Debian Codegraph @

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

raw symbols SCIP
1 function dec(fn, context) {
2 context.addInitializer(function() {
3 this[context.name + 'Context'] = context;
4 });
5
6 return function () {
7 return fn.call(this) + 1;
8 }
9 }
10
11 class Foo {
12 static value = 1;
13
14 @dec
15 static #a() {
16 return this.value;
17 }
18
19 static callA() {
20 return this.#a();
21 }
22 }
23
24 const aContext = Foo['#aContext'];
25
26 // First call gets the method, second call calls the method with correct `this`
27 expect(aContext.access.get.call(Foo).call(Foo)).toBe(2);
28 expect(Foo.callA()).toBe(2);
29 Foo.value = 123;
30 expect(aContext.access.get.call(Foo).call(Foo)).toBe(124);
31 expect(Foo.callA()).toBe(124);
32
33 expect(aContext.name).toBe('#a');
34 expect(aContext.kind).toBe('method');
35 expect(aContext.isStatic).toBe(true);
36 expect(aContext.isPrivate).toBe(true);
37 expect(typeof aContext.addInitializer).toBe('function');
38 expect(typeof aContext.setMetadata).toBe('function');
39 expect(typeof aContext.getMetadata).toBe('function');