Skip to content

Commit

Permalink
add es2015 test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Feb 5, 2022
1 parent d64851a commit c1fe11d
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 1 deletion.
@@ -0,0 +1,31 @@
var log = [];

function push(x) { log.push(x); return x; }

function logDecoratorRun(a, b) {
push(a);
return function (el) { push(b); return el; };
}

@logDecoratorRun(0, 19)
@logDecoratorRun(1, 18)
class A {
@logDecoratorRun(2, 11)
@logDecoratorRun(3, 10)
a;

@logDecoratorRun(4, 13)
@logDecoratorRun(5, 12)
static b;

@logDecoratorRun(6, 15)
@logDecoratorRun(7, 14)
static #c;

@logDecoratorRun(8, 17)
@logDecoratorRun(9, 16)
#d;
}

var nums = Array.from({ length: 20 }, (_, i) => i);
expect(log).toEqual(nums);
@@ -0,0 +1,27 @@
var counter = 0;

@(x => x)
class A {
foo = (() => {
counter++;
expect(typeof this.method).toBe("function");
expect(this.foo).toBeUndefined();
expect(this.bar).toBeUndefined();
return "foo";
})();

method() {}

bar = (() => {
counter++;
expect(typeof this.method).toBe("function");
expect(this.foo).toBe("foo");
expect(this.bar).toBeUndefined();
})();
}

expect(counter).toBe(0);

new A();

expect(counter).toBe(2);
@@ -0,0 +1,8 @@
{
"plugins": [
["proposal-decorators", { "version": "2021-12" }],
"proposal-class-properties",
"proposal-private-methods",
"proposal-class-static-block"
]
}
@@ -0,0 +1,23 @@
var counter = 0;

@(x => x)
class A {
static foo = (() => {
counter++;
expect(typeof this.method).toBe("function");
expect(this.foo).toBeUndefined();
expect(this.bar).toBeUndefined();
return "foo";
})();

static method() {}

static bar = (() => {
counter++;
expect(typeof this.method).toBe("function");
expect(this.foo).toBe("foo");
expect(this.bar).toBeUndefined();
})();
}

expect(counter).toBe(2);
@@ -1,3 +1,4 @@
{
"plugins": [["proposal-decorators", { "version": "2021-12" }]]
"plugins": [["proposal-decorators", { "version": "2021-12" }]],
"minNodeVersion": "16.11.0"
}

0 comments on commit c1fe11d

Please sign in to comment.