* Add accessor loose support * Add private accessors spec support * Fix private dupe name check * Changes from code review * Add duplicated names tests * Add get/set-only tests * Move accessors tests * Split out updates tests * Add helper change tests * Update test output * Update test options
32 lines
613 B
JavaScript
32 lines
613 B
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;
|
|
}
|
|
}
|
|
|
|
const cl = new Cl();
|
|
|
|
expect(cl.publicGetPrivateField()).toEqual("top secret string");
|
|
|
|
cl.publicSetPrivateField("new secret string");
|
|
expect(cl.publicGetPrivateField()).toEqual("new secret string");
|
|
|