Skip to content

Commit

Permalink
add test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed May 9, 2024
1 parent d8b984b commit 7ff0a31
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 4 deletions.
Expand Up @@ -4,3 +4,9 @@ class Foo {

static accessor #b = 123;
}

Foo = class {
static accessor #a;

static accessor #b = 123;
}
Expand Up @@ -15,3 +15,19 @@ class Foo {
Foo.#B = v;
}
}
Foo = class _Class {
static #A;
static get #a() {
return _Class.#A;
}
static set #a(v) {
_Class.#A = v;
}
static #B = 123;
static get #b() {
return _Class.#B;
}
static set #b(v) {
_Class.#B = v;
}
};
Expand Up @@ -6,3 +6,11 @@ class Foo {

static accessor ['c'] = 456;
}

Foo = class {
static accessor a;

static accessor b = 123;

static accessor ['c'] = 456;
}
Expand Up @@ -22,3 +22,26 @@ class Foo {
Foo.#C = v;
}
}
Foo = class _Class {
static #A;
static get a() {
return _Class.#A;
}
static set a(v) {
_Class.#A = v;
}
static #B = 123;
static get b() {
return _Class.#B;
}
static set b(v) {
_Class.#B = v;
}
static #C = 456;
static get ['c']() {
return _Class.#C;
}
static set ['c'](v) {
_Class.#C = v;
}
};
Expand Up @@ -13,6 +13,8 @@ export const atypical = @dec class {}

expect(logs).toEqual(["default", "atypical"]);

const noop = () => {}

{
const logs = [];
const dec = decFactory(logs);
Expand Down Expand Up @@ -77,8 +79,8 @@ expect(logs).toEqual(["default", "atypical"]);
static "1" = @dec class { static {} };
static 2 = @dec class extends class {} {};
static 3n = @dec class extends class {} { static {} };
static ["4"] = @dec class { p; };
static [5] = @dec class { p; };
static ["4"] = @dec class { static p; };
static [5] = @dec class { @noop p; };
static [6n] = @dec class { p; };
static [f()] = @dec class { @dec static 7() {} };
static [{ [Symbol.toPrimitive]: () => (logs.push("computing symbol"), Symbol(9)) }] = @dec class { p; };
Expand All @@ -99,7 +101,7 @@ expect(logs).toEqual(["default", "atypical"]);
accessor 2 = @dec class extends class {} {};
accessor 3n = @dec class extends class {} { static {} };
accessor ["4"] = @dec class { p; };
accessor [5] = @dec class { p; };
accessor [5] = @dec class { @noop static accessor a; };
accessor [6n] = @dec class { p; };
accessor [f()] = @dec class { @dec static 7() {} };
accessor [{ [Symbol.toPrimitive]: () => (logs.push("computing symbol"), Symbol(9)) }] = @dec class { p; };
Expand All @@ -126,7 +128,7 @@ expect(logs).toEqual(["default", "atypical"]);
static accessor [6n] = @dec class { p; };
static accessor [f()] = @dec class { @dec static 7() {} };
static accessor [{ [Symbol.toPrimitive]: () => (logs.push("computing symbol"), Symbol(9)) }] = @dec class { p; };
static accessor #_10 = @dec class {};
static accessor #_10 = @dec class { static accessor a; };
}

expect(logs).toEqual(["computing f", "computing symbol", "A0", "1", "2", "3", "4", "5", "6", "7", "8", "[9]", "#_10"]);
Expand Down

0 comments on commit 7ff0a31

Please sign in to comment.