diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-06-17 14:32:37 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-17 14:32:37 +0800 |
commit | 0a0f4f55912fed32b09c93a2a1efa19edce24e28 (patch) | |
tree | 5b8cac3c39a92a66c12232f87932b6b20b2ba51b /test/compress/functions.js | |
parent | 931daa85bf72f6799dca83c1e1ac9b339d85b70b (diff) | |
download | tracifyjs-0a0f4f55912fed32b09c93a2a1efa19edce24e28.tar.gz tracifyjs-0a0f4f55912fed32b09c93a2a1efa19edce24e28.zip |
make defensive copies when `inline` (#2116)
fixes #2114
Diffstat (limited to 'test/compress/functions.js')
-rw-r--r-- | test/compress/functions.js | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/test/compress/functions.js b/test/compress/functions.js index dc430d18..d2640bb9 100644 --- a/test/compress/functions.js +++ b/test/compress/functions.js @@ -443,3 +443,70 @@ issue_2107: { } expect_stdout: "5" } + +issue_2114_1: { + options = { + collapse_vars: true, + if_return: true, + inline: true, + keep_fargs: false, + side_effects: true, + unused: true, + } + input: { + var c = 0; + !function(a) { + a = 0; + }([ { + 0: c = c + 1, + length: c = 1 + c + }, typeof void function a() { + var b = function f1(a) { + }(b && (b.b += (c = c + 1, 0))); + }() ]); + console.log(c); + } + expect: { + var c = 0; + !function() { + 0; + }((c += 1, c = 1 + c, function() { + var b = void (b && (b.b += (c += 1, 0))); + }())); + console.log(c); + } + expect_stdout: "2" +} + +issue_2114_2: { + options = { + collapse_vars: true, + if_return: true, + inline: true, + keep_fargs: false, + passes: 2, + side_effects: true, + unused: true, + } + input: { + var c = 0; + !function(a) { + a = 0; + }([ { + 0: c = c + 1, + length: c = 1 + c + }, typeof void function a() { + var b = function f1(a) { + }(b && (b.b += (c = c + 1, 0))); + }() ]); + console.log(c); + } + expect: { + var c = 0; + c = 1 + (c += 1), function() { + var b = void (b && (b.b += (c += 1, 0))); + }(); + console.log(c); + } + expect_stdout: "2" +} |