diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2018-02-12 23:28:28 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-12 23:28:28 +0800 |
commit | 0809699bdc7b1c249c7bbe02924a4a861aff8bea (patch) | |
tree | cf442345213f3c85a659ae84db6f82575c3ba2e8 /test | |
parent | 2088e1c19d97955b5582e08396fca8c7b7dadd83 (diff) | |
download | tracifyjs-0809699bdc7b1c249c7bbe02924a4a861aff8bea.tar.gz tracifyjs-0809699bdc7b1c249c7bbe02924a4a861aff8bea.zip |
simplify `do-while` into `for` (#2907)
fixes #2904
Diffstat (limited to 'test')
-rw-r--r-- | test/compress/loops.js | 17 | ||||
-rw-r--r-- | test/compress/reduce_vars.js | 12 |
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;); } } |