-
-
Notifications
You must be signed in to change notification settings - Fork 482
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(transformer): exponentiation transform: fix temp var names (#6318)
Make naming of temp vars follow Babel. It wasn't apparent that our version of this transform was behaving differently from Babel because the Babel plugin has very few tests. The added tests replicate Babel's output.
- Loading branch information
1 parent
c0e2fef
commit 3a4bcc7
Showing
7 changed files
with
358 additions
and
11 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
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
5 changes: 5 additions & 0 deletions
5
...abel-plugin-transform-exponentiation-operator/test/fixtures/assign-to-identifier/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,5 @@ | ||
let x, fn; | ||
x **= 2; | ||
y **= 3; | ||
z **= fn(); | ||
q **= unboundFn(); |
6 changes: 6 additions & 0 deletions
6
...bel-plugin-transform-exponentiation-operator/test/fixtures/assign-to-identifier/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,6 @@ | ||
var _y, _z, _q; | ||
let x, fn; | ||
x = Math.pow(x, 2); | ||
_y = y, y = Math.pow(_y, 3); | ||
_z = z, z = Math.pow(_z, fn()); | ||
_q = q, q = Math.pow(_q, unboundFn()); |
54 changes: 54 additions & 0 deletions
54
...ugin-transform-exponentiation-operator/test/fixtures/assign-to-member-expression/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,54 @@ | ||
// Bound root of member expression | ||
let obj; | ||
obj.prop **= 2; | ||
obj['prop blah'] **= 3; | ||
obj.foo.bar.qux **= 4; | ||
|
||
let boundPropName; | ||
obj[boundPropName] **= 5; | ||
obj[unboundPropName] **= 6; | ||
|
||
let boundPropName2; | ||
obj.foo2.bar2[boundPropName2] **= 7; | ||
obj.foo3.bar3[unboundPropName2] **= 8; | ||
|
||
let boundPropObj; | ||
obj[boundPropObj.foo.bar.qux] **= 9; | ||
obj[unboundPropObj.foo.bar.qux] **= 10; | ||
|
||
// Unbound root of member expression | ||
unboundObj.prop **= 11; | ||
unboundObj['prop blah'] **= 12; | ||
unboundObj.foo.bar.qux **= 13; | ||
|
||
let boundPropName3; | ||
unboundObj[boundPropName3] **= 14; | ||
unboundObj[unboundPropName3] **= 15; | ||
|
||
let boundPropName4; | ||
unboundObj.foo2.bar2[boundPropName4] **= 16; | ||
unboundObj.foo3.bar3[unboundPropName4] **= 17; | ||
|
||
let boundPropObj2; | ||
unboundObj[boundPropObj2.foo.bar.qux] **= 18; | ||
unboundObj[unboundPropObj2.foo.bar.qux] **= 19; | ||
|
||
// Other expressions | ||
let fn, fn2; | ||
fn().prop **= 20; | ||
fn().foo().bar().qux **= 21; | ||
fn().prop[fn2()] **= 22; | ||
fn().prop[fn3().foo().bar().qux() + ' junk'] **= 23; | ||
|
||
// `this` | ||
this.prop **= 24; | ||
this.foo.bar.qux **= 25; | ||
this['prop blah'] **= 26; | ||
this[fn4().foo.bar.qux()] **= 27; | ||
|
||
function outer() { | ||
this.prop **= 28; | ||
this.foo.bar.qux **= 29; | ||
this['prop blah'] **= 30; | ||
this[fn4().foo.bar.qux()] **= 31; | ||
} |
Oops, something went wrong.