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,25 +132,39 @@ function run_compress_tests() {
failures++; failures++;
failed_files[file] = 1; failed_files[file] = 1;
} }
else if (test.expect_warnings) { else {
U.AST_Node.warn_function = original_warn_function; // expect == output
var expected_warnings = make_code(test.expect_warnings, { try {
beautify: false, var reparsed_ast = U.parse(output);
quote_style: 2, // force double quote to match JSON } 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", {
warnings_emitted = warnings_emitted.map(function(input) {
return input.split(process.cwd() + path.sep).join("").split(path.sep).join("/");
});
var actual_warnings = JSON.stringify(warnings_emitted);
if (expected_warnings != actual_warnings) {
log("!!! failed\n---INPUT---\n{input}\n---EXPECTED WARNINGS---\n{expected_warnings}\n---ACTUAL WARNINGS---\n{actual_warnings}\n\n", {
input: input_code, input: input_code,
expected_warnings: expected_warnings, output: output,
actual_warnings: actual_warnings, error: ex.toString(),
}); });
failures++; failures++;
failed_files[file] = 1; 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,
quote_style: 2, // force double quote to match JSON
});
warnings_emitted = warnings_emitted.map(function(input) {
return input.split(process.cwd() + path.sep).join("").split(path.sep).join("/");
});
var actual_warnings = JSON.stringify(warnings_emitted);
if (expected_warnings != actual_warnings) {
log("!!! failed\n---INPUT---\n{input}\n---EXPECTED WARNINGS---\n{expected_warnings}\n---ACTUAL WARNINGS---\n{actual_warnings}\n\n", {
input: input_code,
expected_warnings: expected_warnings,
actual_warnings: actual_warnings,
});
failures++;
failed_files[file] = 1;
}
}
} }
} }
var tests = parse_test(path.resolve(dir, file)); var tests = parse_test(path.resolve(dir, file));