Debian Codegraph @

packages/babel-plugin-proposal-class-properties/test/fixtures/private/optional-chain-before-member-call/exec.js

raw symbols SCIP
1 class Foo {
2 static #x = 1;
3 static #m = function() { return this.#x; };
4 static #self = Foo;
5 static self = Foo;
6 static getSelf() { return this }
7
8 static test() {
9 const o = { Foo: Foo };
10 const deep = { very: { o } };
11 function fn() {
12 return o;
13 }
14 function fnDeep() {
15 return deep;
16 }
17
18 expect(o?.Foo.#m()).toEqual(1);
19 expect(o?.Foo.#m().toString).toEqual(1..toString);
20 expect(o?.Foo.#m().toString()).toEqual('1');
21
22 expect(deep?.very.o?.Foo.#m()).toEqual(1);
23 expect(deep?.very.o?.Foo.#m().toString).toEqual(1..toString);
24 expect(deep?.very.o?.Foo.#m().toString()).toEqual('1');
25
26 expect(o?.Foo.#self.#m()).toEqual(1);
27 expect(o?.Foo.#self.self.#m()).toEqual(1);
28 expect(o?.Foo.#self?.self.#m()).toEqual(1);
29 expect(o?.Foo.#self.self?.self.#m()).toEqual(1);
30 expect(o?.Foo.#self?.self?.self.#m()).toEqual(1);
31
32 expect(o?.Foo.#self.getSelf().#m()).toEqual(1);
33 expect(o?.Foo.#self.getSelf?.().#m()).toEqual(1);
34 expect(o?.Foo.#self?.getSelf().#m()).toEqual(1);
35 expect(o?.Foo.#self?.getSelf?.().#m()).toEqual(1);
36 expect(o?.Foo.#self.getSelf()?.self.#m()).toEqual(1);
37 expect(o?.Foo.#self.getSelf?.()?.self.#m()).toEqual(1);
38 expect(o?.Foo.#self?.getSelf()?.self.#m()).toEqual(1);
39 expect(o?.Foo.#self?.getSelf?.()?.self.#m()).toEqual(1);
40
41 expect(fn?.().Foo.#m()).toEqual(1);
42 expect(fn?.().Foo.#m().toString).toEqual(1..toString);
43 expect(fn?.().Foo.#m().toString()).toEqual('1');
44
45 expect(fnDeep?.().very.o?.Foo.#m()).toEqual(1);
46 expect(fnDeep?.().very.o?.Foo.#m().toString).toEqual(1..toString);
47 expect(fnDeep?.().very.o?.Foo.#m().toString()).toEqual('1');
48
49 expect(fn?.().Foo.#self.#m()).toEqual(1);
50 expect(fn?.().Foo.#self.self.#m()).toEqual(1);
51 expect(fn?.().Foo.#self?.self.#m()).toEqual(1);
52 expect(fn?.().Foo.#self.self?.self.#m()).toEqual(1);
53 expect(fn?.().Foo.#self?.self?.self.#m()).toEqual(1);
54
55 expect(fn?.().Foo.#self.getSelf().#m()).toEqual(1);
56 expect(fn?.().Foo.#self.getSelf?.().#m()).toEqual(1);
57 expect(fn?.().Foo.#self?.getSelf().#m()).toEqual(1);
58 expect(fn?.().Foo.#self?.getSelf?.().#m()).toEqual(1);
59 expect(fn?.().Foo.#self.getSelf()?.self.#m()).toEqual(1);
60 expect(fn?.().Foo.#self.getSelf?.()?.self.#m()).toEqual(1);
61 expect(fn?.().Foo.#self?.getSelf()?.self.#m()).toEqual(1);
62 expect(fn?.().Foo.#self?.getSelf?.()?.self.#m()).toEqual(1);
63 }
64
65 static testNull() {
66 const o = null;;
67 const deep = { very: { o } };
68 const fn = null;
69 function fnDeep() {
70 return deep;
71 }
72
73 expect(o?.Foo.#m()).toEqual(undefined);
74 expect(o?.Foo.#m().toString).toEqual(undefined);
75 expect(o?.Foo.#m().toString()).toEqual(undefined);
76
77 expect(deep?.very.o?.Foo.#m()).toEqual(undefined);
78 expect(deep?.very.o?.Foo.#m().toString).toEqual(undefined);
79 expect(deep?.very.o?.Foo.#m().toString()).toEqual(undefined);
80
81 expect(o?.Foo.#self.#m()).toEqual(undefined);
82 expect(o?.Foo.#self.self.#m()).toEqual(undefined);
83 expect(o?.Foo.#self?.self.#m()).toEqual(undefined);
84 expect(o?.Foo.#self.self?.self.#m()).toEqual(undefined);
85 expect(o?.Foo.#self?.self?.self.#m()).toEqual(undefined);
86
87 expect(o?.Foo.#self.getSelf().#m()).toEqual(undefined);
88 expect(o?.Foo.#self.getSelf?.().#m()).toEqual(undefined);
89 expect(o?.Foo.#self?.getSelf().#m()).toEqual(undefined);
90 expect(o?.Foo.#self?.getSelf?.().#m()).toEqual(undefined);
91 expect(o?.Foo.#self.getSelf()?.self.#m()).toEqual(undefined);
92 expect(o?.Foo.#self.getSelf?.()?.self.#m()).toEqual(undefined);
93 expect(o?.Foo.#self?.getSelf()?.self.#m()).toEqual(undefined);
94 expect(o?.Foo.#self?.getSelf?.()?.self.#m()).toEqual(undefined);
95
96 expect(fn?.().Foo.#m()).toEqual(undefined);
97 expect(fn?.().Foo.#m().toString).toEqual(undefined);
98 expect(fn?.().Foo.#m().toString()).toEqual(undefined);
99
100 expect(fnDeep?.().very.o?.Foo.#m()).toEqual(undefined);
101 expect(fnDeep?.().very.o?.Foo.#m().toString).toEqual(undefined);
102 expect(fnDeep?.().very.o?.Foo.#m().toString()).toEqual(undefined);
103
104 expect(fn?.().Foo.#self.#m()).toEqual(undefined);
105 expect(fn?.().Foo.#self.self.#m()).toEqual(undefined);
106 expect(fn?.().Foo.#self?.self.#m()).toEqual(undefined);
107 expect(fn?.().Foo.#self.self?.self.#m()).toEqual(undefined);
108 expect(fn?.().Foo.#self?.self?.self.#m()).toEqual(undefined);
109
110 expect(fn?.().Foo.#self.getSelf().#m()).toEqual(undefined);
111 expect(fn?.().Foo.#self.getSelf?.().#m()).toEqual(undefined);
112 expect(fn?.().Foo.#self?.getSelf().#m()).toEqual(undefined);
113 expect(fn?.().Foo.#self?.getSelf?.().#m()).toEqual(undefined);
114 expect(fn?.().Foo.#self.getSelf()?.self.#m()).toEqual(undefined);
115 expect(fn?.().Foo.#self.getSelf?.()?.self.#m()).toEqual(undefined);
116 expect(fn?.().Foo.#self?.getSelf()?.self.#m()).toEqual(undefined);
117 expect(fn?.().Foo.#self?.getSelf?.()?.self.#m()).toEqual(undefined);
118 }
119 }
120
121 Foo.test();
122 Foo.testNull();