aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2018-02-12 23:28:28 +0800
committerGitHub <noreply@github.com>2018-02-12 23:28:28 +0800
commit0809699bdc7b1c249c7bbe02924a4a861aff8bea (patch)
treecf442345213f3c85a659ae84db6f82575c3ba2e8 /test
parent2088e1c19d97955b5582e08396fca8c7b7dadd83 (diff)
downloadtracifyjs-0809699bdc7b1c249c7bbe02924a4a861aff8bea.tar.gz
tracifyjs-0809699bdc7b1c249c7bbe02924a4a861aff8bea.zip
simplify `do-while` into `for` (#2907)
fixes #2904
Diffstat (limited to 'test')
-rw-r--r--test/compress/loops.js17
-rw-r--r--test/compress/reduce_vars.js12
2 files changed, 20 insertions, 9 deletions
diff --git a/test/compress/loops.js b/test/compress/loops.js
index a6ebd359..625b552d 100644
--- a/test/compress/loops.js
+++ b/test/compress/loops.js
@@ -605,3 +605,20 @@ issue_2740_5: {
}
expect_stdout: "0 undefined"
}
+
+issue_2904: {
+ options = {
+ join_vars: true,
+ loops: true,
+ }
+ input: {
+ var a = 1;
+ do {
+ console.log(a);
+ } while (--a);
+ }
+ expect: {
+ for (var a = 1; console.log(a), --a;);
+ }
+ expect_stdout: "1"
+}
diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js
index c0148204..f916e54b 100644
--- a/test/compress/reduce_vars.js
+++ b/test/compress/reduce_vars.js
@@ -1178,9 +1178,7 @@ toplevel_on_loops_1: {
console.log("bar:", --x);
}
var x = 3;
- do
- bar();
- while (x);
+ for (;bar(), x;);
}
expect_stdout: true
}
@@ -1208,9 +1206,7 @@ toplevel_off_loops_1: {
console.log("bar:", --x);
}
var x = 3;
- do
- bar();
- while (x);
+ for (;bar(), x;);
}
expect_stdout: true
}
@@ -1265,9 +1261,7 @@ toplevel_off_loops_2: {
console.log("bar:");
}
var x = 3;
- do
- bar();
- while (x);
+ for (;bar(), x;);
}
}