This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
for (var _i in arr) {
|
||||
var _MULTIPLIER = 5;
|
||||
console.log(arr[_i] * _MULTIPLIER);
|
||||
}
|
||||
for (var i in arr) {
|
||||
var MULTIPLIER = 5;
|
||||
console.log(arr[i] * MULTIPLIER);
|
||||
}
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
"use strict";
|
||||
|
||||
var _ref = [1, 2];
|
||||
var _a = _ref[0];
|
||||
var _b = _ref[1];
|
||||
var a = _ref[0];
|
||||
var b = _ref[1];
|
||||
var _ref2 = [3, 4];
|
||||
var _c = _ref2[0];
|
||||
var _d = _ref2[1];
|
||||
var c = _ref2[0];
|
||||
var d = _ref2[1];
|
||||
var _ref3 = {
|
||||
e: 5,
|
||||
f: 6
|
||||
};
|
||||
var _e = _ref3.e;
|
||||
var _f = _ref3.f;
|
||||
var e = _ref3.e;
|
||||
var f = _ref3.f;
|
||||
var _ref4 = {
|
||||
a: 7,
|
||||
b: 8
|
||||
};
|
||||
var _g = _ref4.a;
|
||||
var _h = _ref4.b;
|
||||
var g = _ref4.a;
|
||||
var h = _ref4.b;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
var _MULTIPLIER = 5;
|
||||
var MULTIPLIER = 5;
|
||||
|
||||
for (var i in arr) {
|
||||
console.log(arr[i] * _MULTIPLIER);
|
||||
}
|
||||
console.log(arr[i] * MULTIPLIER);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
|
||||
var _i = _step.value;
|
||||
}
|
||||
var i = _step.value;
|
||||
}
|
||||
|
||||
9
test/fixtures/transformation/let-scoping/closure/actual.js
vendored
Normal file
9
test/fixtures/transformation/let-scoping/closure/actual.js
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
(function() {
|
||||
let foo = 'bar';
|
||||
|
||||
[true].forEach(function() {
|
||||
foo = 'baz';
|
||||
});
|
||||
|
||||
console.log(foo);
|
||||
});
|
||||
11
test/fixtures/transformation/let-scoping/closure/expected.js
vendored
Normal file
11
test/fixtures/transformation/let-scoping/closure/expected.js
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
(function () {
|
||||
var foo = "bar";
|
||||
|
||||
[true].forEach(function () {
|
||||
foo = "baz";
|
||||
});
|
||||
|
||||
console.log(foo);
|
||||
});
|
||||
@@ -2,11 +2,11 @@ var a = 'var a';
|
||||
{
|
||||
var b = 'var b';
|
||||
{
|
||||
var c = 'var c';
|
||||
let d = 'let d';
|
||||
assert.equal(d, 'let d');
|
||||
var c = 'var c';
|
||||
let d = 'let d';
|
||||
assert.equal(d, 'let d');
|
||||
}
|
||||
assert.throws(function () {
|
||||
d;
|
||||
d;
|
||||
}, /d is not defined/);
|
||||
}
|
||||
|
||||
@@ -3,11 +3,11 @@ var result;
|
||||
let let_result = [];
|
||||
let let_array = ['one', 'two', 'three'];
|
||||
for (var index in let_array) {
|
||||
let let_index = index;
|
||||
let let_value = let_array[let_index];
|
||||
let_result.push(function () {
|
||||
return [let_index, let_value];
|
||||
});
|
||||
let let_index = index;
|
||||
let let_value = let_array[let_index];
|
||||
let_result.push(function () {
|
||||
return [let_index, let_value];
|
||||
});
|
||||
}
|
||||
result = let_result;
|
||||
}
|
||||
|
||||
@@ -3,10 +3,10 @@ var result;
|
||||
let let_x = 'let x';
|
||||
let let_l = [];
|
||||
for (var var_x = 1, var_y = 2, var_z = 3; var_x < 10; var_x ++) {
|
||||
let l_x = var_x, l_y = var_y, l_z = var_z;
|
||||
let_l.push(function () {
|
||||
return [l_x, l_y, l_z];
|
||||
});
|
||||
let l_x = var_x, l_y = var_y, l_z = var_z;
|
||||
let_l.push(function () {
|
||||
return [l_x, l_y, l_z];
|
||||
});
|
||||
}
|
||||
result = let_l;
|
||||
}
|
||||
|
||||
9
test/fixtures/transformation/let-scoping/function-declaration/actual.js
vendored
Normal file
9
test/fixtures/transformation/let-scoping/function-declaration/actual.js
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
domready(function () {
|
||||
let a = 1;
|
||||
const b = 1;
|
||||
runIt();
|
||||
|
||||
function runIt() {
|
||||
console.log(a + b);
|
||||
}
|
||||
});
|
||||
11
test/fixtures/transformation/let-scoping/function-declaration/expected.js
vendored
Normal file
11
test/fixtures/transformation/let-scoping/function-declaration/expected.js
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
domready(function () {
|
||||
var a = 1;
|
||||
var b = 1;
|
||||
runIt();
|
||||
|
||||
function runIt() {
|
||||
console.log(a + b);
|
||||
}
|
||||
});
|
||||
@@ -1,13 +1,13 @@
|
||||
function letInClosure(n) {
|
||||
var l = [];
|
||||
for (var i = 0; i < n; i ++) {
|
||||
let let_i = i;
|
||||
if (i % 3 == 0) {
|
||||
continue;
|
||||
}
|
||||
l.push(function () {
|
||||
return let_i;
|
||||
});
|
||||
let let_i = i;
|
||||
if (i % 3 == 0) {
|
||||
continue;
|
||||
}
|
||||
l.push(function () {
|
||||
return let_i;
|
||||
});
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
var numbers = [1, 2, 3];
|
||||
|
||||
for (let i in numbers) {
|
||||
function foo() {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"throws": "`FunctionDeclaration`s that use `let` and `constant` references aren't allowed outside of the root scope"
|
||||
}
|
||||
6
test/fixtures/transformation/let-scoping/no-renaming/actual.js
vendored
Normal file
6
test/fixtures/transformation/let-scoping/no-renaming/actual.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
function foo (n) {
|
||||
let bar = n;
|
||||
eval('console.log(bar)');
|
||||
}
|
||||
|
||||
foo(42);
|
||||
9
test/fixtures/transformation/let-scoping/no-renaming/expected.js
vendored
Normal file
9
test/fixtures/transformation/let-scoping/no-renaming/expected.js
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
|
||||
function foo(n) {
|
||||
var bar = n;
|
||||
eval("console.log(bar)");
|
||||
}
|
||||
|
||||
foo(42);
|
||||
|
||||
@@ -8,12 +8,12 @@ define(["exports"], function (exports) {
|
||||
exports.foo2 = foo2;
|
||||
var foo3;
|
||||
exports.foo3 = foo3;
|
||||
var _foo4 = 2;
|
||||
exports.foo4 = _foo4;
|
||||
var _foo5;
|
||||
exports.foo5 = _foo5;
|
||||
var _foo6 = 3;
|
||||
exports.foo6 = _foo6;
|
||||
var foo4 = 2;
|
||||
exports.foo4 = foo4;
|
||||
var foo5;
|
||||
exports.foo5 = foo5;
|
||||
var foo6 = 3;
|
||||
exports.foo6 = foo6;
|
||||
function foo7() {}
|
||||
|
||||
var foo8 = function foo8() {};
|
||||
|
||||
@@ -7,12 +7,12 @@ var foo2 = function () {};
|
||||
exports.foo2 = foo2;
|
||||
var foo3;
|
||||
exports.foo3 = foo3;
|
||||
var _foo4 = 2;
|
||||
exports.foo4 = _foo4;
|
||||
var _foo5;
|
||||
exports.foo5 = _foo5;
|
||||
var _foo6 = 3;
|
||||
exports.foo6 = _foo6;
|
||||
var foo4 = 2;
|
||||
exports.foo4 = foo4;
|
||||
var foo5;
|
||||
exports.foo5 = foo5;
|
||||
var foo6 = 3;
|
||||
exports.foo6 = foo6;
|
||||
function foo7() {}
|
||||
|
||||
var foo8 = function foo8() {};
|
||||
|
||||
@@ -14,12 +14,12 @@
|
||||
exports.foo2 = foo2;
|
||||
var foo3;
|
||||
exports.foo3 = foo3;
|
||||
var _foo4 = 2;
|
||||
exports.foo4 = _foo4;
|
||||
var _foo5;
|
||||
exports.foo5 = _foo5;
|
||||
var _foo6 = 3;
|
||||
exports.foo6 = _foo6;
|
||||
var foo4 = 2;
|
||||
exports.foo4 = foo4;
|
||||
var foo5;
|
||||
exports.foo5 = foo5;
|
||||
var foo6 = 3;
|
||||
exports.foo6 = foo6;
|
||||
function foo7() {}
|
||||
|
||||
var foo8 = function foo8() {};
|
||||
|
||||
Reference in New Issue
Block a user