aboutsummaryrefslogtreecommitdiff
path: root/test/reduce.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-12-24 09:02:18 +0000
committerGitHub <noreply@github.com>2020-12-24 17:02:18 +0800
commit18966945324786d29def134662221a068297161d (patch)
tree9cd23edc4262ff7ab0d8b32a9b315a9788abc56d /test/reduce.js
parent5f269cd57356fc4dbe7486dca22902d22695d499 (diff)
downloadtracifyjs-18966945324786d29def134662221a068297161d.tar.gz
tracifyjs-18966945324786d29def134662221a068297161d.zip
fix & enhance `collapse_vars` (#4447)
fixes #4446
Diffstat (limited to 'test/reduce.js')
-rw-r--r--test/reduce.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/reduce.js b/test/reduce.js
index d0797f8a..f6b54141 100644
--- a/test/reduce.js
+++ b/test/reduce.js
@@ -153,6 +153,20 @@ module.exports = function reduce_test(testcase, minify_options, reduce_options)
node.left,
node.right,
][ permute & 1 ];
+ if (expr instanceof U.AST_Destructured) expr = expr.transform(new U.TreeTransformer(function(node, descend) {
+ if (node instanceof U.AST_DefaultValue) return new U.AST_Assign({
+ operator: "=",
+ left: node.name.transform(this),
+ right: node.value,
+ start: {},
+ });
+ if (node instanceof U.AST_DestructuredKeyVal) return new U.AST_ObjectKeyVal(node);
+ if (node instanceof U.AST_Destructured) {
+ node = new (node instanceof U.AST_DestructuredArray ? U.AST_Array : U.AST_Object)(node);
+ descend(node, this);
+ }
+ return node;
+ }));
CHANGED = true;
return permute < 2 ? expr : wrap_with_console_log(expr);
}