diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-12-31 16:15:00 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-31 16:15:00 +0800 |
commit | 333792352e2d0108622c318e9e3a4ee96ceb3346 (patch) | |
tree | fc6da3d45068f50c6cc354e0e6c0a1217636282d /test/compress | |
parent | e2ec270b04ddefc1c7aa39ab1eb24f2cae0077a8 (diff) | |
download | tracifyjs-333792352e2d0108622c318e9e3a4ee96ceb3346.tar.gz tracifyjs-333792352e2d0108622c318e9e3a4ee96ceb3346.zip |
reduce hoisting declarations (#2687)
Diffstat (limited to 'test/compress')
-rw-r--r-- | test/compress/reduce_vars.js | 51 |
1 files changed, 49 insertions, 2 deletions
diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js index 6f302ecd..058e9dde 100644 --- a/test/compress/reduce_vars.js +++ b/test/compress/reduce_vars.js @@ -2312,8 +2312,7 @@ delay_def: { } expect: { function f() { - return a; - var a; + return; } function g() { return a; @@ -2324,6 +2323,28 @@ delay_def: { expect_stdout: true } +delay_def_lhs: { + options = { + evaluate: true, + reduce_vars: true, + } + input: { + console.log(function() { + long_name++; + return long_name; + var long_name; + }()); + } + expect: { + console.log(function() { + long_name++; + return long_name; + var long_name; + }()); + } + expect_stdout: "NaN" +} + booleans: { options = { booleans: true, @@ -4952,3 +4973,29 @@ issue_2598: { } expect_stdout: "true" } + +var_if: { + options = { + evaluate: true, + reduce_vars: true, + unused: true, + } + input: { + function f() { + if (x()) { + var a; + if (!g) a = true; + if (a) g(); + } + } + } + expect: { + function f() { + if (x()) { + var a; + if (!g) a = true; + if (a) g(); + } + } + } +} |