Skip to content

Commit

Permalink
Add test for fixed block scoping issue (#13304)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed May 13, 2021
1 parent 379bc77 commit e21abad
Show file tree
Hide file tree
Showing 16 changed files with 174 additions and 0 deletions.
@@ -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();
}

0 comments on commit e21abad

Please sign in to comment.