aboutsummaryrefslogtreecommitdiff
path: root/test/compress
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-01-15 04:05:58 +0800
committerGitHub <noreply@github.com>2020-01-15 04:05:58 +0800
commit91d87ae6633ba66706df32e8b955061c0e9d788f (patch)
treef180984236d5e40d16a5af8ed5b9c9f9aed9b30d /test/compress
parent5beb7e4797097d2b35d45a4fec7c08f91eef615b (diff)
downloadtracifyjs-91d87ae6633ba66706df32e8b955061c0e9d788f.tar.gz
tracifyjs-91d87ae6633ba66706df32e8b955061c0e9d788f.zip
fix corner case in `unsafe_math` (#3683)
fixes #3682
Diffstat (limited to 'test/compress')
-rw-r--r--test/compress/numbers.js52
1 files changed, 50 insertions, 2 deletions
diff --git a/test/compress/numbers.js b/test/compress/numbers.js
index c40ca09d..fdfb6c2f 100644
--- a/test/compress/numbers.js
+++ b/test/compress/numbers.js
@@ -1075,11 +1075,11 @@ issue_3653: {
}
expect: {
console.log(0 - (console && 0));
- console.log(0 - (console && 0) + 0);
+ console.log(0 - (console && 0));
console.log(0 - (0 - (console && 0)));
console.log(0 - (console && 0));
console.log(1 / (0 - (console && 0)));
- console.log(0 - (console && 0) + 0);
+ console.log(0 - (console && 0));
console.log(0 - (console && 0));
console.log(0 - (console && 0));
console.log(0 - (console && 0));
@@ -1167,3 +1167,51 @@ issue_3676_2: {
}
expect_stdout: "NaN"
}
+
+issue_3682_1: {
+ options = {
+ evaluate: true,
+ unsafe_math: true,
+ }
+ input: {
+ var a = -0;
+ console.log(1 / (a - 1 + 1));
+ }
+ expect: {
+ var a = -0;
+ console.log(1 / (a - 1 + 1));
+ }
+ expect_stdout: "Infinity"
+}
+
+issue_3682_2: {
+ options = {
+ evaluate: true,
+ unsafe_math: true,
+ }
+ input: {
+ var a = -0, b = 1;
+ console.log(1 / (a - (b - b)));
+ }
+ expect: {
+ var a = -0, b = 1;
+ console.log(1 / (a - (b - b)));
+ }
+ expect_stdout: "-Infinity"
+}
+
+issue_3682_3: {
+ options = {
+ evaluate: true,
+ unsafe_math: true,
+ }
+ input: {
+ var a = -0, b = 1, c = -1;
+ console.log(1 / (a - (+b + +c)));
+ }
+ expect: {
+ var a = -0, b = 1, c = -1;
+ console.log(1 / (a - (+b + +c)));
+ }
+ expect_stdout: "-Infinity"
+}