aboutsummaryrefslogtreecommitdiff
path: root/test/compress/issue-597.js
diff options
context:
space:
mode:
authorRichard van Velzen <rvanvelzen1@gmail.com>2014-12-31 12:23:00 +0100
committerRichard van Velzen <rvanvelzen1@gmail.com>2014-12-31 12:23:00 +0100
commitc75f5a1fd85368edb3456637c544dee0cad1011e (patch)
tree63f5e62bf51c269fb570e9287d36eb9cdc014d09 /test/compress/issue-597.js
parent5538ec7bd8a64c7fcc45895308a8463e4ca4d00a (diff)
downloadtracifyjs-c75f5a1fd85368edb3456637c544dee0cad1011e.tar.gz
tracifyjs-c75f5a1fd85368edb3456637c544dee0cad1011e.zip
Fix #597
NaN and Infinity were replaced in the output generation, instead of during compression. This could lead to results where `1/0` was inserted without parens leading to invalid output. The nodes are replaced in the compression step now, and the output generation returns their regular names. This should not be a problem, since they're already only constructed from the original name.
Diffstat (limited to 'test/compress/issue-597.js')
-rw-r--r--test/compress/issue-597.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/compress/issue-597.js b/test/compress/issue-597.js
new file mode 100644
index 00000000..3c651a4c
--- /dev/null
+++ b/test/compress/issue-597.js
@@ -0,0 +1,25 @@
+NaN_and_Infinity_must_have_parens: {
+ options = {};
+ input: {
+ Infinity.toString();
+ NaN.toString();
+ }
+ expect: {
+ (1/0).toString();
+ (0/0).toString();
+ }
+}
+
+NaN_and_Infinity_should_not_be_replaced_when_they_are_redefined: {
+ options = {};
+ input: {
+ var Infinity, NaN;
+ Infinity.toString();
+ NaN.toString();
+ }
+ expect: {
+ var Infinity, NaN;
+ Infinity.toString();
+ NaN.toString();
+ }
+}