Debian Codegraph @

packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-fields--to-es2015/private/exec.js

raw symbols SCIP
1 function dec(_v, context) {
2 return function (v) {
3 this[context.name + 'Context'] = context;
4 return (v || 1) + 1;
5 }
6 }
7
8 class Foo {
9 @dec
10 #a;
11
12 @dec
13 #b = 123;
14 }
15
16 let foo = new Foo();
17
18 const aContext = foo['#aContext'];
19 const bContext = foo['#bContext'];
20
21 expect(aContext.access.get.call(foo)).toBe(2);
22 aContext.access.set.call(foo, 123);
23 expect(aContext.access.get.call(foo)).toBe(123);
24 expect(aContext.name).toBe('#a');
25 expect(aContext.kind).toBe('field');
26 expect(aContext.isStatic).toBe(false);
27 expect(aContext.isPrivate).toBe(true);
28 expect(typeof aContext.addInitializer).toBe('undefined');
29 expect(typeof aContext.setMetadata).toBe('function');
30 expect(typeof aContext.getMetadata).toBe('function');
31
32 expect(bContext.access.get.call(foo)).toBe(124);
33 bContext.access.set.call(foo, 123);
34 expect(bContext.access.get.call(foo)).toBe(123);
35 expect(bContext.name).toBe('#b');
36 expect(bContext.kind).toBe('field');
37 expect(bContext.isStatic).toBe(false);
38 expect(bContext.isPrivate).toBe(true);
39 expect(typeof aContext.addInitializer).toBe('undefined');
40 expect(typeof aContext.setMetadata).toBe('function');
41 expect(typeof aContext.getMetadata).toBe('function');