aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-04-19 23:37:46 +0100
committerGitHub <noreply@github.com>2020-04-20 06:37:46 +0800
commit88504ab86995b33b1c497e44ef314ab54fd57355 (patch)
tree9de9c280e40dbfa910497d904ddfd685b53896b1 /test
parente38754e8021c46b08595a4c71f26d20b2d538409 (diff)
downloadtracifyjs-88504ab86995b33b1c497e44ef314ab54fd57355.tar.gz
tracifyjs-88504ab86995b33b1c497e44ef314ab54fd57355.zip
enhance `join_vars` (#3804)
Diffstat (limited to 'test')
-rw-r--r--test/compress/issue-1639.js3
-rw-r--r--test/compress/join_vars.js81
2 files changed, 82 insertions, 2 deletions
diff --git a/test/compress/issue-1639.js b/test/compress/issue-1639.js
index 6633eb2d..4bf74f33 100644
--- a/test/compress/issue-1639.js
+++ b/test/compress/issue-1639.js
@@ -22,8 +22,7 @@ issue_1639_1: {
console.log(a, b);
}
expect: {
- for (var a = 100, b = 10, L1 = 5; --L1 > 0;) {
- var ignore;
+ for (var a = 100, b = 10, L1 = 5, ignore; --L1 > 0;) {
--b;
}
console.log(a, b);
diff --git a/test/compress/join_vars.js b/test/compress/join_vars.js
index 4e8d3b51..078ba351 100644
--- a/test/compress/join_vars.js
+++ b/test/compress/join_vars.js
@@ -815,3 +815,84 @@ issue_3795: {
}
expect_stdout: "PASS"
}
+
+if_body: {
+ options = {
+ join_vars: true,
+ }
+ input: {
+ var a;
+ if (x)
+ var b;
+ else
+ var c;
+ }
+ expect: {
+ var a, b, c;
+ if (x);
+ else;
+ }
+}
+
+if_switch: {
+ options = {
+ join_vars: true,
+ }
+ input: {
+ var a;
+ if (x) switch (y) {
+ case 1:
+ var b;
+ default:
+ var c;
+ }
+ }
+ expect: {
+ var a, b, c;
+ if (x) switch (y) {
+ case 1:
+ default:
+ }
+ }
+}
+
+loop_body_1: {
+ options = {
+ join_vars: true,
+ }
+ input: {
+ var a;
+ for (;x;)
+ var b;
+ }
+ expect: {
+ for (var a, b; x;);
+ }
+}
+
+loop_body_2: {
+ options = {
+ join_vars: true,
+ }
+ input: {
+ for (var a; x;)
+ var b;
+ }
+ expect: {
+ for (var a, b; x;);
+ }
+}
+
+loop_body_3: {
+ options = {
+ join_vars: true,
+ }
+ input: {
+ var a;
+ for (var b; x;)
+ var c;
+ }
+ expect: {
+ for (var a, b, c; x;);
+ }
+}