diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2021-01-12 04:07:01 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-12 12:07:01 +0800 |
commit | b689028e874e35f529b2cc1df906f70d500f6085 (patch) | |
tree | 2e8034725011bc35d21038b1ea8728fcd03d47f2 /test/compress | |
parent | 1e831df1f6a39ccc043384f04863aea58dbd7d9c (diff) | |
download | tracifyjs-b689028e874e35f529b2cc1df906f70d500f6085.tar.gz tracifyjs-b689028e874e35f529b2cc1df906f70d500f6085.zip |
fix corner case in `unsafe_math` (#4543)
fixes #4542
Diffstat (limited to 'test/compress')
-rw-r--r-- | test/compress/numbers.js | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/test/compress/numbers.js b/test/compress/numbers.js index 7a9a3a7c..5a7000cd 100644 --- a/test/compress/numbers.js +++ b/test/compress/numbers.js @@ -1386,3 +1386,75 @@ issue_4142: { } expect_stdout: "0" } + +issue_4542_1: { + options = { + evaluate: true, + unsafe_math: true, + } + input: { + console.log(function(a) { + return a / (1 / (a[0] = 2)); + }([ 3 ])); + } + expect: { + console.log(function(a) { + return a / (1 / (a[0] = 2)); + }([ 3 ])); + } + expect_stdout: "4" +} + +issue_4542_2: { + options = { + evaluate: true, + unsafe_math: true, + } + input: { + console.log(function(a) { + return a / (1 / --a[0]); + }([ 3 ])); + } + expect: { + console.log(function(a) { + return a / (1 / --a[0]); + }([ 3 ])); + } + expect_stdout: "4" +} + +issue_4542_3: { + options = { + evaluate: true, + unsafe_math: true, + } + input: { + console.log(function(a) { + return a / (0 / (a[0] = 0, 1)); + }([ 1 ])); + } + expect: { + console.log(function(a) { + return a / (0 / (a[0] = 0, 1)); + }([ 1 ])); + } + expect_stdout: "NaN" +} + +issue_4542_4: { + options = { + evaluate: true, + unsafe_math: true, + } + input: { + console.log(function(a) { + return a / (1 / (a.length = 1)); + }([ 2, 3 ])); + } + expect: { + console.log(function(a) { + return a / (1 / (a.length = 1)); + }([ 2, 3 ])); + } + expect_stdout: "2" +} |