Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
370 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
.../babel-plugin-proposal-private-methods/test/fixtures/static-accessors-loose/basic/exec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
class Cl { | ||
static #PRIVATE_STATIC_FIELD = "top secret string"; | ||
|
||
static get #privateStaticFieldValue() { | ||
return Cl.#PRIVATE_STATIC_FIELD; | ||
} | ||
|
||
static set #privateStaticFieldValue(newValue) { | ||
Cl.#PRIVATE_STATIC_FIELD = `Updated: ${newValue}`; | ||
} | ||
|
||
static getValue() { | ||
return Cl.#privateStaticFieldValue; | ||
} | ||
|
||
static setValue() { | ||
Cl.#privateStaticFieldValue = "dank"; | ||
} | ||
} | ||
|
||
expect(Cl.getValue()).toEqual("top secret string"); | ||
Cl.setValue(); | ||
expect(Cl.getValue()).toEqual("Updated: dank"); |
19 changes: 19 additions & 0 deletions
19
...babel-plugin-proposal-private-methods/test/fixtures/static-accessors-loose/basic/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class Cl { | ||
static #PRIVATE_STATIC_FIELD = "top secret string"; | ||
|
||
static get #privateStaticFieldValue() { | ||
return Cl.#PRIVATE_STATIC_FIELD; | ||
} | ||
|
||
static set #privateStaticFieldValue(newValue) { | ||
Cl.#PRIVATE_STATIC_FIELD = `Updated: ${newValue}`; | ||
} | ||
|
||
static getValue() { | ||
return Cl.#privateStaticFieldValue; | ||
} | ||
|
||
static setValue() { | ||
Cl.#privateStaticFieldValue = "dank"; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...abel-plugin-proposal-private-methods/test/fixtures/static-accessors-loose/basic/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
class Cl { | ||
static getValue() { | ||
return babelHelpers.classPrivateFieldLooseBase(Cl, _privateStaticFieldValue)[_privateStaticFieldValue]; | ||
} | ||
|
||
static setValue() { | ||
babelHelpers.classPrivateFieldLooseBase(Cl, _privateStaticFieldValue)[_privateStaticFieldValue] = "dank"; | ||
} | ||
|
||
} | ||
|
||
var _PRIVATE_STATIC_FIELD = babelHelpers.classPrivateFieldLooseKey("PRIVATE_STATIC_FIELD"); | ||
|
||
var _privateStaticFieldValue = babelHelpers.classPrivateFieldLooseKey("privateStaticFieldValue"); | ||
|
||
var _set_privateStaticFieldValue = function (newValue) { | ||
babelHelpers.classPrivateFieldLooseBase(Cl, _PRIVATE_STATIC_FIELD)[_PRIVATE_STATIC_FIELD] = `Updated: ${newValue}`; | ||
}; | ||
|
||
var _get_privateStaticFieldValue = function () { | ||
return babelHelpers.classPrivateFieldLooseBase(Cl, _PRIVATE_STATIC_FIELD)[_PRIVATE_STATIC_FIELD]; | ||
}; | ||
|
||
Object.defineProperty(Cl, _PRIVATE_STATIC_FIELD, { | ||
writable: true, | ||
value: "top secret string" | ||
}); | ||
Object.defineProperty(Cl, _privateStaticFieldValue, { | ||
get: _get_privateStaticFieldValue, | ||
set: _set_privateStaticFieldValue | ||
}); |
13 changes: 13 additions & 0 deletions
13
...gin-proposal-private-methods/test/fixtures/static-accessors-loose/get-only-setter/exec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class Cl { | ||
static #PRIVATE_STATIC_FIELD = 0; | ||
|
||
static set #privateStaticFieldValue(newValue) { | ||
Cl.#PRIVATE_STATIC_FIELD = newValue; | ||
} | ||
|
||
static getPrivateStaticFieldValue() { | ||
return Cl.#privateStaticFieldValue; | ||
} | ||
} | ||
|
||
expect(Cl.getPrivateStaticFieldValue()).toBeUndefined(); |
11 changes: 11 additions & 0 deletions
11
...in-proposal-private-methods/test/fixtures/static-accessors-loose/get-only-setter/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class Cl { | ||
static #PRIVATE_STATIC_FIELD = 0; | ||
|
||
static set #privateStaticFieldValue(newValue) { | ||
Cl.#PRIVATE_STATIC_FIELD = newValue; | ||
} | ||
|
||
static getPrivateStaticFieldValue() { | ||
return Cl.#privateStaticFieldValue; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...n-proposal-private-methods/test/fixtures/static-accessors-loose/get-only-setter/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
class Cl { | ||
static getPrivateStaticFieldValue() { | ||
return babelHelpers.classPrivateFieldLooseBase(Cl, _privateStaticFieldValue)[_privateStaticFieldValue]; | ||
} | ||
|
||
} | ||
|
||
var _PRIVATE_STATIC_FIELD = babelHelpers.classPrivateFieldLooseKey("PRIVATE_STATIC_FIELD"); | ||
|
||
var _privateStaticFieldValue = babelHelpers.classPrivateFieldLooseKey("privateStaticFieldValue"); | ||
|
||
var _set_privateStaticFieldValue = function (newValue) { | ||
babelHelpers.classPrivateFieldLooseBase(Cl, _PRIVATE_STATIC_FIELD)[_PRIVATE_STATIC_FIELD] = newValue; | ||
}; | ||
|
||
Object.defineProperty(Cl, _PRIVATE_STATIC_FIELD, { | ||
writable: true, | ||
value: 0 | ||
}); | ||
Object.defineProperty(Cl, _privateStaticFieldValue, { | ||
set: _set_privateStaticFieldValue | ||
}); |
14 changes: 14 additions & 0 deletions
14
...s/babel-plugin-proposal-private-methods/test/fixtures/static-accessors-loose/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"plugins": [ | ||
[ | ||
"external-helpers", | ||
{ | ||
"helperVersion": "7.1000.0" | ||
} | ||
], | ||
["proposal-private-methods", { "loose": true }], | ||
["proposal-class-properties", { "loose": true }], | ||
"transform-block-scoping", | ||
"syntax-class-properties" | ||
] | ||
} |
13 changes: 13 additions & 0 deletions
13
...gin-proposal-private-methods/test/fixtures/static-accessors-loose/set-only-getter/exec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class Cl { | ||
static #PRIVATE_STATIC_FIELD = 0; | ||
|
||
static get #privateStaticFieldValue() { | ||
return Cl.#PRIVATE_STATIC_FIELD; | ||
} | ||
|
||
static setPrivateStaticFieldValue() { | ||
Cl.#privateStaticFieldValue = 1; | ||
} | ||
} | ||
|
||
expect(() => Cl.setPrivateStaticFieldValue()).toThrow(TypeError); |
11 changes: 11 additions & 0 deletions
11
...in-proposal-private-methods/test/fixtures/static-accessors-loose/set-only-getter/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class Cl { | ||
static #PRIVATE_STATIC_FIELD = 0; | ||
|
||
static get #privateStaticFieldValue() { | ||
return Cl.#PRIVATE_STATIC_FIELD; | ||
} | ||
|
||
static setPrivateStaticFieldValue() { | ||
Cl.#privateStaticFieldValue = 1; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...n-proposal-private-methods/test/fixtures/static-accessors-loose/set-only-getter/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
class Cl { | ||
static setPrivateStaticFieldValue() { | ||
babelHelpers.classPrivateFieldLooseBase(Cl, _privateStaticFieldValue)[_privateStaticFieldValue] = 1; | ||
} | ||
|
||
} | ||
|
||
var _PRIVATE_STATIC_FIELD = babelHelpers.classPrivateFieldLooseKey("PRIVATE_STATIC_FIELD"); | ||
|
||
var _privateStaticFieldValue = babelHelpers.classPrivateFieldLooseKey("privateStaticFieldValue"); | ||
|
||
var _get_privateStaticFieldValue = function () { | ||
return babelHelpers.classPrivateFieldLooseBase(Cl, _PRIVATE_STATIC_FIELD)[_PRIVATE_STATIC_FIELD]; | ||
}; | ||
|
||
Object.defineProperty(Cl, _PRIVATE_STATIC_FIELD, { | ||
writable: true, | ||
value: 0 | ||
}); | ||
Object.defineProperty(Cl, _privateStaticFieldValue, { | ||
get: _get_privateStaticFieldValue | ||
}); |
46 changes: 46 additions & 0 deletions
46
...abel-plugin-proposal-private-methods/test/fixtures/static-accessors-loose/updates/exec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
class Cl { | ||
static #privateField = "top secret string"; | ||
static publicField = "not secret string"; | ||
|
||
static get #privateFieldValue() { | ||
return Cl.#privateField; | ||
} | ||
|
||
static set #privateFieldValue(newValue) { | ||
Cl.#privateField = newValue; | ||
} | ||
|
||
static publicGetPrivateField() { | ||
return Cl.#privateFieldValue; | ||
} | ||
|
||
static publicSetPrivateField(newValue) { | ||
Cl.#privateFieldValue = newValue; | ||
} | ||
|
||
static get publicFieldValue() { | ||
return Cl.publicField; | ||
} | ||
|
||
static set publicFieldValue(newValue) { | ||
Cl.publicField = newValue; | ||
} | ||
|
||
static testUpdates() { | ||
Cl.#privateField = 0; | ||
Cl.publicField = 0; | ||
Cl.#privateFieldValue = Cl.#privateFieldValue++; | ||
Cl.publicFieldValue = Cl.publicFieldValue++; | ||
expect(Cl.#privateField).toEqual(Cl.publicField); | ||
|
||
++Cl.#privateFieldValue; | ||
++Cl.publicFieldValue; | ||
expect(Cl.#privateField).toEqual(Cl.publicField); | ||
|
||
Cl.#privateFieldValue += 1; | ||
Cl.publicFieldValue += 1; | ||
expect(Cl.#privateField).toEqual(Cl.publicField); | ||
} | ||
} | ||
|
||
Cl.testUpdates(); |
44 changes: 44 additions & 0 deletions
44
...bel-plugin-proposal-private-methods/test/fixtures/static-accessors-loose/updates/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
class Cl { | ||
static #privateField = "top secret string"; | ||
static publicField = "not secret string"; | ||
|
||
static get #privateFieldValue() { | ||
return Cl.#privateField; | ||
} | ||
|
||
static set #privateFieldValue(newValue) { | ||
Cl.#privateField = newValue; | ||
} | ||
|
||
static publicGetPrivateField() { | ||
return Cl.#privateFieldValue; | ||
} | ||
|
||
static publicSetPrivateField(newValue) { | ||
Cl.#privateFieldValue = newValue; | ||
} | ||
|
||
static get publicFieldValue() { | ||
return Cl.publicField; | ||
} | ||
|
||
static set publicFieldValue(newValue) { | ||
Cl.publicField = newValue; | ||
} | ||
|
||
static testUpdates() { | ||
Cl.#privateField = 0; | ||
Cl.publicField = 0; | ||
Cl.#privateFieldValue = Cl.#privateFieldValue++; | ||
Cl.publicFieldValue = Cl.publicFieldValue++; | ||
|
||
++Cl.#privateFieldValue; | ||
++Cl.publicFieldValue; | ||
|
||
Cl.#privateFieldValue += 1; | ||
Cl.publicFieldValue += 1; | ||
|
||
Cl.#privateFieldValue = -(Cl.#privateFieldValue ** Cl.#privateFieldValue); | ||
Cl.publicFieldValue = -(Cl.publicFieldValue ** Cl.publicFieldValue); | ||
} | ||
} |
Oops, something went wrong.