forked from babel/babel
/
exec.js
38 lines (31 loc) 路 836 Bytes
/
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
function dec(get, context) {
context.addInitializer(function() {
this[context.name + 'Context'] = context;
});
return function () {
return get.call(this) + 1;
}
}
class Foo {
static value = 1;
@dec
static get #a() {
return this.value;
}
static getA() {
return this.#a;
}
}
const aContext = Foo['#aContext'];
expect(aContext.access.get.call(Foo)).toBe(2);
expect(Foo.getA()).toBe(2);
Foo.value = 123;
expect(aContext.access.get.call(Foo)).toBe(124);
expect(Foo.getA()).toBe(124);
expect(aContext.name).toBe('#a');
expect(aContext.kind).toBe('getter');
expect(aContext.isStatic).toBe(true);
expect(aContext.isPrivate).toBe(true);
expect(typeof aContext.addInitializer).toBe('function');
expect(typeof aContext.setMetadata).toBe('function');
expect(typeof aContext.getMetadata).toBe('function');