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 10, 2024
1 parent 4a66836 commit ab03576
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 0 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 @@ -132,6 +134,27 @@ expect(logs).toEqual(["default", "atypical"]);
expect(logs).toEqual(["computing f", "computing symbol", "A0", "1", "2", "3", "4", "5", "6", "7", "8", "[9]", "#_10"]);
}

{
const logs = [];
const dec = decFactory(logs);
const f = () => { logs.push("computing f"); return 8. }

class C {
static accessor A0 = @dec class {};
static accessor "1" = @dec class { static {} };
static accessor 2 = @dec class extends class {} {};
static accessor 3n = @dec class extends class {} { static {} };
static accessor ["4"] = @dec class { static accessor p; };
static accessor [5] = @dec class { @noop static accessor #p; };
static accessor [6n] = @dec class { accessor p; };
static accessor [f()] = @dec class { @dec static 7() {} };
static accessor [{ [Symbol.toPrimitive]: () => (logs.push("computing symbol"), Symbol(9)) }] = @dec class { @noop accessor p; };
static accessor #_10 = @dec class {};
}

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

{
const logs = [];
const dec = decFactory(logs);
Expand Down

0 comments on commit ab03576

Please sign in to comment.