| 1 |
class Foo { |
| 2 |
#bar = "foo"; |
| 3 |
|
| 4 |
test() { |
| 5 |
return this.#bar; |
| 6 |
} |
| 7 |
|
| 8 |
update() { |
| 9 |
this.#bar++; |
| 10 |
} |
| 11 |
|
| 12 |
set(val) { |
| 13 |
this.#bar = val; |
| 14 |
} |
| 15 |
|
| 16 |
static test(foo) { |
| 17 |
return foo.#bar; |
| 18 |
} |
| 19 |
|
| 20 |
static update(foo) { |
| 21 |
foo.#bar **= 2; |
| 22 |
} |
| 23 |
} |
| 24 |
|
| 25 |
const f = new Foo(); |
| 26 |
expect(f.test()).toBe("foo"); |
| 27 |
expect(Foo.test(f)).toBe("foo"); |
| 28 |
expect("bar" in f).toBe(false); |
| 29 |
|
| 30 |
f.set(1); |
| 31 |
expect(f.test()).toBe(1); |
| 32 |
f.update(); |
| 33 |
expect(Foo.test(f)).toBe(2); |
| 34 |
Foo.update(f); |
| 35 |
expect(f.test()).toBe(4); |