diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-04-01 03:02:14 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-01 03:02:14 +0800 |
commit | 257ddc3bdb37efdb48fc23371f5f523e2044afd8 (patch) | |
tree | 8b91508961f0acd7c43db5a0e08dc8f932df4a55 /test/compress/issue-597.js | |
parent | 1ddc05725d078ccf73d711e376c3c530cd517cdb (diff) | |
download | tracifyjs-257ddc3bdb37efdb48fc23371f5f523e2044afd8.tar.gz tracifyjs-257ddc3bdb37efdb48fc23371f5f523e2044afd8.zip |
improve compression of undefined, NaN & Infinitiy (#1748)
- migrate transformation logic from `OutputStream` to `Compressor`
- always turn `undefined` into `void 0` (unless `unsafe`)
- always keep `NaN` except when avoiding local variable redefinition
- introduce `keep_infinity` to suppress `1/0` transform, except when avoiding local variable redefinition
supersedes #1723
fixes #1730
Diffstat (limited to 'test/compress/issue-597.js')
-rw-r--r-- | test/compress/issue-597.js | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/test/compress/issue-597.js b/test/compress/issue-597.js index 987bcacc..143fcc22 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(); - (0/0).toString(); + NaN.toString(); } } @@ -24,6 +24,36 @@ NaN_and_Infinity_should_not_be_replaced_when_they_are_redefined: { } } +NaN_and_Infinity_must_have_parens_evaluate: { + options = { + evaluate: true, + } + input: { + (123456789 / 0).toString(); + (+"foo").toString(); + } + expect: { + (1/0).toString(); + NaN.toString(); + } +} + +NaN_and_Infinity_should_not_be_replaced_when_they_are_redefined_evaluate: { + options = { + evaluate: true, + } + input: { + var Infinity, NaN; + (123456789 / 0).toString(); + (+"foo").toString(); + } + expect: { + var Infinity, NaN; + (1/0).toString(); + (0/0).toString(); + } +} + beautify_off_1: { options = { evaluate: true, |