/
exec.js
121 lines (102 loc) 路 4.67 KB
/
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
class Foo {
static #x = 1;
static #self = Foo;
static self = Foo;
static getSelf() { return this }
static test() {
const o = { Foo: Foo };
const deep = { very: { o } };
function fn() {
return o;
}
function fnDeep() {
return deep;
}
expect(o?.Foo.#x).toEqual(1);
expect(o?.Foo.#x.toString).toEqual(1..toString);
expect(o?.Foo.#x.toString()).toEqual('1');
expect(deep?.very.o?.Foo.#x).toEqual(1);
expect(deep?.very.o?.Foo.#x.toString).toEqual(1..toString);
expect(deep?.very.o?.Foo.#x.toString()).toEqual('1');
expect(o?.Foo.#self.#x).toEqual(1);
expect(o?.Foo.#self.self.#x).toEqual(1);
expect(o?.Foo.#self?.self.#x).toEqual(1);
expect(o?.Foo.#self.self?.self.#x).toEqual(1);
expect(o?.Foo.#self?.self?.self.#x).toEqual(1);
expect(o?.Foo.#self.getSelf().#x).toEqual(1);
expect(o?.Foo.#self.getSelf?.().#x).toEqual(1);
expect(o?.Foo.#self?.getSelf().#x).toEqual(1);
expect(o?.Foo.#self?.getSelf?.().#x).toEqual(1);
expect(o?.Foo.#self.getSelf()?.self.#x).toEqual(1);
expect(o?.Foo.#self.getSelf?.()?.self.#x).toEqual(1);
expect(o?.Foo.#self?.getSelf()?.self.#x).toEqual(1);
expect(o?.Foo.#self?.getSelf?.()?.self.#x).toEqual(1);
expect(fn?.().Foo.#x).toEqual(1);
expect(fn?.().Foo.#x.toString).toEqual(1..toString);
expect(fn?.().Foo.#x.toString()).toEqual('1');
expect(fnDeep?.().very.o?.Foo.#x).toEqual(1);
expect(fnDeep?.().very.o?.Foo.#x.toString).toEqual(1..toString);
expect(fnDeep?.().very.o?.Foo.#x.toString()).toEqual('1');
expect(fn?.().Foo.#self.#x).toEqual(1);
expect(fn?.().Foo.#self.self.#x).toEqual(1);
expect(fn?.().Foo.#self?.self.#x).toEqual(1);
expect(fn?.().Foo.#self.self?.self.#x).toEqual(1);
expect(fn?.().Foo.#self?.self?.self.#x).toEqual(1);
expect(fn?.().Foo.#self.getSelf().#x).toEqual(1);
expect(fn?.().Foo.#self.getSelf?.().#x).toEqual(1);
expect(fn?.().Foo.#self?.getSelf().#x).toEqual(1);
expect(fn?.().Foo.#self?.getSelf?.().#x).toEqual(1);
expect(fn?.().Foo.#self.getSelf()?.self.#x).toEqual(1);
expect(fn?.().Foo.#self.getSelf?.()?.self.#x).toEqual(1);
expect(fn?.().Foo.#self?.getSelf()?.self.#x).toEqual(1);
expect(fn?.().Foo.#self?.getSelf?.()?.self.#x).toEqual(1);
}
static testNull() {
const o = null;;
const deep = { very: { o } };
const fn = null;
function fnDeep() {
return deep;
}
expect(o?.Foo.#x).toEqual(undefined);
expect(o?.Foo.#x.toString).toEqual(undefined);
expect(o?.Foo.#x.toString()).toEqual(undefined);
expect(deep?.very.o?.Foo.#x).toEqual(undefined);
expect(deep?.very.o?.Foo.#x.toString).toEqual(undefined);
expect(deep?.very.o?.Foo.#x.toString()).toEqual(undefined);
expect(o?.Foo.#self.#x).toEqual(undefined);
expect(o?.Foo.#self.self.#x).toEqual(undefined);
expect(o?.Foo.#self?.self.#x).toEqual(undefined);
expect(o?.Foo.#self.self?.self.#x).toEqual(undefined);
expect(o?.Foo.#self?.self?.self.#x).toEqual(undefined);
expect(o?.Foo.#self.getSelf().#x).toEqual(undefined);
expect(o?.Foo.#self.getSelf?.().#x).toEqual(undefined);
expect(o?.Foo.#self?.getSelf().#x).toEqual(undefined);
expect(o?.Foo.#self?.getSelf?.().#x).toEqual(undefined);
expect(o?.Foo.#self.getSelf()?.self.#x).toEqual(undefined);
expect(o?.Foo.#self.getSelf?.()?.self.#x).toEqual(undefined);
expect(o?.Foo.#self?.getSelf()?.self.#x).toEqual(undefined);
expect(o?.Foo.#self?.getSelf?.()?.self.#x).toEqual(undefined);
expect(fn?.().Foo.#x).toEqual(undefined);
expect(fn?.().Foo.#x.toString).toEqual(undefined);
expect(fn?.().Foo.#x.toString()).toEqual(undefined);
expect(fnDeep?.().very.o?.Foo.#x).toEqual(undefined);
expect(fnDeep?.().very.o?.Foo.#x.toString).toEqual(undefined);
expect(fnDeep?.().very.o?.Foo.#x.toString()).toEqual(undefined);
expect(fn?.().Foo.#self.#x).toEqual(undefined);
expect(fn?.().Foo.#self.self.#x).toEqual(undefined);
expect(fn?.().Foo.#self?.self.#x).toEqual(undefined);
expect(fn?.().Foo.#self.self?.self.#x).toEqual(undefined);
expect(fn?.().Foo.#self?.self?.self.#x).toEqual(undefined);
expect(fn?.().Foo.#self.getSelf().#x).toEqual(undefined);
expect(fn?.().Foo.#self.getSelf?.().#x).toEqual(undefined);
expect(fn?.().Foo.#self?.getSelf().#x).toEqual(undefined);
expect(fn?.().Foo.#self?.getSelf?.().#x).toEqual(undefined);
expect(fn?.().Foo.#self.getSelf()?.self.#x).toEqual(undefined);
expect(fn?.().Foo.#self.getSelf?.()?.self.#x).toEqual(undefined);
expect(fn?.().Foo.#self?.getSelf()?.self.#x).toEqual(undefined);
expect(fn?.().Foo.#self?.getSelf?.()?.self.#x).toEqual(undefined);
}
}
Foo.test();
Foo.testNull();