diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/compress/collapse_vars.js | 30 | ||||
-rw-r--r-- | test/compress/reduce_vars.js | 32 |
2 files changed, 62 insertions, 0 deletions
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js index 950ebd07..c915041f 100644 --- a/test/compress/collapse_vars.js +++ b/test/compress/collapse_vars.js @@ -4056,6 +4056,36 @@ replace_all_var: { expect_stdout: "PASS" } +replace_all_var_scope: { + rename = true; + options = { + collapse_vars: true, + unused: true, + } + mangle = {} + input: { + var a = 100, b = 10; + (function(r, a) { + switch (~a) { + case (b += a): + case a++: + } + })(--b, a); + console.log(a, b); + } + expect: { + var a = 100, b = 10; + (function(c, o) { + switch (~a) { + case (b += a): + case o++: + } + })(--b, a); + console.log(a, b); + } + expect_stdout: "100 109" +} + cascade_statement: { options = { collapse_vars: true, diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js index 1d6d1896..14b6a46f 100644 --- a/test/compress/reduce_vars.js +++ b/test/compress/reduce_vars.js @@ -5998,3 +5998,35 @@ issue_3113_5: { "1", ] } + +conditional_nested: { + options = { + evaluate: true, + reduce_vars: true, + } + input: { + var a = 1, b = 0; + (function f(c) { + function g() { + c && (c.a = 0); + c && (c.a = 0); + c && (c[b++] *= 0); + } + g(a-- && f(g(c = 42))); + })(); + console.log(b); + } + expect: { + var a = 1, b = 0; + (function f(c) { + function g() { + c && (c.a = 0); + c && (c.a = 0); + c && (c[b++] *= 0); + } + g(a-- && f(g(c = 42))); + })(); + console.log(b); + } + expect_stdout: "2" +} |