diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2018-02-14 05:15:52 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-14 05:15:52 +0800 |
commit | 83d8aa8b12ab7dc1854e6dc145f0cd96bf7d5bc9 (patch) | |
tree | e146bd95ad2fe235e180b153b9b016a2f5096d3b /test | |
parent | 4f1c12b6fd3b452e5bc851f43b9136a3be70cbb3 (diff) | |
download | tracifyjs-83d8aa8b12ab7dc1854e6dc145f0cd96bf7d5bc9.tar.gz tracifyjs-83d8aa8b12ab7dc1854e6dc145f0cd96bf7d5bc9.zip |
fix `collapse_vars` within loops (#2915)
fixes #2914
Diffstat (limited to 'test')
-rw-r--r-- | test/compress/collapse_vars.js | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js index 2c7bbdeb..bcb9cb91 100644 --- a/test/compress/collapse_vars.js +++ b/test/compress/collapse_vars.js @@ -4546,3 +4546,76 @@ issue_2908: { } expect_stdout: "2" } + +issue_2914_1: { + options = { + collapse_vars: true, + } + input: { + function read(input) { + var i = 0; + var e = 0; + var t = 0; + while (e < 32) { + var n = input[i++]; + t |= (127 & n) << e; + if (0 === (128 & n)) + return t; + e += 7; + } + } + console.log(read([129])); + } + expect: { + function read(input) { + var i = 0; + var e = 0; + var t = 0; + while (e < 32) { + var n = input[i++]; + t |= (127 & n) << e; + if (0 === (128 & n)) + return t; + e += 7; + } + } + console.log(read([129])); + } + expect_stdout: "1" +} + +issue_2914_2: { + options = { + collapse_vars: true, + } + input: { + function read(input) { + var i = 0; + var e = 0; + var t = 0; + while (e < 32) { + var n = input[i++]; + t = (127 & n) << e; + if (0 === (128 & n)) + return t; + e += 7; + } + } + console.log(read([129])); + } + expect: { + function read(input) { + var i = 0; + var e = 0; + var t = 0; + while (e < 32) { + var n = input[i++]; + if (0 === (128 & n)) + return t = (127 & n) << e; + e += 7; + } + } + console.log(read([129])); + } + expect_stdout: "0" +} |