Debian Codegraph @

packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-fields--to-es2015/public/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 @dec
16 ['c'] = 456;
17 }
18
19 let foo = new Foo();
20
21 const aContext = foo['aContext'];
22 const bContext = foo['bContext'];
23 const cContext = foo['cContext'];
24
25 expect(foo.a).toBe(2);
26 expect(aContext.access.get.call(foo)).toBe(2);
27 foo.a = 123;
28 expect(foo.a).toBe(123);
29 expect(aContext.access.get.call(foo)).toBe(123);
30 aContext.access.set.call(foo, 456);
31 expect(foo.a).toBe(456);
32 expect(aContext.access.get.call(foo)).toBe(456);
33 expect(aContext.name).toBe('a');
34 expect(aContext.kind).toBe('field');
35 expect(aContext.static).toBe(false);
36 expect(aContext.private).toBe(false);
37 expect(typeof aContext.addInitializer).toBe('undefined');
38 expect(foo.hasOwnProperty('a')).toBe(true);
39 expect(Foo.prototype.hasOwnProperty('a')).toBe(false);
40
41 expect(foo.b).toBe(124);
42 foo.b = 123;
43 expect(foo.b).toBe(123);
44 expect(bContext.name).toBe('b');
45 expect(bContext.kind).toBe('field');
46 expect(bContext.static).toBe(false);
47 expect(bContext.private).toBe(false);
48 expect(typeof bContext.addInitializer).toBe('undefined');
49 expect(foo.hasOwnProperty('b')).toBe(true);
50 expect(Foo.prototype.hasOwnProperty('b')).toBe(false);
51
52 expect(foo.c).toBe(457);
53 foo.c = 456;
54 expect(foo.c).toBe(456);
55 expect(cContext.name).toBe('c');
56 expect(cContext.kind).toBe('field');
57 expect(cContext.static).toBe(false);
58 expect(cContext.private).toBe(false);
59 expect(typeof cContext.addInitializer).toBe('undefined');
60 expect(foo.hasOwnProperty('c')).toBe(true);
61 expect(Foo.prototype.hasOwnProperty('c')).toBe(false);