add loose mode to spread and destructuring
This commit is contained in:
1
test/fixtures/transformation/es6-destructuring-loose/array/actual.js
vendored
Normal file
1
test/fixtures/transformation/es6-destructuring-loose/array/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var [a, [b], [c], d] = ["hello", [", ", "junk"], ["world"]];
|
||||
10
test/fixtures/transformation/es6-destructuring-loose/array/expected.js
vendored
Normal file
10
test/fixtures/transformation/es6-destructuring-loose/array/expected.js
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
|
||||
var _ref = ["hello", [", ", "junk"], ["world"]];
|
||||
|
||||
var a = _ref[0];
|
||||
var _ref$1 = _ref[1];
|
||||
var b = _ref$1[0];
|
||||
var _ref$2 = _ref[2];
|
||||
var c = _ref$2[0];
|
||||
var d = _ref[3];
|
||||
1
test/fixtures/transformation/es6-destructuring-loose/assignment-expression/actual.js
vendored
Normal file
1
test/fixtures/transformation/es6-destructuring-loose/assignment-expression/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
console.log([x] = [123]);
|
||||
4
test/fixtures/transformation/es6-destructuring-loose/assignment-expression/expected.js
vendored
Normal file
4
test/fixtures/transformation/es6-destructuring-loose/assignment-expression/expected.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
"use strict";
|
||||
|
||||
var _temp, _temp2;
|
||||
console.log((_temp = [123], _temp2 = _temp, x = _temp2[0], _temp));
|
||||
1
test/fixtures/transformation/es6-destructuring-loose/assignment-statement/actual.js
vendored
Normal file
1
test/fixtures/transformation/es6-destructuring-loose/assignment-statement/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
[a, b] = f();
|
||||
7
test/fixtures/transformation/es6-destructuring-loose/assignment-statement/expected.js
vendored
Normal file
7
test/fixtures/transformation/es6-destructuring-loose/assignment-statement/expected.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
var _ref = f();
|
||||
|
||||
var _ref2 = _ref;
|
||||
a = _ref2[0];
|
||||
b = _ref2[1];
|
||||
1
test/fixtures/transformation/es6-destructuring-loose/empty/actual.js
vendored
Normal file
1
test/fixtures/transformation/es6-destructuring-loose/empty/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var [, a, [b], [c], d] = ["foo", "hello", [", ", "junk"], ["world"]];
|
||||
10
test/fixtures/transformation/es6-destructuring-loose/empty/expected.js
vendored
Normal file
10
test/fixtures/transformation/es6-destructuring-loose/empty/expected.js
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
|
||||
var _ref = ["foo", "hello", [", ", "junk"], ["world"]];
|
||||
|
||||
var a = _ref[1];
|
||||
var _ref$2 = _ref[2];
|
||||
var b = _ref$2[0];
|
||||
var _ref$3 = _ref[3];
|
||||
var c = _ref$3[0];
|
||||
var d = _ref[4];
|
||||
3
test/fixtures/transformation/es6-destructuring-loose/es7-object-rest/actual.js
vendored
Normal file
3
test/fixtures/transformation/es6-destructuring-loose/es7-object-rest/actual.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
var { ...x } = z;
|
||||
var { x, ...y } = z;
|
||||
(function({ x, ...y }) { })
|
||||
23
test/fixtures/transformation/es6-destructuring-loose/es7-object-rest/expected.js
vendored
Normal file
23
test/fixtures/transformation/es6-destructuring-loose/es7-object-rest/expected.js
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
|
||||
var _objectWithoutProperties = function (obj, keys) {
|
||||
var target = {};
|
||||
|
||||
for (var i in obj) {
|
||||
if (keys.indexOf(i) >= 0) continue;
|
||||
if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
|
||||
target[i] = obj[i];
|
||||
}
|
||||
|
||||
return target;
|
||||
};
|
||||
|
||||
var x = _objectWithoutProperties(z, []);
|
||||
|
||||
var x = z.x;
|
||||
var y = _objectWithoutProperties(z, ["x"]);
|
||||
|
||||
(function (_ref) {
|
||||
var x = _ref.x;
|
||||
var y = _objectWithoutProperties(_ref, ["x"]);
|
||||
});
|
||||
3
test/fixtures/transformation/es6-destructuring-loose/es7-object-rest/options.json
vendored
Normal file
3
test/fixtures/transformation/es6-destructuring-loose/es7-object-rest/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"experimental": true
|
||||
}
|
||||
3
test/fixtures/transformation/es6-destructuring-loose/for-in/actual.js
vendored
Normal file
3
test/fixtures/transformation/es6-destructuring-loose/for-in/actual.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
for (var [name, value] in obj) {
|
||||
print("Name: " + name + ", Value: " + value);
|
||||
}
|
||||
8
test/fixtures/transformation/es6-destructuring-loose/for-in/expected.js
vendored
Normal file
8
test/fixtures/transformation/es6-destructuring-loose/for-in/expected.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
for (var _ref in obj) {
|
||||
var _ref2 = _ref;
|
||||
var name = _ref2[0];
|
||||
var value = _ref2[1];
|
||||
print("Name: " + name + ", Value: " + value);
|
||||
}
|
||||
3
test/fixtures/transformation/es6-destructuring-loose/for-of/actual.js
vendored
Normal file
3
test/fixtures/transformation/es6-destructuring-loose/for-of/actual.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
for (var [ name, before, after ] of this.test.expectation.registers) {
|
||||
|
||||
}
|
||||
9
test/fixtures/transformation/es6-destructuring-loose/for-of/expected.js
vendored
Normal file
9
test/fixtures/transformation/es6-destructuring-loose/for-of/expected.js
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
|
||||
for (var _iterator = this.test.expectation.registers[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
|
||||
var _ref = _step.value;
|
||||
var _ref2 = _ref;
|
||||
var name = _ref2[0];
|
||||
var before = _ref2[1];
|
||||
var after = _ref2[2];
|
||||
}
|
||||
1
test/fixtures/transformation/es6-destructuring-loose/member-expression/actual.js
vendored
Normal file
1
test/fixtures/transformation/es6-destructuring-loose/member-expression/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
[this.foo, this.bar] = [1, 2];
|
||||
7
test/fixtures/transformation/es6-destructuring-loose/member-expression/expected.js
vendored
Normal file
7
test/fixtures/transformation/es6-destructuring-loose/member-expression/expected.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
var _ref = [1, 2];
|
||||
|
||||
var _ref2 = _ref;
|
||||
this.foo = _ref2[0];
|
||||
this.bar = _ref2[1];
|
||||
1
test/fixtures/transformation/es6-destructuring-loose/mixed/actual.js
vendored
Normal file
1
test/fixtures/transformation/es6-destructuring-loose/mixed/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var {topLeft: [x1, y1], bottomRight: [x2, y2] } = rect;
|
||||
8
test/fixtures/transformation/es6-destructuring-loose/mixed/expected.js
vendored
Normal file
8
test/fixtures/transformation/es6-destructuring-loose/mixed/expected.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
var _rect$topLeft = rect.topLeft;
|
||||
var x1 = _rect$topLeft[0];
|
||||
var y1 = _rect$topLeft[1];
|
||||
var _rect$bottomRight = rect.bottomRight;
|
||||
var x2 = _rect$bottomRight[0];
|
||||
var y2 = _rect$bottomRight[1];
|
||||
2
test/fixtures/transformation/es6-destructuring-loose/multiple/actual.js
vendored
Normal file
2
test/fixtures/transformation/es6-destructuring-loose/multiple/actual.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
var { x, y } = coords,
|
||||
foo = "bar";
|
||||
5
test/fixtures/transformation/es6-destructuring-loose/multiple/expected.js
vendored
Normal file
5
test/fixtures/transformation/es6-destructuring-loose/multiple/expected.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
var x = coords.x;
|
||||
var y = coords.y;
|
||||
var foo = "bar";
|
||||
1
test/fixtures/transformation/es6-destructuring-loose/object-advanced/actual.js
vendored
Normal file
1
test/fixtures/transformation/es6-destructuring-loose/object-advanced/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var {topLeft: {x: x1, y: y1}, bottomRight: {x: x2, y: y2}} = rect;
|
||||
6
test/fixtures/transformation/es6-destructuring-loose/object-advanced/expected.js
vendored
Normal file
6
test/fixtures/transformation/es6-destructuring-loose/object-advanced/expected.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
var x1 = rect.topLeft.x;
|
||||
var y1 = rect.topLeft.y;
|
||||
var x2 = rect.bottomRight.x;
|
||||
var y2 = rect.bottomRight.y;
|
||||
1
test/fixtures/transformation/es6-destructuring-loose/object-basic/actual.js
vendored
Normal file
1
test/fixtures/transformation/es6-destructuring-loose/object-basic/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var { x, y } = coords;
|
||||
4
test/fixtures/transformation/es6-destructuring-loose/object-basic/expected.js
vendored
Normal file
4
test/fixtures/transformation/es6-destructuring-loose/object-basic/expected.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
"use strict";
|
||||
|
||||
var x = coords.x;
|
||||
var y = coords.y;
|
||||
3
test/fixtures/transformation/es6-destructuring-loose/options.json
vendored
Normal file
3
test/fixtures/transformation/es6-destructuring-loose/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"loose": ["destructuring"]
|
||||
}
|
||||
15
test/fixtures/transformation/es6-destructuring-loose/parameters/actual.js
vendored
Normal file
15
test/fixtures/transformation/es6-destructuring-loose/parameters/actual.js
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
function somethingAdvanced({topLeft: {x: x1, y: y1}, bottomRight: {x: x2, y: y2}}){
|
||||
|
||||
}
|
||||
|
||||
function unpackObject({title: title, author: author}) {
|
||||
return title + ' ' + author;
|
||||
}
|
||||
|
||||
console.log(unpackObject({title: 'title', author: 'author'}));
|
||||
|
||||
var unpackArray = function ([a, b, c], [x, y, z]) {
|
||||
return a+b+c;
|
||||
};
|
||||
|
||||
console.log(unpackArray(['hello', ', ', 'world'], [1, 2, 3]));
|
||||
30
test/fixtures/transformation/es6-destructuring-loose/parameters/expected.js
vendored
Normal file
30
test/fixtures/transformation/es6-destructuring-loose/parameters/expected.js
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
"use strict";
|
||||
|
||||
function somethingAdvanced(_ref) {
|
||||
var x1 = _ref.topLeft.x;
|
||||
var y1 = _ref.topLeft.y;
|
||||
var x2 = _ref.bottomRight.x;
|
||||
var y2 = _ref.bottomRight.y;
|
||||
}
|
||||
|
||||
function unpackObject(_ref2) {
|
||||
var title = _ref2.title;
|
||||
var author = _ref2.author;
|
||||
return title + " " + author;
|
||||
}
|
||||
|
||||
console.log(unpackObject({ title: "title", author: "author" }));
|
||||
|
||||
var unpackArray = function (_ref3, _ref4) {
|
||||
var _ref32 = _ref3;
|
||||
var a = _ref32[0];
|
||||
var b = _ref32[1];
|
||||
var c = _ref32[2];
|
||||
var _ref42 = _ref4;
|
||||
var x = _ref42[0];
|
||||
var y = _ref42[1];
|
||||
var z = _ref42[2];
|
||||
return a + b + c;
|
||||
};
|
||||
|
||||
console.log(unpackArray(["hello", ", ", "world"], [1, 2, 3]));
|
||||
5
test/fixtures/transformation/es6-destructuring-loose/spread/actual.js
vendored
Normal file
5
test/fixtures/transformation/es6-destructuring-loose/spread/actual.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
var isSorted = ([x, y, ...wow]) => {
|
||||
if (!zs.length) return true
|
||||
if (y > x) return isSorted(zs)
|
||||
return false
|
||||
};
|
||||
12
test/fixtures/transformation/es6-destructuring-loose/spread/expected.js
vendored
Normal file
12
test/fixtures/transformation/es6-destructuring-loose/spread/expected.js
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
var isSorted = function (_ref) {
|
||||
var _ref2 = _ref;
|
||||
var x = _ref2[0];
|
||||
var y = _ref2[1];
|
||||
var wow = _ref2.slice(2);
|
||||
|
||||
if (!zs.length) return true;
|
||||
if (y > x) return isSorted(zs);
|
||||
return false;
|
||||
};
|
||||
@@ -32,16 +32,16 @@ function unpackObject(_ref2) {
|
||||
console.log(unpackObject({ title: "title", author: "author" }));
|
||||
|
||||
var unpackArray = function (_ref3, _ref4) {
|
||||
var _ref3 = _slicedToArray(_ref3, 3);
|
||||
var _ref32 = _slicedToArray(_ref3, 3);
|
||||
|
||||
var a = _ref3[0];
|
||||
var b = _ref3[1];
|
||||
var c = _ref3[2];
|
||||
var _ref4 = _slicedToArray(_ref4, 3);
|
||||
var a = _ref32[0];
|
||||
var b = _ref32[1];
|
||||
var c = _ref32[2];
|
||||
var _ref42 = _slicedToArray(_ref4, 3);
|
||||
|
||||
var x = _ref4[0];
|
||||
var y = _ref4[1];
|
||||
var z = _ref4[2];
|
||||
var x = _ref42[0];
|
||||
var y = _ref42[1];
|
||||
var z = _ref42[2];
|
||||
return a + b + c;
|
||||
};
|
||||
|
||||
|
||||
12
test/fixtures/transformation/es6-let-scoping/exec-block-scoped-2/exec.js
vendored
Normal file
12
test/fixtures/transformation/es6-let-scoping/exec-block-scoped-2/exec.js
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
assert.equal(() => {
|
||||
let sum = 0;
|
||||
let a = 0;
|
||||
{
|
||||
let a = 10;
|
||||
for (let i = 0; i < a; i++) {
|
||||
let a = 1;
|
||||
sum += (() => a)();
|
||||
}
|
||||
}
|
||||
return sum;
|
||||
}(), 10);
|
||||
9
test/fixtures/transformation/es6-spread-loose/arguments-array/actual.js
vendored
Normal file
9
test/fixtures/transformation/es6-spread-loose/arguments-array/actual.js
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
function foo() {
|
||||
return bar([...arguments]);
|
||||
}
|
||||
|
||||
function bar(one, two, three) {
|
||||
return [one, two, three];
|
||||
}
|
||||
|
||||
foo("foo", "bar");
|
||||
11
test/fixtures/transformation/es6-spread-loose/arguments-array/expected.js
vendored
Normal file
11
test/fixtures/transformation/es6-spread-loose/arguments-array/expected.js
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
function foo() {
|
||||
return bar([].concat(arguments));
|
||||
}
|
||||
|
||||
function bar(one, two, three) {
|
||||
return [one, two, three];
|
||||
}
|
||||
|
||||
foo("foo", "bar");
|
||||
9
test/fixtures/transformation/es6-spread-loose/arguments-concat/actual.js
vendored
Normal file
9
test/fixtures/transformation/es6-spread-loose/arguments-concat/actual.js
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
function foo() {
|
||||
return bar("test", ...arguments);
|
||||
}
|
||||
|
||||
function bar(one, two, three) {
|
||||
return [one, two, three];
|
||||
}
|
||||
|
||||
foo("foo", "bar");
|
||||
11
test/fixtures/transformation/es6-spread-loose/arguments-concat/expected.js
vendored
Normal file
11
test/fixtures/transformation/es6-spread-loose/arguments-concat/expected.js
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
function foo() {
|
||||
return bar.apply(undefined, ["test"].concat(arguments));
|
||||
}
|
||||
|
||||
function bar(one, two, three) {
|
||||
return [one, two, three];
|
||||
}
|
||||
|
||||
foo("foo", "bar");
|
||||
9
test/fixtures/transformation/es6-spread-loose/arguments/actual.js
vendored
Normal file
9
test/fixtures/transformation/es6-spread-loose/arguments/actual.js
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
function foo() {
|
||||
return bar(...arguments);
|
||||
}
|
||||
|
||||
function bar(one, two, three) {
|
||||
return [one, two, three];
|
||||
}
|
||||
|
||||
foo("foo", "bar");
|
||||
11
test/fixtures/transformation/es6-spread-loose/arguments/expected.js
vendored
Normal file
11
test/fixtures/transformation/es6-spread-loose/arguments/expected.js
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
function foo() {
|
||||
return bar.apply(undefined, arguments);
|
||||
}
|
||||
|
||||
function bar(one, two, three) {
|
||||
return [one, two, three];
|
||||
}
|
||||
|
||||
foo("foo", "bar");
|
||||
1
test/fixtures/transformation/es6-spread-loose/array-literal-first/actual.js
vendored
Normal file
1
test/fixtures/transformation/es6-spread-loose/array-literal-first/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var lyrics = [...parts, "head", "and", "toes"];
|
||||
3
test/fixtures/transformation/es6-spread-loose/array-literal-first/expected.js
vendored
Normal file
3
test/fixtures/transformation/es6-spread-loose/array-literal-first/expected.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
var lyrics = [].concat(parts, ["head", "and", "toes"]);
|
||||
1
test/fixtures/transformation/es6-spread-loose/array-literal-middle/actual.js
vendored
Normal file
1
test/fixtures/transformation/es6-spread-loose/array-literal-middle/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var a = [b, ...c, d];
|
||||
3
test/fixtures/transformation/es6-spread-loose/array-literal-middle/expected.js
vendored
Normal file
3
test/fixtures/transformation/es6-spread-loose/array-literal-middle/expected.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
var a = [b].concat(c, [d]);
|
||||
1
test/fixtures/transformation/es6-spread-loose/array-literal-multiple/actual.js
vendored
Normal file
1
test/fixtures/transformation/es6-spread-loose/array-literal-multiple/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var a = [b, ...c, d, e, ...f];
|
||||
3
test/fixtures/transformation/es6-spread-loose/array-literal-multiple/expected.js
vendored
Normal file
3
test/fixtures/transformation/es6-spread-loose/array-literal-multiple/expected.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
var a = [b].concat(c, [d, e], f);
|
||||
1
test/fixtures/transformation/es6-spread-loose/array-literals/actual.js
vendored
Normal file
1
test/fixtures/transformation/es6-spread-loose/array-literals/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var lyrics = ["head", "and", "toes", ...parts];
|
||||
3
test/fixtures/transformation/es6-spread-loose/array-literals/expected.js
vendored
Normal file
3
test/fixtures/transformation/es6-spread-loose/array-literals/expected.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
var lyrics = ["head", "and", "toes"].concat(parts);
|
||||
@@ -0,0 +1 @@
|
||||
obj[method](foo, bar, ...args);
|
||||
@@ -0,0 +1,4 @@
|
||||
"use strict";
|
||||
|
||||
var _obj;
|
||||
(_obj = obj)[method].apply(_obj, [foo, bar].concat(args));
|
||||
@@ -0,0 +1 @@
|
||||
obj[method](...args);
|
||||
@@ -0,0 +1,4 @@
|
||||
"use strict";
|
||||
|
||||
var _obj;
|
||||
(_obj = obj)[method].apply(_obj, args);
|
||||
2
test/fixtures/transformation/es6-spread-loose/contexted-method-call-multiple-args/actual.js
vendored
Normal file
2
test/fixtures/transformation/es6-spread-loose/contexted-method-call-multiple-args/actual.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
foob.add(foo, bar, ...numbers);
|
||||
foob.test.add(foo, bar, ...numbers);
|
||||
@@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
var _foob, _foob$test;
|
||||
(_foob = foob).add.apply(_foob, [foo, bar].concat(numbers));
|
||||
(_foob$test = foob.test).add.apply(_foob$test, [foo, bar].concat(numbers));
|
||||
2
test/fixtures/transformation/es6-spread-loose/contexted-method-call-single-arg/actual.js
vendored
Normal file
2
test/fixtures/transformation/es6-spread-loose/contexted-method-call-single-arg/actual.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
foob.add(...numbers);
|
||||
foob.test.add(...numbers);
|
||||
5
test/fixtures/transformation/es6-spread-loose/contexted-method-call-single-arg/expected.js
vendored
Normal file
5
test/fixtures/transformation/es6-spread-loose/contexted-method-call-single-arg/expected.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
var _foob, _foob$test;
|
||||
(_foob = foob).add.apply(_foob, numbers);
|
||||
(_foob$test = foob.test).add.apply(_foob$test, numbers);
|
||||
1
test/fixtures/transformation/es6-spread-loose/method-call-array-literal/actual.js
vendored
Normal file
1
test/fixtures/transformation/es6-spread-loose/method-call-array-literal/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
f(...[1, 2, 3]);
|
||||
3
test/fixtures/transformation/es6-spread-loose/method-call-array-literal/expected.js
vendored
Normal file
3
test/fixtures/transformation/es6-spread-loose/method-call-array-literal/expected.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
f.apply(undefined, [1, 2, 3]);
|
||||
1
test/fixtures/transformation/es6-spread-loose/method-call-first/actual.js
vendored
Normal file
1
test/fixtures/transformation/es6-spread-loose/method-call-first/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
add(...numbers, foo, bar);
|
||||
3
test/fixtures/transformation/es6-spread-loose/method-call-first/expected.js
vendored
Normal file
3
test/fixtures/transformation/es6-spread-loose/method-call-first/expected.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
add.apply(undefined, numbers.concat([foo, bar]));
|
||||
1
test/fixtures/transformation/es6-spread-loose/method-call-middle/actual.js
vendored
Normal file
1
test/fixtures/transformation/es6-spread-loose/method-call-middle/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
add(foo, ...numbers, bar);
|
||||
3
test/fixtures/transformation/es6-spread-loose/method-call-middle/expected.js
vendored
Normal file
3
test/fixtures/transformation/es6-spread-loose/method-call-middle/expected.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
add.apply(undefined, [foo].concat(numbers, [bar]));
|
||||
1
test/fixtures/transformation/es6-spread-loose/method-call-multiple-args/actual.js
vendored
Normal file
1
test/fixtures/transformation/es6-spread-loose/method-call-multiple-args/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
add(foo, bar, ...numbers);
|
||||
3
test/fixtures/transformation/es6-spread-loose/method-call-multiple-args/expected.js
vendored
Normal file
3
test/fixtures/transformation/es6-spread-loose/method-call-multiple-args/expected.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
add.apply(undefined, [foo, bar].concat(numbers));
|
||||
1
test/fixtures/transformation/es6-spread-loose/method-call-multiple/actual.js
vendored
Normal file
1
test/fixtures/transformation/es6-spread-loose/method-call-multiple/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
add(foo, ...numbers, bar, what, ...test);
|
||||
3
test/fixtures/transformation/es6-spread-loose/method-call-multiple/expected.js
vendored
Normal file
3
test/fixtures/transformation/es6-spread-loose/method-call-multiple/expected.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
add.apply(undefined, [foo].concat(numbers, [bar, what], test));
|
||||
1
test/fixtures/transformation/es6-spread-loose/method-call-single-arg/actual.js
vendored
Normal file
1
test/fixtures/transformation/es6-spread-loose/method-call-single-arg/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
add(...numbers);
|
||||
3
test/fixtures/transformation/es6-spread-loose/method-call-single-arg/expected.js
vendored
Normal file
3
test/fixtures/transformation/es6-spread-loose/method-call-single-arg/expected.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
add.apply(undefined, numbers);
|
||||
2
test/fixtures/transformation/es6-spread-loose/new-expression/actual.js
vendored
Normal file
2
test/fixtures/transformation/es6-spread-loose/new-expression/actual.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
new Numbers(...nums);
|
||||
new Numbers(1, ...nums);
|
||||
12
test/fixtures/transformation/es6-spread-loose/new-expression/expected.js
vendored
Normal file
12
test/fixtures/transformation/es6-spread-loose/new-expression/expected.js
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
var _applyConstructor = function (Constructor, args) {
|
||||
var instance = Object.create(Constructor.prototype);
|
||||
|
||||
var result = Constructor.apply(instance, args);
|
||||
|
||||
return result != null && (typeof result == "object" || typeof result == "function") ? result : instance;
|
||||
};
|
||||
|
||||
_applyConstructor(Numbers, nums);
|
||||
_applyConstructor(Numbers, [1].concat(nums));
|
||||
3
test/fixtures/transformation/es6-spread-loose/options.json
vendored
Normal file
3
test/fixtures/transformation/es6-spread-loose/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"loose": "spread"
|
||||
}
|
||||
1
test/fixtures/transformation/es6-spread-loose/single/actual.js
vendored
Normal file
1
test/fixtures/transformation/es6-spread-loose/single/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
[...foo];
|
||||
3
test/fixtures/transformation/es6-spread-loose/single/expected.js
vendored
Normal file
3
test/fixtures/transformation/es6-spread-loose/single/expected.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
[].concat(foo);
|
||||
5
test/fixtures/transformation/es7-array-comprehension-loose/arguments/actual.js
vendored
Normal file
5
test/fixtures/transformation/es7-array-comprehension-loose/arguments/actual.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
function add() {
|
||||
return [for (i of [1, 2, 3]) i * arguments[0]];
|
||||
}
|
||||
|
||||
add(5);
|
||||
17
test/fixtures/transformation/es7-array-comprehension-loose/arguments/expected.js
vendored
Normal file
17
test/fixtures/transformation/es7-array-comprehension-loose/arguments/expected.js
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
|
||||
function add() {
|
||||
var _arguments = arguments;
|
||||
return (function () {
|
||||
var _ref = [];
|
||||
|
||||
for (var _iterator = [1, 2, 3][Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
|
||||
var i = _step.value;
|
||||
_ref.push(i * _arguments[0]);
|
||||
}
|
||||
|
||||
return _ref;
|
||||
})();
|
||||
}
|
||||
|
||||
add(5);
|
||||
@@ -0,0 +1 @@
|
||||
var arr = [for (i of [1, 2, 3]) if (i > 1) i * i];
|
||||
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
|
||||
var arr = (function () {
|
||||
var _arr = [];
|
||||
|
||||
for (var _iterator = [1, 2, 3][Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
|
||||
var i = _step.value;
|
||||
if (i > 1) {
|
||||
_arr.push(i * i);
|
||||
}
|
||||
}
|
||||
|
||||
return _arr;
|
||||
})();
|
||||
1
test/fixtures/transformation/es7-array-comprehension-loose/array-expression-single/actual.js
vendored
Normal file
1
test/fixtures/transformation/es7-array-comprehension-loose/array-expression-single/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var arr = [for (i of [1, 2, 3]) i * i];
|
||||
12
test/fixtures/transformation/es7-array-comprehension-loose/array-expression-single/expected.js
vendored
Normal file
12
test/fixtures/transformation/es7-array-comprehension-loose/array-expression-single/expected.js
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
var arr = (function () {
|
||||
var _arr = [];
|
||||
|
||||
for (var _iterator = [1, 2, 3][Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
|
||||
var i = _step.value;
|
||||
_arr.push(i * i);
|
||||
}
|
||||
|
||||
return _arr;
|
||||
})();
|
||||
1
test/fixtures/transformation/es7-array-comprehension-loose/multiple-if/actual.js
vendored
Normal file
1
test/fixtures/transformation/es7-array-comprehension-loose/multiple-if/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var seattlers = [for (customers of countries) for (c of customers) if (c.city == "Seattle") { name: c.name, age: c.age }];
|
||||
17
test/fixtures/transformation/es7-array-comprehension-loose/multiple-if/expected.js
vendored
Normal file
17
test/fixtures/transformation/es7-array-comprehension-loose/multiple-if/expected.js
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
|
||||
var seattlers = (function () {
|
||||
var _seattlers = [];
|
||||
|
||||
for (var _iterator = countries[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
|
||||
var customers = _step.value;
|
||||
for (var _iterator2 = customers[Symbol.iterator](), _step2; !(_step2 = _iterator2.next()).done;) {
|
||||
var c = _step2.value;
|
||||
if (c.city == "Seattle") {
|
||||
_seattlers.push({ name: c.name, age: c.age });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return _seattlers;
|
||||
})();
|
||||
1
test/fixtures/transformation/es7-array-comprehension-loose/multiple/actual.js
vendored
Normal file
1
test/fixtures/transformation/es7-array-comprehension-loose/multiple/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var arr = [for (x of "abcdefgh".split("")) for (y of "12345678".split("")) x + y];
|
||||
15
test/fixtures/transformation/es7-array-comprehension-loose/multiple/expected.js
vendored
Normal file
15
test/fixtures/transformation/es7-array-comprehension-loose/multiple/expected.js
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
"use strict";
|
||||
|
||||
var arr = (function () {
|
||||
var _arr = [];
|
||||
|
||||
for (var _iterator = "abcdefgh".split("")[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
|
||||
var x = _step.value;
|
||||
for (var _iterator2 = "12345678".split("")[Symbol.iterator](), _step2; !(_step2 = _iterator2.next()).done;) {
|
||||
var y = _step2.value;
|
||||
_arr.push(x + y);
|
||||
}
|
||||
}
|
||||
|
||||
return _arr;
|
||||
})();
|
||||
4
test/fixtures/transformation/es7-array-comprehension-loose/options.json
vendored
Normal file
4
test/fixtures/transformation/es7-array-comprehension-loose/options.json
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"experimental": true,
|
||||
"loose": "arrayComprehension"
|
||||
}
|
||||
1
test/fixtures/transformation/es7-array-comprehension-loose/single-if/actual.js
vendored
Normal file
1
test/fixtures/transformation/es7-array-comprehension-loose/single-if/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var arr = [for (i of nums) if (i > 1) i * i];
|
||||
14
test/fixtures/transformation/es7-array-comprehension-loose/single-if/expected.js
vendored
Normal file
14
test/fixtures/transformation/es7-array-comprehension-loose/single-if/expected.js
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
|
||||
var arr = (function () {
|
||||
var _arr = [];
|
||||
|
||||
for (var _iterator = nums[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
|
||||
var i = _step.value;
|
||||
if (i > 1) {
|
||||
_arr.push(i * i);
|
||||
}
|
||||
}
|
||||
|
||||
return _arr;
|
||||
})();
|
||||
1
test/fixtures/transformation/es7-array-comprehension-loose/single/actual.js
vendored
Normal file
1
test/fixtures/transformation/es7-array-comprehension-loose/single/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var arr = [for (i of nums) i * i];
|
||||
12
test/fixtures/transformation/es7-array-comprehension-loose/single/expected.js
vendored
Normal file
12
test/fixtures/transformation/es7-array-comprehension-loose/single/expected.js
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
var arr = (function () {
|
||||
var _arr = [];
|
||||
|
||||
for (var _iterator = nums[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
|
||||
var i = _step.value;
|
||||
_arr.push(i * i);
|
||||
}
|
||||
|
||||
return _arr;
|
||||
})();
|
||||
5
test/fixtures/transformation/es7-array-comprehension-loose/this/actual.js
vendored
Normal file
5
test/fixtures/transformation/es7-array-comprehension-loose/this/actual.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
function add() {
|
||||
return [for (i of [1, 2, 3]) i * this.multiplier];
|
||||
}
|
||||
|
||||
add.call({ multiplier: 5 });
|
||||
17
test/fixtures/transformation/es7-array-comprehension-loose/this/expected.js
vendored
Normal file
17
test/fixtures/transformation/es7-array-comprehension-loose/this/expected.js
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
|
||||
function add() {
|
||||
var _this = this;
|
||||
return (function () {
|
||||
var _ref = [];
|
||||
|
||||
for (var _iterator = [1, 2, 3][Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
|
||||
var i = _step.value;
|
||||
_ref.push(i * _this.multiplier);
|
||||
}
|
||||
|
||||
return _ref;
|
||||
})();
|
||||
}
|
||||
|
||||
add.call({ multiplier: 5 });
|
||||
4
test/fixtures/transformation/es7-generator-comprehension-loose/options.json
vendored
Normal file
4
test/fixtures/transformation/es7-generator-comprehension-loose/options.json
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"experimental": true,
|
||||
"loose": "generatorComprehension"
|
||||
}
|
||||
6
test/fixtures/transformation/es7-generator-comprehension-loose/simple/exec.js
vendored
Normal file
6
test/fixtures/transformation/es7-generator-comprehension-loose/simple/exec.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
var nums = [1, 2, 3, 4, 5, 6];
|
||||
var multiples = (for (i of nums) if (i % 2) i * i);
|
||||
assert.equal(multiples.next().value, 1);
|
||||
assert.equal(multiples.next().value, 9);
|
||||
assert.equal(multiples.next().value, 25);
|
||||
assert.ok(multiples.next().done);
|
||||
Reference in New Issue
Block a user