diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2021-02-19 00:26:57 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-19 08:26:57 +0800 |
commit | 5f60c1b830fec648974b3ea7cbd6f53a6bfd7c75 (patch) | |
tree | 4c9d12f39be736a2f000ce1e5d88a3af45bc6933 /test/compress | |
parent | 10de27ca3d2010f45a1fb86b2707fa82e73b36b2 (diff) | |
download | tracifyjs-5f60c1b830fec648974b3ea7cbd6f53a6bfd7c75.tar.gz tracifyjs-5f60c1b830fec648974b3ea7cbd6f53a6bfd7c75.zip |
fix corner cases in arrow functions & `rests` (#4667)
fixes #4666
Diffstat (limited to 'test/compress')
-rw-r--r-- | test/compress/arrows.js | 9 | ||||
-rw-r--r-- | test/compress/rests.js | 27 |
2 files changed, 36 insertions, 0 deletions
diff --git a/test/compress/arrows.js b/test/compress/arrows.js index fbb18b95..e7322b72 100644 --- a/test/compress/arrows.js +++ b/test/compress/arrows.js @@ -694,3 +694,12 @@ issue_4476: { expect_stdout: "foo bar" node_version: ">=4" } + +issue_4666: { + input: { + console.log((a => /[0-9]/.test(a))(42)); + } + expect_exact: "console.log((a=>/[0-9]/.test(a))(42));" + expect_stdout: "true" + node_version: ">=4" +} diff --git a/test/compress/rests.js b/test/compress/rests.js index 676b5e7f..bbbcc14b 100644 --- a/test/compress/rests.js +++ b/test/compress/rests.js @@ -757,3 +757,30 @@ issue_4644_2: { expect_stdout: "PASS 0 undefined" node_version: ">=6" } + +issue_4666: { + options = { + evaluate: true, + reduce_vars: true, + rests: true, + toplevel: true, + unsafe: true, + unused: true, + } + input: { + var a = 0, b = 0; + var o = ((...c) => a++ + c)(b); + for (var k in o) + b++; + console.log(a, b); + } + expect: { + var a = 0, b = 0; + var o = (c => +a + c)([ b ]); + for(var k in o) + b++; + console.log(1, b); + } + expect_stdout: "1 2" + node_version: ">=6" +} |