-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
1 parent
aa8f794
commit 9e97ce6
Showing
6 changed files
with
247 additions
and
5 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
68 changes: 68 additions & 0 deletions
68
...ages/babel-plugin-transform-class-properties/test/fixtures/regression/old-helpers/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,68 @@ | ||
// @force-old-private-helpers | ||
|
||
let s_s, s_gs, i_s, i_gs; | ||
|
||
class A { | ||
static #s_f = 0; | ||
static #s_m() { return 1 } | ||
static get #s_g() { return 2 } | ||
static set #s_s(v) { s_s = v } | ||
static get #s_gs() { return 3 } | ||
static set #s_gs(v) { s_gs = v } | ||
|
||
#i_f = 4; | ||
#i_m() { return 5 } | ||
get #i_g() { return 6 } | ||
set #i_s(v) { i_s = v } | ||
get #i_gs() { return 7 } | ||
set #i_gs(v) { i_gs = v } | ||
|
||
static read() { | ||
expect(A.#s_f).toBe(0); | ||
expect(A.#s_m()).toBe(1); | ||
expect(A.#s_g).toBe(2); | ||
// expect(() => A.#s_s).toThrow(TypeError); -- This was never implemented properly | ||
expect(A.#s_gs).toBe(3); | ||
|
||
const a = new A(); | ||
expect(a.#i_f).toBe(4); | ||
expect(a.#i_m()).toBe(5); | ||
expect(a.#i_g).toBe(6); | ||
expect(() => a.#i_s).toThrow(TypeError); | ||
expect(a.#i_gs).toBe(7); | ||
} | ||
|
||
static write() { | ||
A.#s_f = 8; expect(A.#s_f).toBe(8); | ||
expect(() => A.#s_m = 0).toThrow(TypeError); expect(A.#s_m()).toBe(1); | ||
expect(() => A.#s_g = 0).toThrow(TypeError); expect(A.#s_g).toBe(2); | ||
A.#s_s = 9; expect(s_s).toBe(9); | ||
A.#s_gs = 10; expect(s_gs).toBe(10); | ||
|
||
const a = new A(); | ||
a.#i_f = 11; expect(a.#i_f).toBe(11); | ||
expect(() => a.#i_m = 0).toThrow(TypeError); expect(a.#i_m()).toBe(5); | ||
expect(() => a.#i_g = 0).toThrow(TypeError); expect(a.#i_g).toBe(6); | ||
a.#i_s = 12; expect(i_s).toBe(12); | ||
a.#i_gs = 13; expect(i_gs).toBe(13); | ||
} | ||
|
||
static write_destructuring() { | ||
[A.#s_f] = [14]; expect(A.#s_f).toBe(14); | ||
expect(() => [A.#s_m] = [0]).toThrow(TypeError); expect(A.#s_m()).toBe(1); | ||
expect(() => [A.#s_g] = [0]).toThrow(TypeError); expect(A.#s_g).toBe(2); | ||
[A.#s_s] = [15]; expect(s_s).toBe(15); | ||
[A.#s_gs] = [16]; expect(s_gs).toBe(16); | ||
|
||
const a = new A(); | ||
[a.#i_f] = [17]; expect(a.#i_f).toBe(17); | ||
expect(() => [a.#i_m] = [0]).toThrow(TypeError); expect(a.#i_m()).toBe(5); | ||
expect(() => [a.#i_g] = [0]).toThrow(TypeError); expect(a.#i_g).toBe(6); | ||
[a.#i_s] = [18]; expect(i_s).toBe(18); | ||
[a.#i_gs] = [19]; expect(i_gs).toBe(19); | ||
} | ||
} | ||
|
||
A.read(); | ||
A.write(); | ||
A.write_destructuring(); |
62 changes: 62 additions & 0 deletions
62
...ges/babel-plugin-transform-class-properties/test/fixtures/regression/old-helpers/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,62 @@ | ||
// @force-old-private-helpers | ||
|
||
class A { | ||
static #s_f = 0; | ||
static #s_m() {} | ||
static get #s_g() {} | ||
static set #s_s(v) {} | ||
static get #s_gs() {} | ||
static set #s_gs(v) {} | ||
|
||
#i_f = 0; | ||
#i_m() {} | ||
get #i_g() {} | ||
set #i_s(v) {} | ||
get #i_gs() {} | ||
set #i_gs(v) {} | ||
|
||
static read() { | ||
A.#s_f; | ||
A.#s_m; | ||
A.#s_g; | ||
A.#s_s; | ||
A.#s_gs; | ||
|
||
const a = new A(); | ||
a.#i_f; | ||
a.#i_m; | ||
a.#i_g; | ||
a.#i_s; | ||
a.#i_gs; | ||
} | ||
|
||
static write() { | ||
A.#s_f = 1; | ||
A.#s_m = 2; | ||
A.#s_g = 3; | ||
A.#s_s = 4; | ||
A.#s_gs = 5; | ||
|
||
const a = new A(); | ||
a.#i_f = 6; | ||
a.#i_m = 7; | ||
a.#i_g = 8; | ||
a.#i_s = 9; | ||
a.#i_gs = 10; | ||
} | ||
|
||
static write_destructuring() { | ||
[A.#s_f] = [1]; | ||
[A.#s_m] = [2]; | ||
[A.#s_g] = [3]; | ||
[A.#s_s] = [4]; | ||
[A.#s_gs] = [5]; | ||
|
||
const a = new A(); | ||
[a.#i_f] = [6]; | ||
[a.#i_m] = [7]; | ||
[a.#i_g] = [8]; | ||
[a.#i_s] = [9]; | ||
[a.#i_gs] = [10]; | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...babel-plugin-transform-class-properties/test/fixtures/regression/old-helpers/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,6 @@ | ||
{ | ||
"BABEL_8_BREAKING": false, | ||
"SKIP_ON_PUBLISH": true, | ||
"plugins": ["transform-class-properties", "transform-private-methods"], | ||
"minNodeVersion": "16.0.0" | ||
} |
93 changes: 93 additions & 0 deletions
93
...es/babel-plugin-transform-class-properties/test/fixtures/regression/old-helpers/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,93 @@ | ||
var _i_f = /*#__PURE__*/new WeakMap(); | ||
var _i_m = /*#__PURE__*/new WeakSet(); | ||
var _i_g = /*#__PURE__*/new WeakMap(); | ||
var _i_s = /*#__PURE__*/new WeakMap(); | ||
var _i_gs = /*#__PURE__*/new WeakMap(); | ||
// @force-old-private-helpers | ||
|
||
class A { | ||
constructor() { | ||
babelHelpers.classPrivateFieldInitSpec(this, _i_gs, { | ||
get: _get_i_gs, | ||
set: _set_i_gs | ||
}); | ||
babelHelpers.classPrivateFieldInitSpec(this, _i_s, { | ||
get: void 0, | ||
set: _set_i_s | ||
}); | ||
babelHelpers.classPrivateFieldInitSpec(this, _i_g, { | ||
get: _get_i_g, | ||
set: void 0 | ||
}); | ||
babelHelpers.classPrivateMethodInitSpec(this, _i_m); | ||
babelHelpers.classPrivateFieldInitSpec(this, _i_f, { | ||
writable: true, | ||
value: 0 | ||
}); | ||
} | ||
static read() { | ||
babelHelpers.classStaticPrivateFieldSpecGet(A, A, _s_f); | ||
babelHelpers.classStaticPrivateMethodGet(A, A, _s_m); | ||
babelHelpers.classStaticPrivateFieldSpecGet(A, A, _s_g); | ||
babelHelpers.classStaticPrivateFieldSpecGet(A, A, _s_s); | ||
babelHelpers.classStaticPrivateFieldSpecGet(A, A, _s_gs); | ||
const a = new A(); | ||
babelHelpers.classPrivateFieldGet(a, _i_f); | ||
babelHelpers.classPrivateMethodGet(a, _i_m, _i_m2); | ||
babelHelpers.classPrivateFieldGet(a, _i_g); | ||
a, babelHelpers.writeOnlyError("#i_s"); | ||
babelHelpers.classPrivateFieldGet(a, _i_gs); | ||
} | ||
static write() { | ||
babelHelpers.classStaticPrivateFieldSpecSet(A, A, _s_f, 1); | ||
babelHelpers.classStaticPrivateMethodSet(A, A, _s_m, 2); | ||
babelHelpers.classStaticPrivateFieldSpecSet(A, A, _s_g, 3); | ||
babelHelpers.classStaticPrivateFieldSpecSet(A, A, _s_s, 4); | ||
babelHelpers.classStaticPrivateFieldSpecSet(A, A, _s_gs, 5); | ||
const a = new A(); | ||
babelHelpers.classPrivateFieldSet(a, _i_f, 6); | ||
a, 7, babelHelpers.readOnlyError("#i_m"); | ||
a, 8, babelHelpers.readOnlyError("#i_g"); | ||
babelHelpers.classPrivateFieldSet(a, _i_s, 9); | ||
babelHelpers.classPrivateFieldSet(a, _i_gs, 10); | ||
} | ||
static write_destructuring() { | ||
[babelHelpers.classStaticPrivateFieldDestructureSet(A, A, _s_f).value] = [1]; | ||
[babelHelpers.classStaticPrivateFieldDestructureSet(A, A, _s_m).value] = [2]; | ||
[babelHelpers.classStaticPrivateFieldDestructureSet(A, A, _s_g).value] = [3]; | ||
[babelHelpers.classStaticPrivateFieldDestructureSet(A, A, _s_s).value] = [4]; | ||
[babelHelpers.classStaticPrivateFieldDestructureSet(A, A, _s_gs).value] = [5]; | ||
const a = new A(); | ||
[babelHelpers.classPrivateFieldDestructureSet(a, _i_f).value] = [6]; | ||
[babelHelpers.classPrivateFieldDestructureSet(a, _i_m).value] = [7]; | ||
[babelHelpers.classPrivateFieldDestructureSet(a, _i_g).value] = [8]; | ||
[babelHelpers.classPrivateFieldDestructureSet(a, _i_s).value] = [9]; | ||
[babelHelpers.classPrivateFieldDestructureSet(a, _i_gs).value] = [10]; | ||
} | ||
} | ||
function _s_m() {} | ||
function _get_s_g() {} | ||
function _set_s_s(v) {} | ||
function _get_s_gs() {} | ||
function _set_s_gs(v) {} | ||
function _i_m2() {} | ||
function _get_i_g() {} | ||
function _set_i_s(v) {} | ||
function _get_i_gs() {} | ||
function _set_i_gs(v) {} | ||
var _s_gs = { | ||
get: _get_s_gs, | ||
set: _set_s_gs | ||
}; | ||
var _s_s = { | ||
get: void 0, | ||
set: _set_s_s | ||
}; | ||
var _s_g = { | ||
get: _get_s_g, | ||
set: void 0 | ||
}; | ||
var _s_f = { | ||
writable: true, | ||
value: 0 | ||
}; |