diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-04-19 04:49:09 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-19 04:49:09 +0800 |
commit | 4dcff038cb1a6951a0b20d1345bfdb27d756301c (patch) | |
tree | 67cc31594a81154843526af836266ce367d3388f /test | |
parent | b4b9305db0d3c4682848ed0a4214f1fee332a078 (diff) | |
download | tracifyjs-4dcff038cb1a6951a0b20d1345bfdb27d756301c.tar.gz tracifyjs-4dcff038cb1a6951a0b20d1345bfdb27d756301c.zip |
improve `collapse_vars` on `AST_Var` (#1828)
Perform the same cascaded scanning within `var` statement as we do on array of statements.
Diffstat (limited to 'test')
-rw-r--r-- | test/compress/collapse_vars.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js index 0f82b743..94515a6f 100644 --- a/test/compress/collapse_vars.js +++ b/test/compress/collapse_vars.js @@ -1654,3 +1654,26 @@ iife_2: { }(bar()); } } + +var_defs: { + options = { + collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true, + comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true, + keep_fargs:true, if_return:true, join_vars:true, cascade:true, side_effects:true + } + input: { + var f1 = function(x, y) { + var a, b, r = x + y, q = r * r, z = q - r, a = z, b = 7; + console.log(a + b); + }; + f1("1", 0); + } + expect: { + var f1 = function(x, y) { + var r = x + y, a = r * r - r, b = 7; + console.log(a + b); + }; + f1("1", 0); + } + expect_stdout: "97" +} |