From 8f5d8a9563442860ff75efb74244ef6a5b45f827 Mon Sep 17 00:00:00 2001 From: alexlamsl Date: Thu, 14 Dec 2017 19:35:38 +0800 Subject: [PATCH] add test --- test/compress/functions.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/compress/functions.js b/test/compress/functions.js index 5065836d..7b5318c4 100644 --- a/test/compress/functions.js +++ b/test/compress/functions.js @@ -748,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); + console.log(sum); + var x, y, z; + } + expect_stdout: "465" +}