Test runner: Detect extra property in 'actual' but not in 'expected'. (#407)

* Test runner: Detect extra property in 'actual' but not in 'expected'.

Also update all expected.json where this would result in errors.

* Include rmExpected.js script in case it is needed again
This commit is contained in:
Andy
2017-03-19 14:03:11 -07:00
committed by Daniel Tschinder
parent 82b7872cb8
commit 0545173f66
1379 changed files with 12566 additions and 11513 deletions

View File

@@ -49,9 +49,6 @@ exports.runThrowTestsWithEstree = function runThrowTestsWithEstree(fixturesPath,
};
function save(test, ast) {
delete ast.tokens;
if (ast.comments && !ast.comments.length) delete ast.comments;
// Ensure that RegExp are serialized as strings
const toJSON = RegExp.prototype.toJSON;
RegExp.prototype.toJSON = RegExp.prototype.toString;
@@ -81,6 +78,9 @@ function runTest(test, parseFunction) {
throw err;
}
delete ast.tokens;
if (ast.comments && !ast.comments.length) delete ast.comments;
if (!test.expect.code && !opts.throws && !process.env.CI) {
test.expect.loc += "on";
return save(test, ast);
@@ -129,5 +129,15 @@ function misMatch(exp, act) {
var mis = misMatch(exp[prop], act[prop]);
if (mis) return addPath(mis, prop);
}
for (var prop in act) {
if (prop === "__clone") {
continue;
}
if (!(prop in exp) && act[prop] !== undefined) {
return `Did not expect a property '${prop}'`;
}
}
}
}