diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-12-15 13:28:30 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-15 13:28:30 +0800 |
commit | 8f681b1d1721e931852be48720d26ba052eac96c (patch) | |
tree | fc0f3a94f03fe79107fa3db5f46bef4249ce89c1 /test/compress/functions.js | |
parent | 90313875f75f68fecfc23c6c6f96f921da730301 (diff) | |
download | tracifyjs-8f681b1d1721e931852be48720d26ba052eac96c.tar.gz tracifyjs-8f681b1d1721e931852be48720d26ba052eac96c.zip |
handle `inline` of function arguments (#2590)
fixes #2476
Diffstat (limited to 'test/compress/functions.js')
-rw-r--r-- | test/compress/functions.js | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/test/compress/functions.js b/test/compress/functions.js index c4281d5c..a36509af 100644 --- a/test/compress/functions.js +++ b/test/compress/functions.js @@ -578,11 +578,10 @@ issue_2531_1: { } expect: { function outer() { - return function(value) { - return function() { - return value; - }; - }("Hello"); + return value = "Hello", function() { + return value; + }; + var value; } console.log("Greeting:", outer()()); } @@ -593,9 +592,10 @@ issue_2531_2: { options = { evaluate: true, inline: true, - passes: 2, + passes: 3, reduce_funcs: true, reduce_vars: true, + side_effects: true, unused: true, } input: { @@ -627,9 +627,10 @@ issue_2531_3: { options = { evaluate: true, inline: true, - passes: 2, + passes: 3, reduce_funcs: true, reduce_vars: true, + side_effects: true, toplevel: true, unused: true, } @@ -747,3 +748,27 @@ inline_loop_4: { }; } } + +issue_2476: { + options = { + inline: true, + reduce_vars: true, + toplevel: true, + unused: true, + } + input: { + function foo(x, y, z) { + return x < y ? x * y + z : x * z - y; + } + for (var sum = 0, i = 0; i < 10; i++) + sum += foo(i, i + 1, 3 * i); + console.log(sum); + } + expect: { + for (var sum = 0, i = 0; i < 10; i++) + sum += (x = i, y = i + 1, z = 3 * i, x < y ? x * y + z : x * z - y); + var x, y, z; + console.log(sum); + } + expect_stdout: "465" +} |