aboutsummaryrefslogtreecommitdiff
path: root/test/compress
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-11-17 08:23:50 +0000
committerGitHub <noreply@github.com>2020-11-17 16:23:50 +0800
commit8a83c8dd46dc8e446cd7231116a06c8b217291b7 (patch)
treeb1f081551a1f9f488ac07d963ddbf41463dd50cd /test/compress
parent2a612fd472b4d26fee4342fb57fe9ec54ab124cb (diff)
downloadtracifyjs-8a83c8dd46dc8e446cd7231116a06c8b217291b7.tar.gz
tracifyjs-8a83c8dd46dc8e446cd7231116a06c8b217291b7.zip
fix corner cases in `collapse_vars` & `dead_code` (#4285)
fixes #4284
Diffstat (limited to 'test/compress')
-rw-r--r--test/compress/destructured.js62
1 files changed, 62 insertions, 0 deletions
diff --git a/test/compress/destructured.js b/test/compress/destructured.js
index 65429b92..1555e3e3 100644
--- a/test/compress/destructured.js
+++ b/test/compress/destructured.js
@@ -1341,3 +1341,65 @@ issue_4282: {
expect_stdout: true
node_version: ">=6"
}
+
+issue_4284_1: {
+ options = {
+ dead_code: true,
+ }
+ input: {
+ var a, {
+ 0: b,
+ } = a = "foo";
+ console.log(a, b);
+ }
+ expect: {
+ var a, {
+ 0: b,
+ } = a = "foo";
+ console.log(a, b);
+ }
+ expect_stdout: "foo f"
+ node_version: ">=6"
+}
+
+issue_4284_2: {
+ options = {
+ collapse_vars: true,
+ }
+ input: {
+ var a, {
+ [console.log(a)]: b,
+ } = (a = "PASS", 0);
+ var c = a;
+ }
+ expect: {
+ var a, {
+ [console.log(a)]: b,
+ } = (a = "PASS", 0);
+ var c = a;
+ }
+ expect_stdout: "PASS"
+ node_version: ">=6"
+}
+
+issue_4284_3: {
+ options = {
+ collapse_vars: true,
+ }
+ input: {
+ var a, b;
+ ({
+ [console.log(a)]: b,
+ } = (a = "PASS", 0));
+ var c = a;
+ }
+ expect: {
+ var a, b;
+ ({
+ [console.log(a)]: b,
+ } = (a = "PASS", 0));
+ var c = a;
+ }
+ expect_stdout: "PASS"
+ node_version: ">=6"
+}