Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
danez committed Mar 18, 2017
1 parent 5f075a9 commit c3c2823
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 5 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
"through": "^2.3.8"
},
"devDependencies": {
"babel-plugin-transform-es2015-parameters": "^6.23.0",
"babel-plugin-transform-es2015-spread": "^6.22.0",
"babylon": "^6.14.1",
"mocha": "^2.3.4",
"promise": "^7.0.4",
Expand Down
25 changes: 25 additions & 0 deletions test/regression.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Copyright (c) 2017, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* https://raw.github.com/facebook/regenerator/master/LICENSE file. An
* additional grant of patent rights can be found in the PATENTS file in
* the same directory.
*/

var assert = require("assert");

describe("regressions", function() {
it("should correctly hoist arguments", async function () {
function test(fn) {
return async (...args) => {
return fn(...args);
};
}
const result = [];
await test((arg1, arg2) => { result.push(arg1, arg2); })(1, "foo");

assert.deepEqual(result, [1, "foo"]);
});
});
39 changes: 34 additions & 5 deletions test/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,31 @@ enqueue(convert, [
"./test/async.es5.js"
]);

function convertWithSpread(es6File, es5File, callback) {
var transformOptions = {
presets:[require("regenerator-preset")],
plugins: [
require("babel-plugin-transform-es2015-spread"),
require("babel-plugin-transform-es2015-parameters")
]
};

fs.readFile(es6File, "utf-8", function(err, es6) {
if (err) {
return callback(err);
}

var es5 = require("babel-core").transform(es6, transformOptions).code;

fs.writeFile(es5File, es5, callback);
});
}

enqueue(convertWithSpread, [
"./test/regression.js",
"./test/regression.es5.js"
]);

enqueue(makeMochaCopyFunction("mocha.js"));
enqueue(makeMochaCopyFunction("mocha.css"));

Expand All @@ -137,11 +162,14 @@ if (!semver.eq(process.version, "0.11.7")) {
try {
require.resolve("browserify"); // Throws if missing.
enqueue(bundle, [
["./test/runtime.js",
"./test/tests.es5.js",
"./test/tests-node4.es5.js",
"./test/non-native.es5.js",
"./test/async.es5.js"],
[
"./test/runtime.js",
"./test/tests.es5.js",
"./test/tests-node4.es5.js",
"./test/non-native.es5.js",
"./test/async.es5.js",
"./test/regression.es5.js"
],
"./test/tests.browser.js"
]);
} catch (ignored) {
Expand All @@ -156,6 +184,7 @@ enqueue("mocha", [
"./test/tests-node4.es5.js",
"./test/non-native.es5.js",
"./test/async.es5.js",
"./test/regression.es5.js",
"./test/tests.transform.js"
]);

Expand Down

0 comments on commit c3c2823

Please sign in to comment.