From 94ef5ed8bbfbca0ac311dbcde21f1d9ff0fe6d14 Mon Sep 17 00:00:00 2001 From: philippsimon Date: Mon, 14 Mar 2016 12:21:25 +0100 Subject: [PATCH] Fix: Uglified Number.prototype functions on big numbers --- lib/output.js | 4 ++-- test/compress/numbers.js | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 test/compress/numbers.js diff --git a/lib/output.js b/lib/output.js index dceece34..99a8a39b 100644 --- a/lib/output.js +++ b/lib/output.js @@ -596,7 +596,7 @@ function OutputStream(options) { PARENS(AST_Number, function(output){ var p = output.parent(); - if (this.getValue() < 0 && p instanceof AST_PropAccess && p.expression === this) + if (p instanceof AST_PropAccess && p.expression === this && (this.getValue() < 0 || make_num(this.getValue()).match(/^0/))) return true; }); @@ -1026,7 +1026,7 @@ function OutputStream(options) { var expr = self.expression; expr.print(output); if (expr instanceof AST_Number && expr.getValue() >= 0) { - if (!/[xa-f.]/i.test(output.last())) { + if (!/[xa-f.)]/i.test(output.last())) { output.print("."); } } diff --git a/test/compress/numbers.js b/test/compress/numbers.js new file mode 100644 index 00000000..6785e873 --- /dev/null +++ b/test/compress/numbers.js @@ -0,0 +1,16 @@ +hex_numbers_in_parentheses_for_prototype_functions: { + input: { + (-2); + (-2).toFixed(0); + + (2); + (2).toFixed(0); + + (0.00000002); + (0.00000002).toFixed(0); + + (1000000000000000128); + (1000000000000000128).toFixed(0); + } + expect_exact: "-2;(-2).toFixed(0);2;2..toFixed(0);2e-8;2e-8.toFixed(0);0xde0b6b3a7640080;(0xde0b6b3a7640080).toFixed(0);" +}