diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2018-03-06 00:45:58 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-06 00:45:58 +0800 |
commit | fe51a91395f3b0a6ab812f3f42746d39efd9e80c (patch) | |
tree | d8b2c380890eeb04d9acb1dbb5ffce863e701c7d /test/compress | |
parent | 951d87ca9471b2cbbd6b96200484beb421d1a335 (diff) | |
download | tracifyjs-fe51a91395f3b0a6ab812f3f42746d39efd9e80c.tar.gz tracifyjs-fe51a91395f3b0a6ab812f3f42746d39efd9e80c.zip |
handle negated constants correctly in `collapse_vars` (#2975)
fixes #2974
Diffstat (limited to 'test/compress')
-rw-r--r-- | test/compress/collapse_vars.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js index 97efc21b..8b0f033a 100644 --- a/test/compress/collapse_vars.js +++ b/test/compress/collapse_vars.js @@ -5207,3 +5207,39 @@ collapse_rhs_undefined: { } expect_stdout: "true true true" } + +issue_2974: { + options = { + booleans: true, + collapse_vars: true, + evaluate: true, + loops: true, + passes: 2, + pure_getters: "strict", + reduce_vars: true, + sequences: true, + side_effects: true, + unused: true, + } + input: { + var c = 0; + (function f(b) { + var a = 2; + do { + b && b[b]; + b && (b.null = -4); + c++; + } while (b.null && --a > 0); + })(true); + console.log(c); + } + expect: { + var c = 0; + (function(b) { + var a = 2; + for (; b.null = -4, c++, b.null && --a > 0;); + })(!0), + console.log(c); + } + expect_stdout: "1" +} |