Debian Codegraph @

packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-getters--to-es2015/public/exec.js

raw symbols SCIP
1 function dec(get, context) {
2 context.addInitializer(function() {
3 this[context.name + 'Context'] = context;
4 });
5
6 return function () {
7 return get.call(this) + 1;
8 }
9 }
10
11 class Foo {
12 value = 1;
13
14 @dec
15 get a() {
16 return this.value;
17 }
18
19 @dec
20 get ['b']() {
21 return this.value;
22 }
23 }
24
25 let foo = new Foo();
26
27 const aContext = foo['aContext'];
28 const bContext = foo['bContext'];
29
30 expect(foo.a).toBe(2);
31 expect(foo.b).toBe(2);
32 expect(aContext.access.get.call(foo)).toBe(2);
33 expect(bContext.access.get.call(foo)).toBe(2);
34 foo.value = 123;
35 expect(foo.a).toBe(124);
36 expect(foo.b).toBe(124);
37 expect(aContext.access.get.call(foo)).toBe(124);
38 expect(bContext.access.get.call(foo)).toBe(124);
39
40 expect(aContext.name).toBe('a');
41 expect(aContext.kind).toBe('getter');
42 expect(aContext.static).toBe(false);
43 expect(aContext.private).toBe(false);
44 expect(typeof aContext.addInitializer).toBe('function');
45
46 expect(bContext.name).toBe('b');
47 expect(bContext.kind).toBe('getter');
48 expect(bContext.static).toBe(false);
49 expect(bContext.private).toBe(false);
50 expect(typeof bContext.addInitializer).toBe('function');