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