move all plugin tests out of babel-core and into their appropriate folders

This commit is contained in:
Sebastian McKenzie
2015-11-08 23:04:10 -08:00
parent 5f40b53dee
commit 15969a0904
1189 changed files with 365 additions and 65 deletions

View File

@@ -10,5 +10,8 @@
],
"dependencies": {
"babel-runtime": "^5.0.0"
},
"devDependencies": {
"babel-helper-plugin-test-runner": "^6.0.0"
}
}

View File

@@ -0,0 +1,10 @@
var [a, b] = [1, 2];
var [[a, b]] = [[1, 2]];
var [a, b, ...c] = [1, 2, 3, 4];
var [[a, b, ...c]] = [[1, 2, 3, 4]];
var [a, b] = [1, 2, 3];
var [[a, b]] = [[1, 2, 3]];
var [a, b] = [a, b];
[a[0], a[1]] = [a[1], a[0]];
var [a, b] = [...foo, bar];

View File

@@ -0,0 +1,27 @@
var a = 1;
var b = 2;
var a = 1;
var b = 2;
var a = 1;
var b = 2;
var c = [3, 4];
var a = 1;
var b = 2;
var c = [3, 4];
var _ref = [1, 2, 3];
var a = _ref[0];
var b = _ref[1];
var _ref2 = [1, 2, 3];
var a = _ref2[0];
var b = _ref2[1];
var _ref3 = [a, b];
var a = _ref3[0];
var b = _ref3[1];
var _ref4 = [a[1], a[0]];
a[0] = _ref4[0];
a[1] = _ref4[1];
var _ref5 = [].concat(babelHelpers.toConsumableArray(foo), [bar]);
var a = _ref5[0];
var b = _ref5[1];

View File

@@ -0,0 +1,3 @@
var [a, [b], [c]] = ["hello", [", ", "junk"], ["world"]];
[a, [b], [c]] = ["hello", [", ", "junk"], ["world"]];
;

View File

@@ -0,0 +1,10 @@
var a = "hello";
var _ref = [", ", "junk"];
var b = _ref[0];
var c = "world";
a = "hello";
var _ref2 = [", ", "junk"];
b = _ref2[0];
c = "world";
;

View File

@@ -0,0 +1,5 @@
var x, y;
var _ref = [1, 2];
x = _ref[0];
y = _ref[1];
_ref;

View File

@@ -0,0 +1,2 @@
var z = {};
var { x: { y } = {} } = z;

View File

@@ -0,0 +1,4 @@
var z = {};
var _z$x = z.x;
_z$x = _z$x === undefined ? {} : _z$x;
var y = _z$x.y;

View File

@@ -0,0 +1 @@
console.log([x] = [123]);

View File

@@ -0,0 +1,3 @@
var _ref;
console.log((_ref = [123], x = _ref[0], _ref));

View File

@@ -0,0 +1,8 @@
var _f = f();
var _f2 = babelHelpers.slicedToArray(_f, 2);
a = _f2[0];
b = _f2[1];
;

View File

@@ -0,0 +1,6 @@
var a, b, c, d;
({ a, b } = { c, d } = { a: 1, b: 2, c: 3, d: 4});
assert.equal(a, 1);
assert.equal(b, 2);
assert.equal(c, 3);
assert.equal(d, 4);

View File

@@ -0,0 +1,17 @@
var f0 = function (a, b = a, c = b) {
return [a, b, c];
};
assert.deepEqual(f0(1), [1, 1, 1]);
var f1 = function ({a}, b = a, c = b) {
return [a, b, c];
};
assert.deepEqual(f1({a: 1}), [1, 1, 1]);
var f2 = function ({a}, b = a, c = a) {
return [a, b, c];
};
assert.deepEqual(f2({a: 1}), [1, 1, 1]);

View File

@@ -0,0 +1,17 @@
var f0 = function (a, b = a, c = b) {
return [a, b, c];
};
assert.deepEqual(f0(1), [1, 1, 1]);
var f1 = function ({a}, b = a, c = b) {
return [a, b, c];
};
assert.deepEqual(f1({a: 1}), [1, 1, 1]);
var f2 = function ({a}, b = a, c = a) {
return [a, b, c];
};
assert.deepEqual(f2({a: 1}), [1, 1, 1]);

View File

@@ -0,0 +1,28 @@
var f0 = function (a) {
var b = arguments.length <= 1 || arguments[1] === undefined ? a : arguments[1];
var c = arguments.length <= 2 || arguments[2] === undefined ? b : arguments[2];
return [a, b, c];
};
assert.deepEqual(f0(1), [1, 1, 1]);
var f1 = function (_ref) {
var a = _ref.a;
var b = arguments.length <= 1 || arguments[1] === undefined ? a : arguments[1];
var c = arguments.length <= 2 || arguments[2] === undefined ? b : arguments[2];
return [a, b, c];
};
assert.deepEqual(f1({ a: 1 }), [1, 1, 1]);
var f2 = function (_ref2) {
var a = _ref2.a;
var b = arguments.length <= 1 || arguments[1] === undefined ? a : arguments[1];
var c = arguments.length <= 2 || arguments[2] === undefined ? a : arguments[2];
return [a, b, c];
};
assert.deepEqual(f2({ a: 1 }), [1, 1, 1]);

View File

@@ -0,0 +1,3 @@
assert.throws(function () {
var {} = null;
}, /Cannot destructure undefined/);

View File

@@ -0,0 +1,2 @@
var _ref = null;
babelHelpers.objectDestructuringEmpty(_ref);

View File

@@ -0,0 +1 @@
var [, a, [b], [c], d] = ["foo", "hello", [", ", "junk"], ["world"]];

View File

@@ -0,0 +1,11 @@
var _ref = ["foo", "hello", [", ", "junk"], ["world"]];
var a = _ref[1];
var _ref$ = babelHelpers.slicedToArray(_ref[2], 1);
var b = _ref$[0];
var _ref$2 = babelHelpers.slicedToArray(_ref[3], 1);
var c = _ref$2[0];
var d = _ref[4];

View File

@@ -0,0 +1,5 @@
var z = {};
var { ...x } = z;
var { x, ...y } = z;
var { [x]: x, ...y } = z;
(function({ x, ...y }) { })

View File

@@ -0,0 +1,11 @@
var z = {};
var x = babelHelpers.objectWithoutProperties(z, []);
var x = z.x;
var y = babelHelpers.objectWithoutProperties(z, ["x"]);
var x = z[x];
var y = babelHelpers.objectWithoutProperties(z, [x]);
(function (_ref) {
var x = _ref.x;
var y = babelHelpers.objectWithoutProperties(_ref, ["x"]);
});

View File

@@ -0,0 +1,3 @@
for (var [name, value] in obj) {
print("Name: " + name + ", Value: " + value);
}

View File

@@ -0,0 +1,8 @@
for (var _ref in obj) {
var _ref2 = babelHelpers.slicedToArray(_ref, 2);
var name = _ref2[0];
var value = _ref2[1];
print("Name: " + name + ", Value: " + value);
}

View File

@@ -0,0 +1,3 @@
for (var [ name, before, after ] of test.expectation.registers) {
}

View File

@@ -0,0 +1,7 @@
for (var _ref of test.expectation.registers) {
var _ref2 = babelHelpers.slicedToArray(_ref, 3);
var name = _ref2[0];
var before = _ref2[1];
var after = _ref2[2];
}

View File

@@ -0,0 +1,2 @@
var z = [];
var [x, ...y] = z;

View File

@@ -0,0 +1,3 @@
var z = [];
var x = z[0];
var y = z.slice(1);

View File

@@ -0,0 +1,2 @@
[foo.foo, foo.bar] = [1, 2];
;

View File

@@ -0,0 +1,5 @@
var _ref = [1, 2];
foo.foo = _ref[0];
foo.bar = _ref[1];
;

View File

@@ -0,0 +1,2 @@
var rect = {};
var {topLeft: [x1, y1], bottomRight: [x2, y2] } = rect;

View File

@@ -0,0 +1,11 @@
var rect = {};
var _rect$topLeft = babelHelpers.slicedToArray(rect.topLeft, 2);
var x1 = _rect$topLeft[0];
var y1 = _rect$topLeft[1];
var _rect$bottomRight = babelHelpers.slicedToArray(rect.bottomRight, 2);
var x2 = _rect$bottomRight[0];
var y2 = _rect$bottomRight[1];

View File

@@ -0,0 +1,3 @@
var coords = [1, 2];
var { x, y } = coords,
foo = "bar";

View File

@@ -0,0 +1,4 @@
var coords = [1, 2];
var x = coords.x;
var y = coords.y;
var foo = "bar";

View File

@@ -0,0 +1,3 @@
var rect = {};
var {topLeft: {x: x1, y: y1}, bottomRight: {x: x2, y: y2}} = rect;
var { 3: foo, 5: bar } = [0, 1, 2, 3, 4, 5, 6];

View File

@@ -0,0 +1,10 @@
var rect = {};
var _rect$topLeft = rect.topLeft;
var x1 = _rect$topLeft.x;
var y1 = _rect$topLeft.y;
var _rect$bottomRight = rect.bottomRight;
var x2 = _rect$bottomRight.x;
var y2 = _rect$bottomRight.y;
var _ref = [0, 1, 2, 3, 4, 5, 6];
var foo = _ref[3];
var bar = _ref[5];

View File

@@ -0,0 +1,2 @@
var coords = [1, 2];
var { x, y } = coords;

View File

@@ -0,0 +1,3 @@
var coords = [1, 2];
var x = coords.x;
var y = coords.y;

View File

@@ -0,0 +1,3 @@
{
"plugins": ["external-helpers-2", "transform-es2015-destructuring", "transform-es2015-spread", "transform-es2015-parameters", "transform-es2015-block-scoping", "transform-object-rest-spread", "transform-regenerator"]
}

View File

@@ -0,0 +1,15 @@
function somethingAdvanced({topLeft: {x: x1, y: y1} = {}, bottomRight: {x: x2, y: y2} = {}}, p2, p3){
}
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]));

View File

@@ -0,0 +1,37 @@
function somethingAdvanced(_ref, p2, p3) {
var _ref$topLeft = _ref.topLeft;
_ref$topLeft = _ref$topLeft === undefined ? {} : _ref$topLeft;
var x1 = _ref$topLeft.x;
var y1 = _ref$topLeft.y;
var _ref$bottomRight = _ref.bottomRight;
_ref$bottomRight = _ref$bottomRight === undefined ? {} : _ref$bottomRight;
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 _ref6 = babelHelpers.slicedToArray(_ref3, 3);
var a = _ref6[0];
var b = _ref6[1];
var c = _ref6[2];
var _ref5 = babelHelpers.slicedToArray(_ref4, 3);
var x = _ref5[0];
var y = _ref5[1];
var z = _ref5[2];
return a + b + c;
};
console.log(unpackArray(["hello", ", ", "world"], [1, 2, 3]));

View File

@@ -0,0 +1,7 @@
function* f() {
for (var i = 0; i < 3; i++) {
yield i;
}
}
var [...xs] = f();
assert.deepEqual(xs, [0, 1, 2]);

View File

@@ -0,0 +1,5 @@
function isSorted([x, y, ...wow]) {
if (!zs.length) return true
if (y > x) return isSorted(zs)
return false
}

View File

@@ -0,0 +1,12 @@
function isSorted(_ref) {
var _ref2 = babelHelpers.toArray(_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;
}

View File

@@ -0,0 +1 @@
require("babel-helper-plugin-test-runner")(__dirname);