-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(es/minifier): Fix compress pow
NaN
(#9210)
**Description:** `f64::powf` for `NaN` returns 1 instead of `NaN`, see rust-lang/rust#60468. We should handle that. **Related issue:** - Closes #9193 --------- Co-authored-by: magic-akari <[email protected]>
- Loading branch information
1 parent
181320a
commit 2b361e6
Showing
15 changed files
with
357 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
crates/swc_ecma_minifier/tests/terser/compress/evaluate/pow_nan/config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"evaluate": true | ||
} |
1 change: 1 addition & 0 deletions
1
crates/swc_ecma_minifier/tests/terser/compress/evaluate/pow_nan/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log(Math.pow(1, NaN)); |
1 change: 1 addition & 0 deletions
1
crates/swc_ecma_minifier/tests/terser/compress/evaluate/pow_nan/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log(NaN); |
1 change: 1 addition & 0 deletions
1
crates/swc_ecma_minifier/tests/terser/compress/evaluate/pow_nan/output.mangleOnly.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log(Math.pow(1, NaN)); |
1 change: 1 addition & 0 deletions
1
crates/swc_ecma_minifier/tests/terser/compress/evaluate/pow_nan/output.terser.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log(NaN); |
3 changes: 3 additions & 0 deletions
3
crates/swc_ecma_minifier/tests/terser/compress/evaluate/pow_spec/config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"evaluate": true | ||
} |
81 changes: 81 additions & 0 deletions
81
crates/swc_ecma_minifier/tests/terser/compress/evaluate/pow_spec/expected.stdout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
NaN | ||
NaN | ||
NaN | ||
NaN | ||
1 | ||
NaN | ||
NaN | ||
NaN | ||
1 | ||
NaN | ||
Infinity | ||
Infinity | ||
Infinity | ||
1 | ||
Infinity | ||
0 | ||
0 | ||
1 | ||
NaN | ||
Infinity | ||
4 | ||
2 | ||
1 | ||
1.4142135623730951 | ||
0 | ||
0.5 | ||
1 | ||
NaN | ||
NaN | ||
1 | ||
1 | ||
1 | ||
1 | ||
NaN | ||
1 | ||
1 | ||
NaN | ||
0 | ||
0.25 | ||
0.5 | ||
1 | ||
0.7071067811865476 | ||
Infinity | ||
2 | ||
1 | ||
NaN | ||
0 | ||
0 | ||
0 | ||
1 | ||
0 | ||
Infinity | ||
Infinity | ||
1 | ||
NaN | ||
Infinity | ||
Infinity | ||
-Infinity | ||
1 | ||
Infinity | ||
0 | ||
-0 | ||
1 | ||
NaN | ||
NaN | ||
1 | ||
-1 | ||
1 | ||
NaN | ||
NaN | ||
-1 | ||
1 | ||
NaN | ||
0 | ||
0 | ||
-0 | ||
1 | ||
0 | ||
Infinity | ||
-Infinity | ||
1 |
81 changes: 81 additions & 0 deletions
81
crates/swc_ecma_minifier/tests/terser/compress/evaluate/pow_spec/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
console.log(Math.pow(NaN, NaN)); | ||
console.log(Math.pow(NaN, Infinity)); | ||
console.log(Math.pow(NaN, 2)); | ||
console.log(Math.pow(NaN, 1)); | ||
console.log(Math.pow(NaN, 0)); | ||
console.log(Math.pow(NaN, 0.5)); | ||
console.log(Math.pow(NaN, -Infinity)); | ||
console.log(Math.pow(NaN, -1)); | ||
console.log(Math.pow(NaN, -0)); | ||
console.log(Math.pow(Infinity, NaN)); | ||
console.log(Math.pow(Infinity, Infinity)); | ||
console.log(Math.pow(Infinity, 2)); | ||
console.log(Math.pow(Infinity, 1)); | ||
console.log(Math.pow(Infinity, 0)); | ||
console.log(Math.pow(Infinity, 0.5)); | ||
console.log(Math.pow(Infinity, -Infinity)); | ||
console.log(Math.pow(Infinity, -1)); | ||
console.log(Math.pow(Infinity, -0)); | ||
console.log(Math.pow(2, NaN)); | ||
console.log(Math.pow(2, Infinity)); | ||
console.log(Math.pow(2, 2)); | ||
console.log(Math.pow(2, 1)); | ||
console.log(Math.pow(2, 0)); | ||
console.log(Math.pow(2, 0.5)); | ||
console.log(Math.pow(2, -Infinity)); | ||
console.log(Math.pow(2, -1)); | ||
console.log(Math.pow(2, -0)); | ||
console.log(Math.pow(1, NaN)); | ||
console.log(Math.pow(1, Infinity)); | ||
console.log(Math.pow(1, 2)); | ||
console.log(Math.pow(1, 1)); | ||
console.log(Math.pow(1, 0)); | ||
console.log(Math.pow(1, 0.5)); | ||
console.log(Math.pow(1, -Infinity)); | ||
console.log(Math.pow(1, -1)); | ||
console.log(Math.pow(1, -0)); | ||
console.log(Math.pow(0.5, NaN)); | ||
console.log(Math.pow(0.5, Infinity)); | ||
console.log(Math.pow(0.5, 2)); | ||
console.log(Math.pow(0.5, 1)); | ||
console.log(Math.pow(0.5, 0)); | ||
console.log(Math.pow(0.5, 0.5)); | ||
console.log(Math.pow(0.5, -Infinity)); | ||
console.log(Math.pow(0.5, -1)); | ||
console.log(Math.pow(0.5, -0)); | ||
console.log(Math.pow(0, NaN)); | ||
console.log(Math.pow(0, Infinity)); | ||
console.log(Math.pow(0, 2)); | ||
console.log(Math.pow(0, 1)); | ||
console.log(Math.pow(0, 0)); | ||
console.log(Math.pow(0, 0.5)); | ||
console.log(Math.pow(0, -Infinity)); | ||
console.log(Math.pow(0, -1)); | ||
console.log(Math.pow(0, -0)); | ||
console.log(Math.pow(-Infinity, NaN)); | ||
console.log(Math.pow(-Infinity, Infinity)); | ||
console.log(Math.pow(-Infinity, 2)); | ||
console.log(Math.pow(-Infinity, 1)); | ||
console.log(Math.pow(-Infinity, 0)); | ||
console.log(Math.pow(-Infinity, 0.5)); | ||
console.log(Math.pow(-Infinity, -Infinity)); | ||
console.log(Math.pow(-Infinity, -1)); | ||
console.log(Math.pow(-Infinity, -0)); | ||
console.log(Math.pow(-1, NaN)); | ||
console.log(Math.pow(-1, Infinity)); | ||
console.log(Math.pow(-1, 2)); | ||
console.log(Math.pow(-1, 1)); | ||
console.log(Math.pow(-1, 0)); | ||
console.log(Math.pow(-1, 0.5)); | ||
console.log(Math.pow(-1, -Infinity)); | ||
console.log(Math.pow(-1, -1)); | ||
console.log(Math.pow(-1, -0)); | ||
console.log(Math.pow(-0, NaN)); | ||
console.log(Math.pow(-0, Infinity)); | ||
console.log(Math.pow(-0, 2)); | ||
console.log(Math.pow(-0, 1)); | ||
console.log(Math.pow(-0, 0)); | ||
console.log(Math.pow(-0, 0.5)); | ||
console.log(Math.pow(-0, -Infinity)); | ||
console.log(Math.pow(-0, -1)); | ||
console.log(Math.pow(-0, -0)); |
81 changes: 81 additions & 0 deletions
81
crates/swc_ecma_minifier/tests/terser/compress/evaluate/pow_spec/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
console.log(NaN); | ||
console.log(Math.pow(NaN, 1 / 0)); | ||
console.log(NaN); | ||
console.log(NaN); | ||
console.log(1); | ||
console.log(NaN); | ||
console.log(Math.pow(NaN, -1 / 0)); | ||
console.log(NaN); | ||
console.log(1); | ||
console.log(Math.pow(1 / 0, NaN)); | ||
console.log(Math.pow(1 / 0, 1 / 0)); | ||
console.log(Math.pow(1 / 0, 2)); | ||
console.log(Math.pow(1 / 0, 1)); | ||
console.log(Math.pow(1 / 0, 0)); | ||
console.log(Math.pow(1 / 0, 0.5)); | ||
console.log(Math.pow(1 / 0, -1 / 0)); | ||
console.log(Math.pow(1 / 0, -1)); | ||
console.log(Math.pow(1 / 0, -0)); | ||
console.log(NaN); | ||
console.log(Math.pow(2, 1 / 0)); | ||
console.log(4); | ||
console.log(2); | ||
console.log(1); | ||
console.log(1.4142135623730951); | ||
console.log(Math.pow(2, -1 / 0)); | ||
console.log(0.5); | ||
console.log(1); | ||
console.log(NaN); | ||
console.log(Math.pow(1, 1 / 0)); | ||
console.log(1); | ||
console.log(1); | ||
console.log(1); | ||
console.log(1); | ||
console.log(Math.pow(1, -1 / 0)); | ||
console.log(1); | ||
console.log(1); | ||
console.log(NaN); | ||
console.log(Math.pow(0.5, 1 / 0)); | ||
console.log(0.25); | ||
console.log(0.5); | ||
console.log(1); | ||
console.log(0.7071067811865476); | ||
console.log(Math.pow(0.5, -1 / 0)); | ||
console.log(2); | ||
console.log(1); | ||
console.log(NaN); | ||
console.log(Math.pow(0, 1 / 0)); | ||
console.log(0); | ||
console.log(0); | ||
console.log(1); | ||
console.log(0); | ||
console.log(Math.pow(0, -1 / 0)); | ||
console.log(Infinity); | ||
console.log(1); | ||
console.log(Math.pow(-1 / 0, NaN)); | ||
console.log(Math.pow(-1 / 0, 1 / 0)); | ||
console.log(Math.pow(-1 / 0, 2)); | ||
console.log(Math.pow(-1 / 0, 1)); | ||
console.log(Math.pow(-1 / 0, 0)); | ||
console.log(Math.pow(-1 / 0, 0.5)); | ||
console.log(Math.pow(-1 / 0, -1 / 0)); | ||
console.log(Math.pow(-1 / 0, -1)); | ||
console.log(Math.pow(-1 / 0, -0)); | ||
console.log(NaN); | ||
console.log(Math.pow(-1, 1 / 0)); | ||
console.log(1); | ||
console.log(-1); | ||
console.log(1); | ||
console.log(NaN); | ||
console.log(Math.pow(-1, -1 / 0)); | ||
console.log(-1); | ||
console.log(1); | ||
console.log(NaN); | ||
console.log(Math.pow(-0, 1 / 0)); | ||
console.log(0); | ||
console.log(-0); | ||
console.log(1); | ||
console.log(0); | ||
console.log(Math.pow(-0, -1 / 0)); | ||
console.log(-Infinity); | ||
console.log(1); |
Oops, something went wrong.