diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2019-11-27 14:54:36 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-27 14:54:36 +0800 |
commit | e27493f3c2e637b8f3e9da4757e76959a8705cd9 (patch) | |
tree | 0187747dcd0ab70f1d7ba0aa62f4440149054238 /test | |
parent | 292d1de3636adb9ee8a2ec0e0bf27fc27d453825 (diff) | |
download | tracifyjs-e27493f3c2e637b8f3e9da4757e76959a8705cd9.tar.gz tracifyjs-e27493f3c2e637b8f3e9da4757e76959a8705cd9.zip |
fix corner case in `inline` (#3608)
Diffstat (limited to 'test')
-rw-r--r-- | test/compress/functions.js | 162 |
1 files changed, 162 insertions, 0 deletions
diff --git a/test/compress/functions.js b/test/compress/functions.js index 4f3139b1..8795afb1 100644 --- a/test/compress/functions.js +++ b/test/compress/functions.js @@ -3594,3 +3594,165 @@ inline_use_strict: { } expect_stdout: "foobar" } + +pr_3595_1: { + options = { + collapse_vars: false, + inline: true, + reduce_funcs: true, + reduce_vars: true, + toplevel: true, + unused: true, + } + input: { + var g = [ "PASS" ]; + function problem(arg) { + return g.indexOf(arg); + } + function unused(arg) { + return problem(arg); + } + function a(arg) { + return problem(arg); + } + function b(problem) { + return g[problem]; + } + function c(arg) { + return b(a(arg)); + } + console.log(c("PASS")); + } + expect: { + var g = [ "PASS" ]; + function problem(arg) { + return g.indexOf(arg); + } + console.log((arg = "PASS", function(problem) { + return g[problem]; + }(function(arg) { + return problem(arg); + }(arg)))); + var arg; + } + expect_stdout: "PASS" +} + +pr_3595_2: { + options = { + collapse_vars: true, + inline: true, + reduce_funcs: true, + reduce_vars: true, + toplevel: true, + unused: true, + } + input: { + var g = [ "PASS" ]; + function problem(arg) { + return g.indexOf(arg); + } + function unused(arg) { + return problem(arg); + } + function a(arg) { + return problem(arg); + } + function b(problem) { + return g[problem]; + } + function c(arg) { + return b(a(arg)); + } + console.log(c("PASS")); + } + expect: { + var g = [ "PASS" ]; + function problem(arg) { + return g.indexOf(arg); + } + console.log(function(problem) { + return g[problem]; + }(function(arg) { + return problem(arg); + }("PASS"))); + } + expect_stdout: "PASS" +} + +pr_3595_3: { + options = { + collapse_vars: true, + inline: true, + passes: 2, + reduce_funcs: true, + reduce_vars: true, + toplevel: true, + unused: true, + } + input: { + var g = [ "PASS" ]; + function problem(arg) { + return g.indexOf(arg); + } + function unused(arg) { + return problem(arg); + } + function a(arg) { + return problem(arg); + } + function b(problem) { + return g[problem]; + } + function c(arg) { + return b(a(arg)); + } + console.log(c("PASS")); + } + expect: { + var g = [ "PASS" ]; + console.log(function(problem) { + return g[problem]; + }(function(arg) { + return g.indexOf(arg); + }("PASS"))); + } + expect_stdout: "PASS" +} + +pr_3595_4: { + options = { + collapse_vars: true, + inline: true, + passes: 3, + reduce_funcs: true, + reduce_vars: true, + toplevel: true, + unused: true, + } + input: { + var g = [ "PASS" ]; + function problem(arg) { + return g.indexOf(arg); + } + function unused(arg) { + return problem(arg); + } + function a(arg) { + return problem(arg); + } + function b(problem) { + return g[problem]; + } + function c(arg) { + return b(a(arg)); + } + console.log(c("PASS")); + } + expect: { + var g = [ "PASS" ]; + console.log((problem = g.indexOf("PASS"), g[problem])); + var problem; + } + expect_stdout: "PASS" +} |