-
-
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
Showing
8 changed files
with
87 additions
and
10 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
.../babel-plugin-proposal-private-methods/test/fixtures/accessors-loose/reassignment/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 @@ | ||
let counter = 0; | ||
class Foo { | ||
constructor() { | ||
this.#privateFieldValue = ++counter; | ||
} | ||
|
||
get #privateFieldValue() { | ||
return 42; | ||
} | ||
} | ||
|
||
expect(() => new Foo).toThrow(); | ||
expect(counter).toBe(1); |
10 changes: 10 additions & 0 deletions
10
...babel-plugin-proposal-private-methods/test/fixtures/accessors-loose/reassignment/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,10 @@ | ||
let counter = 0; | ||
class Foo { | ||
constructor() { | ||
this.#privateFieldValue = ++counter; | ||
} | ||
|
||
get #privateFieldValue() { | ||
return 42; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...abel-plugin-proposal-private-methods/test/fixtures/accessors-loose/reassignment/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,18 @@ | ||
var counter = 0; | ||
|
||
var _privateFieldValue = babelHelpers.classPrivateFieldLooseKey("privateFieldValue"); | ||
|
||
class Foo { | ||
constructor() { | ||
Object.defineProperty(this, _privateFieldValue, { | ||
get: _get_privateFieldValue, | ||
set: void 0 | ||
}); | ||
babelHelpers.classPrivateFieldLooseBase(this, _privateFieldValue)[_privateFieldValue] = ++counter; | ||
} | ||
|
||
} | ||
|
||
var _get_privateFieldValue = function () { | ||
return 42; | ||
}; |
13 changes: 13 additions & 0 deletions
13
packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/reassignment/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 @@ | ||
let counter = 0; | ||
class Foo { | ||
constructor() { | ||
this.#privateFieldValue = ++counter; | ||
} | ||
|
||
get #privateFieldValue() { | ||
return 42; | ||
} | ||
} | ||
|
||
expect(() => new Foo).toThrow(); | ||
expect(counter).toBe(1); |
10 changes: 10 additions & 0 deletions
10
packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/reassignment/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,10 @@ | ||
let counter = 0; | ||
class Foo { | ||
constructor() { | ||
this.#privateFieldValue = ++counter; | ||
} | ||
|
||
get #privateFieldValue() { | ||
return 42; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...ages/babel-plugin-proposal-private-methods/test/fixtures/accessors/reassignment/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,19 @@ | ||
var counter = 0; | ||
|
||
var _privateFieldValue = new WeakMap(); | ||
|
||
class Foo { | ||
constructor() { | ||
_privateFieldValue.set(this, { | ||
get: _get_privateFieldValue, | ||
set: void 0 | ||
}); | ||
|
||
babelHelpers.classPrivateMethodSet(++counter); | ||
} | ||
|
||
} | ||
|
||
var _get_privateFieldValue = function () { | ||
return 42; | ||
}; |
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