diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-02-06 21:20:05 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-06 21:20:05 +0000 |
commit | 470a7d4df186dd263d22eb1bd7c2ef220e142d16 (patch) | |
tree | 52279ccba6dafadfce02b3249a6edc178f51476f /test | |
parent | 551420132c357467a747cae12be39c2662ce56f1 (diff) | |
download | tracifyjs-470a7d4df186dd263d22eb1bd7c2ef220e142d16.tar.gz tracifyjs-470a7d4df186dd263d22eb1bd7c2ef220e142d16.zip |
improve reduction of `AST_BlockStatement` (#3708)
Diffstat (limited to 'test')
-rw-r--r-- | test/reduce.js | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/test/reduce.js b/test/reduce.js index 6b5f9114..40e57de9 100644 --- a/test/reduce.js +++ b/test/reduce.js @@ -116,10 +116,10 @@ module.exports = function reduce_test(testcase, minify_options, reduce_options) ][ ((node.start._permute += step) * steps | 0) % 3 ]; } else if (node instanceof U.AST_BlockStatement) { - if (node.body.length === 1) { + if (in_list) { node.start._permute++; CHANGED = true; - return node.body[0]; // each child is an AST_Statement + return List.splice(node.body); } } else if (node instanceof U.AST_Call) { @@ -274,19 +274,12 @@ module.exports = function reduce_test(testcase, minify_options, reduce_options) // replace or skip statement if (node instanceof U.AST_Statement) { - if (node instanceof U.AST_BlockStatement - && ( parent instanceof U.AST_IterationStatement - || parent instanceof U.AST_Switch)) { - // don't drop the block of a switch or loop - return; - } - if (node instanceof U.AST_LabeledStatement) { - if (node.body instanceof U.AST_Statement) { - // replace labelled statement with its non-labelled body - node.start._permute = REPLACEMENTS.length; - CHANGED = true; - return node.body; - } + if (node instanceof U.AST_LabeledStatement + && node.body instanceof U.AST_Statement) { + // replace labelled statement with its non-labelled body + node.start._permute = REPLACEMENTS.length; + CHANGED = true; + return node.body; } node.start._permute++; CHANGED = true; |