forked from babel/babel
/
exec.js
75 lines (63 loc) 路 1.37 KB
/
exec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
var log = [];
function push(x) {
log.push(x);
return x;
}
function logClassDecoratorRun(a, b, c) {
push(a);
return function (el, { addInitializer }) {
push(b);
addInitializer(function () {
push(c);
});
return el;
};
}
function logAccessorDecoratorRun(a, b, c, d) {
push(a);
return function (el, { addInitializer }) {
push(b);
addInitializer(function () {
push(c);
});
return {
init: () => push(d),
};
};
}
function logMethodDecoratorRun(a, b, c, d) {
push(a);
return function (el, { addInitializer }) {
push(b);
addInitializer(function () {
push(c);
});
return () => (el(), push(d))
};
}
@logClassDecoratorRun(0, 19, 21)
@logClassDecoratorRun(1, 18, 20)
class A {
@logAccessorDecoratorRun(2, 11, 23, 31)
@logAccessorDecoratorRun(3, 10, 22, 30)
accessor a;
@logMethodDecoratorRun(4, 13, 25, 35)
@logMethodDecoratorRun(5, 12, 24, 34)
b() {};
@logMethodDecoratorRun(6, 15, 27, 37)
@logMethodDecoratorRun(7, 14, 26, 36)
#c() {};
@logAccessorDecoratorRun(8, 17, 29, 33)
@logAccessorDecoratorRun(9, 16, 28, 32)
accessor #d;
constructor() {
this.b();
this.#c();
this.a = this.#d = null;
}
}
var nums = Array.from({ length: 22 }, (_, i) => i);
expect(log).toEqual(nums);
new A();
var nums = Array.from({ length: 38 }, (_, i) => i);
expect(log).toEqual(nums);