-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
/
exec.js
46 lines (38 loc) 路 876 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
37
38
39
40
41
42
43
44
45
46
class Foo {
static #x = 1;
static #m = function() { return this.#x; };
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;
}
function f(o, r = o?.Foo.#m()) {
return r;
}
function g(o, r = o?.Foo.#self.getSelf().#m()) {
return r;
}
function h(fnDeep, r = fnDeep?.().very.o?.Foo?.#m()) {
return r;
}
function i(fn, r = fn?.().Foo.#self?.getSelf()?.self.#m()) {
return r;
}
function j(fn, r = (fn().Foo.#self.getSelf().self.#m)?.()) {
return r;
}
expect(f(o)).toBe(1);
expect(g(o)).toBe(1);
expect(h(fnDeep)).toBe(1);
expect(i(fn)).toBe(1);
expect(j(fn)).toBe(1);
}
}
Foo.test();