Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for fixed block scoping issue (#13304)
- Loading branch information
1 parent
379bc77
commit e21abad
Showing
16 changed files
with
174 additions
and
0 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
...abel-plugin-transform-block-scoping/test/fixtures/general/issue-8128-for-of-after/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,15 @@ | ||
"use strict"; | ||
|
||
const results = [0, 1, 2]; | ||
const fns = []; | ||
|
||
for (let result of results) { | ||
result = result * 2; | ||
fns.push(() => { | ||
return result; | ||
}); | ||
} | ||
|
||
expect(fns[0]()).toBe(0); | ||
expect(fns[1]()).toBe(2); | ||
expect(fns[2]()).toBe(4); |
6 changes: 6 additions & 0 deletions
6
...bel-plugin-transform-block-scoping/test/fixtures/general/issue-8128-for-of-after/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,6 @@ | ||
for (let result of results) { | ||
result = otherValue; | ||
fn(() => { | ||
result; | ||
}); | ||
} |
6 changes: 6 additions & 0 deletions
6
...plugin-transform-block-scoping/test/fixtures/general/issue-8128-for-of-after/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 @@ | ||
{ | ||
"plugins": [ | ||
["transform-block-scoping", { "loose": true }], | ||
"transform-for-of" | ||
] | ||
} |
22 changes: 22 additions & 0 deletions
22
...el-plugin-transform-block-scoping/test/fixtures/general/issue-8128-for-of-after/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 @@ | ||
var _loop = function (_result) { | ||
_result = otherValue; | ||
fn(() => { | ||
_result; | ||
}); | ||
result = _result; | ||
}; | ||
|
||
var _iterator = babelHelpers.createForOfIteratorHelper(results), | ||
_step; | ||
|
||
try { | ||
for (_iterator.s(); !(_step = _iterator.n()).done;) { | ||
var result = _step.value; | ||
|
||
_loop(result); | ||
} | ||
} catch (err) { | ||
_iterator.e(err); | ||
} finally { | ||
_iterator.f(); | ||
} |
15 changes: 15 additions & 0 deletions
15
...bel-plugin-transform-block-scoping/test/fixtures/general/issue-8128-for-of-before/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,15 @@ | ||
"use strict"; | ||
|
||
const results = [0, 1, 2]; | ||
const fns = []; | ||
|
||
for (let result of results) { | ||
result = result * 2; | ||
fns.push(() => { | ||
return result; | ||
}); | ||
} | ||
|
||
expect(fns[0]()).toBe(0); | ||
expect(fns[1]()).toBe(2); | ||
expect(fns[2]()).toBe(4); |
6 changes: 6 additions & 0 deletions
6
...el-plugin-transform-block-scoping/test/fixtures/general/issue-8128-for-of-before/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,6 @@ | ||
for (let result of results) { | ||
result = otherValue; | ||
fn(() => { | ||
result; | ||
}); | ||
} |
6 changes: 6 additions & 0 deletions
6
...lugin-transform-block-scoping/test/fixtures/general/issue-8128-for-of-before/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 @@ | ||
{ | ||
"plugins": [ | ||
"transform-for-of", | ||
["transform-block-scoping", { "loose": true }] | ||
] | ||
} |
20 changes: 20 additions & 0 deletions
20
...l-plugin-transform-block-scoping/test/fixtures/general/issue-8128-for-of-before/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,20 @@ | ||
var _iterator = babelHelpers.createForOfIteratorHelper(results), | ||
_step; | ||
|
||
try { | ||
var _loop = function () { | ||
var result = _step.value; | ||
result = otherValue; | ||
fn(() => { | ||
result; | ||
}); | ||
}; | ||
|
||
for (_iterator.s(); !(_step = _iterator.n()).done;) { | ||
_loop(); | ||
} | ||
} catch (err) { | ||
_iterator.e(err); | ||
} finally { | ||
_iterator.f(); | ||
} |
15 changes: 15 additions & 0 deletions
15
...lugin-transform-block-scoping/test/fixtures/general/issue-8128-for-of-loose-after/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,15 @@ | ||
"use strict"; | ||
|
||
const results = [0, 1, 2]; | ||
const fns = []; | ||
|
||
for (let result of results) { | ||
result = result * 2; | ||
fns.push(() => { | ||
return result; | ||
}); | ||
} | ||
|
||
expect(fns[0]()).toBe(0); | ||
expect(fns[1]()).toBe(2); | ||
expect(fns[2]()).toBe(4); |
6 changes: 6 additions & 0 deletions
6
...ugin-transform-block-scoping/test/fixtures/general/issue-8128-for-of-loose-after/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,6 @@ | ||
for (let result of results) { | ||
result = otherValue; | ||
fn(() => { | ||
result; | ||
}); | ||
} |
6 changes: 6 additions & 0 deletions
6
...-transform-block-scoping/test/fixtures/general/issue-8128-for-of-loose-after/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 @@ | ||
{ | ||
"plugins": [ | ||
["transform-block-scoping", { "loose": true }], | ||
["transform-for-of", { "loose": true }] | ||
] | ||
} |
13 changes: 13 additions & 0 deletions
13
...gin-transform-block-scoping/test/fixtures/general/issue-8128-for-of-loose-after/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,13 @@ | ||
var _loop = function (_result) { | ||
_result = otherValue; | ||
fn(() => { | ||
_result; | ||
}); | ||
result = _result; | ||
}; | ||
|
||
for (var _iterator = babelHelpers.createForOfIteratorHelperLoose(results), _step; !(_step = _iterator()).done;) { | ||
var result = _step.value; | ||
|
||
_loop(result); | ||
} |
15 changes: 15 additions & 0 deletions
15
...ugin-transform-block-scoping/test/fixtures/general/issue-8128-for-of-loose-before/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,15 @@ | ||
"use strict"; | ||
|
||
const results = [0, 1, 2]; | ||
const fns = []; | ||
|
||
for (let result of results) { | ||
result = result * 2; | ||
fns.push(() => { | ||
return result; | ||
}); | ||
} | ||
|
||
expect(fns[0]()).toBe(0); | ||
expect(fns[1]()).toBe(2); | ||
expect(fns[2]()).toBe(4); |
6 changes: 6 additions & 0 deletions
6
...gin-transform-block-scoping/test/fixtures/general/issue-8128-for-of-loose-before/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,6 @@ | ||
for (let result of results) { | ||
result = otherValue; | ||
fn(() => { | ||
result; | ||
}); | ||
} |
6 changes: 6 additions & 0 deletions
6
...transform-block-scoping/test/fixtures/general/issue-8128-for-of-loose-before/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 @@ | ||
{ | ||
"plugins": [ | ||
["transform-for-of", { "loose": true }], | ||
["transform-block-scoping", { "loose": true }] | ||
] | ||
} |
11 changes: 11 additions & 0 deletions
11
...in-transform-block-scoping/test/fixtures/general/issue-8128-for-of-loose-before/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,11 @@ | ||
var _loop = function () { | ||
var result = _step.value; | ||
result = otherValue; | ||
fn(() => { | ||
result; | ||
}); | ||
}; | ||
|
||
for (var _iterator = babelHelpers.createForOfIteratorHelperLoose(results), _step; !(_step = _iterator()).done;) { | ||
_loop(); | ||
} |