diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-09-17 14:20:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-17 21:20:31 +0800 |
commit | 09d93cc6c80a934daae53dea6a13d96924a0f466 (patch) | |
tree | 9d571605c2b4c743658e11c779767f3d29768040 /test/compress | |
parent | dd1374aa8adc0a0fc9fec8e173d424e8e1d17041 (diff) | |
download | tracifyjs-09d93cc6c80a934daae53dea6a13d96924a0f466.tar.gz tracifyjs-09d93cc6c80a934daae53dea6a13d96924a0f466.zip |
fix corner case in `evaluate` (#4120)
fixes #4119
Diffstat (limited to 'test/compress')
-rw-r--r-- | test/compress/evaluate.js | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/test/compress/evaluate.js b/test/compress/evaluate.js index 6d4d084d..5cf3fb1c 100644 --- a/test/compress/evaluate.js +++ b/test/compress/evaluate.js @@ -2908,3 +2908,55 @@ issue_4077: { } expect_stdout: "PASS" } + +issue_4119_1: { + options = { + conditionals: true, + dead_code: true, + evaluate: true, + reduce_vars: true, + toplevel: true, + unsafe: true, + } + input: { + var a, b; + b = a = []; + a[0] += 0; + if (+b + 1) { + console.log("FAIL"); + } else { + console.log("PASS"); + } + } + expect: { + var a, b; + b = a = []; + a[0] += 0; + +b + 1 ? console.log("FAIL") : console.log("PASS"); + } + expect_stdout: "PASS" +} + +issue_4119_2: { + options = { + conditionals: true, + evaluate: true, + reduce_vars: true, + unsafe: true, + } + input: { + var a; + (function(b) { + a[0] += 0; + console.log(+b + 1 ? "FAIL" : "PASS"); + })(a = []); + } + expect: { + var a; + (function(b) { + a[0] += 0; + console.log(+b + 1 ? "FAIL" : "PASS"); + })(a = []); + } + expect_stdout: "PASS" +} |