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

@@ -195,11 +195,12 @@ assorted_Infinity_NaN_undefined_in_with_scope: {
sequences: false,
}
input: {
var f = console.log;
var o = {
undefined : 3,
NaN : 4,
Infinity : 5,
}
};
if (o) {
f(undefined, void 0);
f(NaN, 0/0);
@@ -216,25 +217,25 @@ assorted_Infinity_NaN_undefined_in_with_scope: {
}
}
expect: {
var o = {
var f = console.log, o = {
undefined : 3,
NaN : 4,
Infinity : 5
}
};
if (o) {
f(void 0, void 0);
f(NaN, NaN);
f(0/0, 0/0);
f(1/0, 1/0);
f(-(1/0), -(1/0));
f(NaN, NaN);
f(-1/0, -1/0);
f(0/0, 0/0);
}
with (o) {
f(undefined, void 0);
f(NaN, 0/0);
f(Infinity, 1/0);
f(-Infinity, -(1/0));
f(-Infinity, -1/0);
f(9 + undefined, 9 + void 0);
}
}
expect_stdout: true
}