diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-12-13 04:52:54 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-13 04:52:54 +0800 |
commit | 04cc395c353ac622d8e737c9099387d69b851d64 (patch) | |
tree | b4c34f6ae443746713e524540d4cb15906d1cba4 /test/compress/collapse_vars.js | |
parent | e008dc1bde1455eaafe04061412b0b9524212d99 (diff) | |
download | tracifyjs-04cc395c353ac622d8e737c9099387d69b851d64.tar.gz tracifyjs-04cc395c353ac622d8e737c9099387d69b851d64.zip |
improve `collapse_vars` on side-effect-free replacements (#2583)
Diffstat (limited to 'test/compress/collapse_vars.js')
-rw-r--r-- | test/compress/collapse_vars.js | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js index 330667dd..58405801 100644 --- a/test/compress/collapse_vars.js +++ b/test/compress/collapse_vars.js @@ -3805,3 +3805,51 @@ may_throw: { } } } + +side_effect_free_replacement: { + options = { + collapse_vars: true, + inline: true, + side_effects: true, + unused: true, + } + input: { + var b; + (function(a) { + x(a); + })(b); + } + expect: { + var b; + x(b); + } +} + +recursive_function_replacement: { + rename = true + options = { + collapse_vars: true, + inline: true, + passes: 2, + reduce_funcs: true, + reduce_vars: true, + toplevel: true, + unused: true, + } + mangle = {} + input: { + function f(a) { + return x(g(a)); + } + function g(a) { + return y(f(a)); + } + console.log(f(c)); + } + expect: { + function f(n) { + return x(y(f(n))); + } + console.log(f(c)); + } +} |