diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-03-29 18:31:55 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-29 18:31:55 +0800 |
commit | 09f77c7d4d37350102c36b270b553f45e706d0c8 (patch) | |
tree | 39d2af90ff895ad55db168069f6b3c8ac4bc959f /test/compress/issue-597.js | |
parent | fef0bf9ee0367f07dfbca26b144c2995c2b5db5f (diff) | |
download | tracifyjs-09f77c7d4d37350102c36b270b553f45e706d0c8.tar.gz tracifyjs-09f77c7d4d37350102c36b270b553f45e706d0c8.zip |
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
Diffstat (limited to 'test/compress/issue-597.js')
-rw-r--r-- | test/compress/issue-597.js | 86 |
1 files changed, 85 insertions, 1 deletions
diff --git a/test/compress/issue-597.js b/test/compress/issue-597.js index f243223a..3a501532 100644 --- a/test/compress/issue-597.js +++ b/test/compress/issue-597.js @@ -6,7 +6,7 @@ NaN_and_Infinity_must_have_parens: { } expect: { (1/0).toString(); - NaN.toString(); // transformation to 0/0 dropped + (0/0).toString(); } } @@ -23,3 +23,87 @@ NaN_and_Infinity_should_not_be_replaced_when_they_are_redefined: { NaN.toString(); } } + +beautify_off_1: { + options = { + evaluate: true, + } + beautify = { + beautify: false, + } + input: { + var NaN; + console.log( + null, + undefined, + Infinity, + NaN, + Infinity * undefined, + Infinity.toString(), + NaN.toString(), + (Infinity * undefined).toString() + ); + } + expect_exact: "var NaN;console.log(null,void 0,1/0,NaN,0/0,(1/0).toString(),NaN.toString(),(0/0).toString());" + expect_stdout: true +} + +beautify_off_2: { + options = { + evaluate: true, + } + beautify = { + beautify: false, + } + input: { + console.log( + null.toString(), + undefined.toString() + ); + } + expect_exact: "console.log(null.toString(),(void 0).toString());" +} + +beautify_on_1: { + options = { + evaluate: true, + } + beautify = { + beautify: true, + } + input: { + var NaN; + console.log( + null, + undefined, + Infinity, + NaN, + Infinity * undefined, + Infinity.toString(), + NaN.toString(), + (Infinity * undefined).toString() + ); + } + expect_exact: [ + "var NaN;", + "", + "console.log(null, void 0, 1 / 0, NaN, 0 / 0, (1 / 0).toString(), NaN.toString(), (0 / 0).toString());", + ] + expect_stdout: true +} + +beautify_on_2: { + options = { + evaluate: true, + } + beautify = { + beautify: true, + } + input: { + console.log( + null.toString(), + undefined.toString() + ); + } + expect_exact: "console.log(null.toString(), (void 0).toString());" +} |