diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2018-02-03 07:58:43 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-03 07:58:43 +0800 |
commit | 7e13c0db4034d2c28e36473a3add915de1813844 (patch) | |
tree | 0788e4fc0c87cee3336701e59c39f19ea099e8da /test | |
parent | e6a2e9e4d08b73c327e95bcd4da923f9404788d0 (diff) | |
download | tracifyjs-7e13c0db4034d2c28e36473a3add915de1813844.tar.gz tracifyjs-7e13c0db4034d2c28e36473a3add915de1813844.zip |
handle `break` & `continue` in `collapse_vars` (#2875)
fixes #2873
Diffstat (limited to 'test')
-rw-r--r-- | test/compress/collapse_vars.js | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js index a2571c24..ad09edc3 100644 --- a/test/compress/collapse_vars.js +++ b/test/compress/collapse_vars.js @@ -4383,3 +4383,53 @@ cond_branch_switch: { } expect_stdout: "1" } + +issue_2873_1: { + options = { + collapse_vars: true, + } + input: { + var b = 1, c = 0; + do { + c++; + if (!--b) break; + c = 1 + c; + } while (0); + console.log(b, c); + } + expect: { + var b = 1, c = 0; + do { + c++; + if (!--b) break; + c = 1 + c; + } while (0); + console.log(b, c); + } + expect_stdout: "0 1" +} + +issue_2873_2: { + options = { + collapse_vars: true, + } + input: { + var b = 1, c = 0; + do { + c++; + if (!--b) continue; + c = 1 + c; + } while (0); + console.log(b, c); + } + expect: { + var b = 1, c = 0; + do { + c++; + if (!--b) continue; + c = 1 + c; + } while (0); + console.log(b, c); + } + expect_stdout: "0 1" +} |