mirror of
https://github.com/hanzoai/babel.git
synced 2026-09-24 16:56:45 +00:00
51 lines
1.1 KiB
JavaScript
51 lines
1.1 KiB
JavaScript
class Cl {
|
|
#privateField = "top secret string";
|
|
|
|
constructor() {
|
|
this.publicField = "not secret string";
|
|
}
|
|
|
|
get #privateFieldValue() {
|
|
return this.#privateField;
|
|
}
|
|
|
|
set #privateFieldValue(newValue) {
|
|
this.#privateField = newValue;
|
|
}
|
|
|
|
publicGetPrivateField() {
|
|
return this.#privateFieldValue;
|
|
}
|
|
|
|
publicSetPrivateField(newValue) {
|
|
this.#privateFieldValue = newValue;
|
|
}
|
|
|
|
get publicFieldValue() {
|
|
return this.publicField;
|
|
}
|
|
|
|
set publicFieldValue(newValue) {
|
|
this.publicField = newValue;
|
|
}
|
|
|
|
testUpdates() {
|
|
this.#privateField = 0n;
|
|
this.publicField = 0n;
|
|
this.#privateFieldValue = this.#privateFieldValue++;
|
|
this.publicFieldValue = this.publicFieldValue++;
|
|
expect(this.#privateField).toEqual(this.publicField);
|
|
|
|
++this.#privateFieldValue;
|
|
++this.publicFieldValue;
|
|
expect(this.#privateField).toEqual(this.publicField);
|
|
|
|
this.#privateFieldValue += 1n;
|
|
this.publicFieldValue += 1n;
|
|
expect(this.#privateField).toEqual(this.publicField);
|
|
}
|
|
}
|
|
|
|
const cl = new Cl();
|
|
cl.testUpdates();
|