forked from babel/babel
/
exec.js
36 lines (27 loc) 路 960 Bytes
/
exec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
class Foo {
static #x = 1;
static self = Foo;
static #m = function() { return this.#x; };
static getSelf() { return Foo }
test() {
const o = { Foo: Foo };
expect((Foo?.#m)()).toEqual(1);
expect((Foo?.#m)().toString).toEqual(1..toString);
expect((Foo?.#m)().toString()).toEqual('1');
expect((o?.Foo.#m)()).toEqual(1);
expect((o?.Foo.#m)().toString).toEqual(1..toString);
expect((o?.Foo.#m)().toString()).toEqual('1');
expect((((o.Foo?.self.getSelf)())?.#m)()).toEqual(1);
expect((((o.Foo.self?.getSelf)())?.#m)()).toEqual(1);
}
testNull() {
const o = null;
expect(() => { (o?.Foo.#m)() }).toThrow();
expect(() => { (o?.Foo.#m)().toString }).toThrow();
expect(() => { (o?.Foo.#m)().toString() }).toThrow();
expect(() => { (((o.Foo?.self.getSelf)())?.#m)() }).toThrow();
expect(() => { (((o.Foo.self?.getSelf)())?.#m)() }).toThrow();
}
}
(new Foo).test();
(new Foo).testNull();