avoid false positive in --reduce-test (#4648)

This commit is contained in:
Alex Lam S.L
2021-02-13 13:15:11 +00:00
committed by GitHub
parent 83197ffdb3
commit 94e8944f67
3 changed files with 53 additions and 12 deletions

View File

@@ -300,7 +300,7 @@ module.exports = function reduce_test(testcase, minify_options, reduce_options)
node.start._permute += step;
if (expr && (expr !== node.body || !has_loopcontrol(expr, node, parent))) {
CHANGED = true;
return to_statement(expr);
return to_statement_init(expr);
}
}
else if (node instanceof U.AST_ForEnumeration) {
@@ -322,7 +322,7 @@ module.exports = function reduce_test(testcase, minify_options, reduce_options)
node.start._permute += step;
if (expr) {
CHANGED = true;
return to_statement(expr);
return to_statement_init(expr);
}
}
else if (node instanceof U.AST_If) {
@@ -695,6 +695,13 @@ function to_statement(node) {
});
}
function to_statement_init(node) {
return node instanceof U.AST_Const || node instanceof U.AST_Let ? new U.AST_BlockStatement({
body: [ node ],
start: {},
}) : to_statement(node);;
}
function wrap_with_console_log(node) {
// wrap with console.log()
return new U.AST_Call({