Test reparsing test/compress/*.js output

This commit is contained in:
kzc
2016-07-22 10:44:29 -04:00
committed by Richard van Velzen
parent 642273c290
commit 67cca43358

View File

@@ -132,7 +132,20 @@ function run_compress_tests() {
failures++;
failed_files[file] = 1;
}
else if (test.expect_warnings) {
else {
// expect == output
try {
var reparsed_ast = U.parse(output);
} catch (ex) {
log("!!! Test matched expected result but cannot parse output\n---INPUT---\n{input}\n---OUTPUT---\n{output}\n--REPARSE ERROR--\n{error}\n\n", {
input: input_code,
output: output,
error: ex.toString(),
});
failures++;
failed_files[file] = 1;
}
if (test.expect_warnings) {
U.AST_Node.warn_function = original_warn_function;
var expected_warnings = make_code(test.expect_warnings, {
beautify: false,
@@ -153,6 +166,7 @@ function run_compress_tests() {
}
}
}
}
var tests = parse_test(path.resolve(dir, file));
for (var i in tests) if (tests.hasOwnProperty(i)) {
test_case(tests[i]);