Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix file helpers, re-enable exec tests
- Loading branch information
Showing
9 changed files
with
82 additions
and
81 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
32 changes: 16 additions & 16 deletions
32
packages/babel-plugin-proposal-class-properties/test/fixtures/private/assignment/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 |
---|---|---|
@@ -1,19 +1,19 @@ | ||
// class Foo { | ||
// #foo = 0; | ||
// constructor() { | ||
// this.publicField = this.#privateMethod(); | ||
// } | ||
class Foo { | ||
#foo = 0; | ||
constructor() { | ||
this.publicField = this.#privateMethod(); | ||
} | ||
|
||
// test(other) { | ||
// this.#foo += 1; | ||
// this.#foo = 2; | ||
// other.obj.#foo += 1; | ||
// other.obj.#foo = 2; | ||
// } | ||
test(other) { | ||
this.#foo += 1; | ||
this.#foo = 2; | ||
other.obj.#foo += 1; | ||
other.obj.#foo = 2; | ||
} | ||
|
||
// #privateMethod() { | ||
// return 42; | ||
// } | ||
// } | ||
#privateMethod() { | ||
return 42; | ||
} | ||
} | ||
|
||
// expect((new Foo).publicField).toEqual(42); | ||
expect((new Foo).publicField).toEqual(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
22 changes: 11 additions & 11 deletions
22
...s/babel-plugin-proposal-class-properties/test/fixtures/private/method-exfiltrated/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 |
---|---|---|
@@ -1,13 +1,13 @@ | ||
// let exfiltrated; | ||
// class Foo { | ||
// #privateMethod() {} | ||
let exfiltrated; | ||
class Foo { | ||
#privateMethod() {} | ||
|
||
// constructor() { | ||
// if (exfiltrated === undefined) { | ||
// exfiltrated = this.#privateMethod; | ||
// } | ||
// expect(exfiltrated).toStrictEqual(this.#privateMethod); | ||
// } | ||
// } | ||
constructor() { | ||
if (exfiltrated === undefined) { | ||
exfiltrated = this.#privateMethod; | ||
} | ||
expect(exfiltrated).toStrictEqual(this.#privateMethod); | ||
} | ||
} | ||
|
||
// new Foo(); | ||
new Foo(); |
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
82 changes: 41 additions & 41 deletions
82
packages/babel-plugin-proposal-class-properties/test/fixtures/private/method/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 |
---|---|---|
@@ -1,41 +1,41 @@ | ||
// class Foo { | ||
// constructor(status) { | ||
// this.status = status; | ||
// expect(() => this.#getStatus = null).toThrow(TypeError); | ||
// } | ||
|
||
// #getStatus() { | ||
// return this.status; | ||
// } | ||
|
||
// getCurrentStatus() { | ||
// return this.#getStatus(); | ||
// } | ||
|
||
// setCurrentStatus(newStatus) { | ||
// this.status = newStatus; | ||
// } | ||
|
||
// getFakeStatus(fakeStatus) { | ||
// const getStatus = this.#getStatus; | ||
// return function() { | ||
// return getStatus.call({ status: fakeStatus }); | ||
// }; | ||
// } | ||
|
||
// getFakeStatusFunc() { | ||
// return { | ||
// status: 'fake-status', | ||
// getFakeStatus: this.#getStatus, | ||
// }; | ||
// } | ||
// } | ||
|
||
// const f = new Foo('inactive'); | ||
// expect(f.getCurrentStatus()).toBe('inactive'); | ||
|
||
// f.setCurrentStatus('new-status'); | ||
// expect(f.getCurrentStatus()).toBe('new-status'); | ||
|
||
// expect(f.getFakeStatus('fake')()).toBe('fake'); | ||
// expect(f.getFakeStatusFunc().getFakeStatus()).toBe('fake-status'); | ||
class Foo { | ||
constructor(status) { | ||
this.status = status; | ||
expect(() => this.#getStatus = null).toThrow(TypeError); | ||
} | ||
|
||
#getStatus() { | ||
return this.status; | ||
} | ||
|
||
getCurrentStatus() { | ||
return this.#getStatus(); | ||
} | ||
|
||
setCurrentStatus(newStatus) { | ||
this.status = newStatus; | ||
} | ||
|
||
getFakeStatus(fakeStatus) { | ||
const fakeGetStatus = this.#getStatus; | ||
return function () { | ||
return fakeGetStatus.call({ status: fakeStatus }); | ||
}; | ||
} | ||
|
||
getFakeStatusFunc() { | ||
return { | ||
status: 'fake-status', | ||
getFakeStatus: this.#getStatus, | ||
}; | ||
} | ||
} | ||
|
||
const f = new Foo('inactive'); | ||
expect(f.getCurrentStatus()).toBe('inactive'); | ||
|
||
f.setCurrentStatus('new-status'); | ||
expect(f.getCurrentStatus()).toBe('new-status'); | ||
|
||
expect(f.getFakeStatus('fake')()).toBe('fake'); | ||
expect(f.getFakeStatusFunc().getFakeStatus()).toBe('fake-status'); |
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