Merge pull request #2888 from amasad/plugin-regression

Introduce exec tests for plugin regressions
This commit is contained in:
Sebastian McKenzie 2015-11-06 19:38:04 -05:00
commit 64688dfe9c
3 changed files with 40 additions and 2 deletions

View File

@ -107,8 +107,8 @@ function run(task, done) {
}
};
var fn = new Function("require", "done", "exports", execCode);
fn.call(global, fakeRequire, chai.assert, {}, done);
var fn = new Function("require", "assert", "exports", "done", "transform", execCode);
fn.call(global, fakeRequire, chai.assert, {}, done, transform);
} catch (err) {
err.message = exec.loc + ": " + err.message;
err.message += codeFrame(execCode);

View File

@ -0,0 +1,37 @@
var code = `
(function() {
function foo(b){
b === "lol";
foo(b);
}
})();
`;
transform(code, {
plugins: [
function (b) {
var t = b.types;
return {
visitor: {
// Replace block statements with a new node without changing anything
BlockStatement: function(path) {
if (path.node.seen) {
return;
}
var node = t.blockStatement(path.node.body);
node.seen = true;
path.replaceWith(node);
},
// do type inference
BinaryExpression: function(path) {
var left = path.get("left");
var right = path.get("right");
left.baseTypeStrictlyMatches(right);
}
}
};
}
],
compact: true,
comments: false,
}).code;

View File

@ -0,0 +1 @@
require("./_transformation-helper").run("plugins");