output optimal representations of NaN & Infinity (#1723)

- move these optimisations out from `Compressor` to `OutputStream`
- fixes behaviour inconsistency when running uglified code from global or module levels due to redefinition
This commit is contained in:
Alex Lam S.L
2017-03-29 18:31:55 +08:00
committed by GitHub
parent fef0bf9ee0
commit 09f77c7d4d
7 changed files with 137 additions and 44 deletions

View File

@@ -52,7 +52,7 @@ and: {
a = 7;
a = false;
a = NaN;
a = 0/0;
a = 0;
a = void 0;
a = null;
@@ -67,7 +67,7 @@ and: {
a = 6 << condition && -4.5;
a = condition && false;
a = console.log("b") && NaN;
a = console.log("b") && 0/0;
a = console.log("c") && 0;
a = 2 * condition && void 0;
a = condition + 3 && null;
@@ -149,7 +149,7 @@ or: {
a = 6 << condition || -4.5;
a = condition || false;
a = console.log("b") || NaN;
a = console.log("b") || 0/0;
a = console.log("c") || 0;
a = 2 * condition || void 0;
a = condition + 3 || null;
@@ -196,8 +196,8 @@ negative_zero: {
console.log(
-0,
0,
1 / (-0),
1 / (-0)
-1/0,
-1/0
);
}
expect_stdout: true
@@ -217,8 +217,8 @@ positive_zero: {
console.log(
0,
-0,
1 / (0),
1 / (0)
1/0,
1/0
);
}
expect_stdout: true
@@ -533,7 +533,7 @@ unsafe_array: {
[1, 2, 3, a][0] + 1,
2,
3,
NaN,
0/0,
"1,21",
5,
(void 0)[1] + 1