Debian Codegraph @

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

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