mirror of
https://github.com/hanzoai/babel.git
synced 2026-09-24 16:56:45 +00:00
36 lines
473 B
JavaScript
36 lines
473 B
JavaScript
class Foo {
|
|
#bar = "foo";
|
|
|
|
test() {
|
|
return this.#bar;
|
|
}
|
|
|
|
update() {
|
|
this.#bar++;
|
|
}
|
|
|
|
set(val) {
|
|
this.#bar = val;
|
|
}
|
|
|
|
static test(foo) {
|
|
return foo.#bar;
|
|
}
|
|
|
|
static update(foo) {
|
|
foo.#bar **= 2;
|
|
}
|
|
}
|
|
|
|
const f = new Foo();
|
|
expect(f.test()).toBe("foo");
|
|
expect(Foo.test(f)).toBe("foo");
|
|
expect("bar" in f).toBe(false);
|
|
|
|
f.set(1);
|
|
expect(f.test()).toBe(1);
|
|
f.update();
|
|
expect(Foo.test(f)).toBe(2);
|
|
Foo.update(f);
|
|
expect(f.test()).toBe(4);
|