nicer exec test option
This commit is contained in:
parent
d412f46696
commit
0056b0fcd6
@ -19,6 +19,7 @@ transform.test = function (task, assert) {
|
||||
var actual = task.actual;
|
||||
var expect = task.expect;
|
||||
var opts = task.options;
|
||||
var exec = opts.exec;
|
||||
|
||||
opts.filename = actual.filename;
|
||||
|
||||
@ -28,14 +29,14 @@ transform.test = function (task, assert) {
|
||||
var actualAst = actualResult.ast;
|
||||
actualCode = recast.prettyPrint(actualAst).code;
|
||||
|
||||
if (task.options.exec) {
|
||||
if (exec) {
|
||||
var fn = new Function("assert", actualCode);
|
||||
fn(assert);
|
||||
}
|
||||
|
||||
var expectCode = expect.code.trim();
|
||||
|
||||
if (!task.options.exec || (task.options.exec && expectCode)) {
|
||||
if (!exec || (exec && expectCode)) {
|
||||
var expectAst = util.parse(expect, expectCode);
|
||||
var expectResult = recast.prettyPrint(expectAst);
|
||||
expectCode = expectResult.code;
|
||||
@ -60,7 +61,7 @@ transform.test = function (task, assert) {
|
||||
|
||||
transform._ensureTransformerNames = function (type, keys) {
|
||||
_.each(keys, function (key) {
|
||||
if (key[0] === "_" || !transform.transformers[key]) {
|
||||
if (key[0] === "_" || !_.has(transform.transformers, key)) {
|
||||
throw new ReferenceError("unknown transformer " + key + " specified in " + type);
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user