Add test for fixed block scoping issue (#13304)
This commit is contained in:
parent
379bc775ed
commit
e21abad016
@ -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);
|
||||
@ -0,0 +1,6 @@
|
||||
for (let result of results) {
|
||||
result = otherValue;
|
||||
fn(() => {
|
||||
result;
|
||||
});
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
{
|
||||
"plugins": [
|
||||
["transform-block-scoping", { "loose": true }],
|
||||
"transform-for-of"
|
||||
]
|
||||
}
|
||||
@ -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();
|
||||
}
|
||||
@ -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);
|
||||
@ -0,0 +1,6 @@
|
||||
for (let result of results) {
|
||||
result = otherValue;
|
||||
fn(() => {
|
||||
result;
|
||||
});
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
{
|
||||
"plugins": [
|
||||
"transform-for-of",
|
||||
["transform-block-scoping", { "loose": true }]
|
||||
]
|
||||
}
|
||||
@ -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();
|
||||
}
|
||||
@ -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);
|
||||
@ -0,0 +1,6 @@
|
||||
for (let result of results) {
|
||||
result = otherValue;
|
||||
fn(() => {
|
||||
result;
|
||||
});
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
{
|
||||
"plugins": [
|
||||
["transform-block-scoping", { "loose": true }],
|
||||
["transform-for-of", { "loose": true }]
|
||||
]
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
@ -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);
|
||||
@ -0,0 +1,6 @@
|
||||
for (let result of results) {
|
||||
result = otherValue;
|
||||
fn(() => {
|
||||
result;
|
||||
});
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
{
|
||||
"plugins": [
|
||||
["transform-for-of", { "loose": true }],
|
||||
["transform-block-scoping", { "loose": true }]
|
||||
]
|
||||
}
|
||||
@ -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();
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user