Debian Codegraph @

packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-getters--to-es2015/private/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 getA() {
20 return this.#a;
21 }
22 }
23
24 let foo = new Foo();
25
26 const aContext = foo['#aContext'];
27
28 expect(aContext.access.get.call(foo)).toBe(2);
29 expect(foo.getA()).toBe(2);
30 foo.value = 123;
31 expect(aContext.access.get.call(foo)).toBe(124);
32 expect(foo.getA()).toBe(124);
33 expect(aContext.name).toBe('#a');
34 expect(aContext.kind).toBe('getter');
35 expect(aContext.static).toBe(false);
36 expect(aContext.private).toBe(true);
37 expect(typeof aContext.addInitializer).toBe('function');