diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-09-08 15:12:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-08 22:12:27 +0800 |
commit | d97672613d28632a038fa14eb35d8c19c748320d (patch) | |
tree | b08d7d9bbb165f782897102bfebe96c711593e73 /test | |
parent | 30761eede5a5f0970a5655a2288aca1734407a51 (diff) | |
download | tracifyjs-d97672613d28632a038fa14eb35d8c19c748320d.tar.gz tracifyjs-d97672613d28632a038fa14eb35d8c19c748320d.zip |
fix corner case in `reduce_vars` (#4095)
Diffstat (limited to 'test')
-rw-r--r-- | test/compress/reduce_vars.js | 111 |
1 files changed, 109 insertions, 2 deletions
diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js index 8ed827a7..34d358cb 100644 --- a/test/compress/reduce_vars.js +++ b/test/compress/reduce_vars.js @@ -1624,7 +1624,7 @@ defun_label: { expect_stdout: true } -double_reference: { +double_reference_1: { options = { reduce_funcs: true, reduce_vars: true, @@ -1640,6 +1640,32 @@ double_reference: { } expect: { function f() { + var g = function g() { + g(); + }; + g(); + } + } +} + +double_reference_2: { + options = { + functions: true, + passes: 2, + reduce_funcs: true, + reduce_vars: true, + unused: true, + } + input: { + function f() { + var g = function g() { + g(); + }; + g(); + } + } + expect: { + function f() { (function g() { g(); })(); @@ -1647,6 +1673,60 @@ double_reference: { } } +double_reference_3: { + options = { + reduce_funcs: true, + reduce_vars: true, + toplevel: true, + unused: true, + } + input: { + var x = function f() { + return f; + }; + function g() { + return x(); + } + console.log(g() === g()); + } + expect: { + var x = function f() { + return f; + }; + function g() { + return x(); + } + console.log(g() === g()); + } + expect_stdout: "true" +} + +double_reference_4: { + options = { + comparisons: true, + functions: true, + inline: true, + passes: 2, + reduce_funcs: true, + reduce_vars: true, + toplevel: true, + unused: true, + } + input: { + var x = function f() { + return f; + }; + function g() { + return x(); + } + console.log(g() === g()); + } + expect: { + console.log(true); + } + expect_stdout: "true" +} + iife_arguments_1: { options = { reduce_funcs: true, @@ -1686,8 +1766,35 @@ iife_arguments_2: { } expect: { (function() { - console.log(function f() { + var x = function f() { + return f; + }; + console.log(x() === arguments[0]); + })(); + } + expect_stdout: true +} + +iife_arguments_3: { + options = { + functions: true, + passes: 2, + reduce_funcs: true, + reduce_vars: true, + unused: true, + } + input: { + (function() { + var x = function f() { return f; + }; + console.log(x() === arguments[0]); + })(); + } + expect: { + (function() { + console.log(function x() { + return x; }() === arguments[0]); })(); } |