Debian Codegraph @

packages/babel-plugin-proposal-class-properties/test/fixtures/private/parenthesized-optional-member-call-with-transform/exec.js

raw symbols SCIP
1 class Foo {
2 static #x = 1;
3
4 static self = Foo;
5 static #m = function() { return this.#x; };
6 static getSelf() { return Foo }
7
8 test() {
9 const o = { Foo: Foo };
10 const fn = function () {
11 return o;
12 };
13
14 expect((Foo?.#m)()).toEqual(1);
15 expect((Foo?.#m)().toString).toEqual(1..toString);
16 expect((Foo?.#m)().toString()).toEqual('1');
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((((o.Foo?.self.getSelf)())?.#m)()).toEqual(1);
23 expect((((o.Foo.self?.getSelf)())?.#m)()).toEqual(1);
24
25 expect((((fn()?.Foo?.self.getSelf)())?.#m)()).toEqual(1);
26 expect((((fn?.().Foo.self?.getSelf)())?.#m)()).toEqual(1);
27 }
28
29 testNull() {
30 const o = null;
31 const fn = function () {
32 return { o };
33 }
34
35 expect(() => { (o?.Foo.#m)() }).toThrow();
36 expect(() => { (o?.Foo.#m)().toString }).toThrow();
37 expect(() => { (o?.Foo.#m)().toString() }).toThrow();
38
39 expect(() => { (((o.Foo?.self.getSelf)())?.#m)() }).toThrow();
40 expect(() => { (((o.Foo.self?.getSelf)())?.#m)() }).toThrow();
41
42 expect(() => (((fn()?.Foo?.self.getSelf)())?.#m)()).toThrow();
43 expect(() => (((fn?.().Foo.self?.getSelf)())?.#m)()).toThrow();
44 }
45 }
46
47 (new Foo).test();
48 (new Foo).testNull();