mirror of
https://github.com/hanzoai/babel.git
synced 2026-09-24 16:56:45 +00:00
* fix arguments * Update packages/babel-plugin-transform-private-methods/test/fixtures/accessors/arguments/exec.js Co-authored-by: Nicolò Ribaudo <[email protected]> * review * fix types --------- Co-authored-by: Nicolò Ribaudo <[email protected]>
34 lines
689 B
JavaScript
34 lines
689 B
JavaScript
class Cl {
|
|
#privateField = "top secret string";
|
|
|
|
constructor() {
|
|
this.publicField = "not secret string";
|
|
}
|
|
|
|
get #privateFieldValue() {
|
|
expect(arguments.length).toBe(0);
|
|
return this.#privateField;
|
|
}
|
|
|
|
set #privateFieldValue(newValue) {
|
|
expect(arguments.length).toBe(1);
|
|
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");
|
|
|