aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-06-23 15:56:28 +0100
committerGitHub <noreply@github.com>2021-06-23 22:56:28 +0800
commit7cbcd114402188d09267d3537894e611d2f13f9a (patch)
tree18fd635d0de6f6e78d77a64614965e1040ffa917 /test
parent980dbde171d47c36028355a4cbd4f6f0e7700976 (diff)
downloadtracifyjs-7cbcd114402188d09267d3537894e611d2f13f9a.tar.gz
tracifyjs-7cbcd114402188d09267d3537894e611d2f13f9a.zip
fix corner case in `dead_code` (#5031)
fixes #5030
Diffstat (limited to 'test')
-rw-r--r--test/compress/dead-code.js49
-rw-r--r--test/compress/default-values.js11
2 files changed, 56 insertions, 4 deletions
diff --git a/test/compress/dead-code.js b/test/compress/dead-code.js
index 4493deb0..ecf5ce4b 100644
--- a/test/compress/dead-code.js
+++ b/test/compress/dead-code.js
@@ -1103,6 +1103,21 @@ last_assign_finally: {
expect_stdout: "PASS"
}
+consecutive_assignments: {
+ options = {
+ dead_code: true,
+ }
+ input: {
+ while (a = void 0, a = "PASS", console.log(a));
+ var a;
+ }
+ expect: {
+ while (void 0, a = "PASS", console.log(a));
+ var a;
+ }
+ expect_stdout: "PASS"
+}
+
issue_3578: {
options = {
dead_code: true,
@@ -1584,3 +1599,37 @@ issue_4570: {
}
expect_stdout: "NaN"
}
+
+issue_5030: {
+ options = {
+ dead_code: true,
+ }
+ input: {
+ (function(a, b) {
+ a = function f() {
+ if (a)
+ if (b--)
+ setImmediate(f);
+ else
+ console.log("FAIL");
+ else
+ console.log("PASS");
+ }();
+ })(42, 1);
+ }
+ expect: {
+ (function(a, b) {
+ a = function f() {
+ if (a)
+ if (b--)
+ setImmediate(f);
+ else
+ console.log("FAIL");
+ else
+ console.log("PASS");
+ }();
+ })(42, 1);
+ }
+ expect_stdout: "PASS"
+ node_version: ">=0.12"
+}
diff --git a/test/compress/default-values.js b/test/compress/default-values.js
index d1637524..6406d4a2 100644
--- a/test/compress/default-values.js
+++ b/test/compress/default-values.js
@@ -422,7 +422,9 @@ inline_loop_1: {
inline_loop_2: {
options = {
inline: true,
+ sequences: true,
toplevel: true,
+ unused: true,
}
input: {
while (function(a = [ "PASS" ]) {
@@ -432,10 +434,11 @@ inline_loop_2: {
}());
}
expect: {
- while (a = [ "PASS" ], a = function f(b) {
- console.log(a[b]);
- }(0), void 0) ;
- var a;
+ while (a = [ "PASS" ],
+ b = void 0,
+ b = 0,
+ void (a = void console.log(a[b])));
+ var a, b;
}
expect_stdout: "PASS"
node_version: ">=6"