[Pkg-javascript-commits] [uglifyjs] 122/190: Fix: Uglified Number.prototype functions on big numbers
Antonio Terceiro
terceiro at moszumanska.debian.org
Sun Aug 7 23:17:19 UTC 2016
This is an automated email from the git hooks/post-receive script.
terceiro pushed a commit to annotated tag upstream/2.7.0
in repository uglifyjs.
commit ee6c9fabb7dc00b8bbc9e60859767acc585cd0fa
Author: philippsimon <github at philippsimon.de>
Date: Mon Mar 14 12:21:25 2016 +0100
Fix: Uglified Number.prototype functions on big numbers
---
lib/output.js | 10 +++++++---
test/compress/numbers.js | 19 +++++++++++++++++++
2 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/lib/output.js b/lib/output.js
index dceece3..a8c45a0 100644
--- a/lib/output.js
+++ b/lib/output.js
@@ -596,8 +596,12 @@ function OutputStream(options) {
PARENS(AST_Number, function(output){
var p = output.parent();
- if (this.getValue() < 0 && p instanceof AST_PropAccess && p.expression === this)
- return true;
+ if (p instanceof AST_PropAccess && p.expression === this) {
+ var value = this.getValue();
+ if (value < 0 || /^0/.test(make_num(value))) {
+ return true;
+ }
+ }
});
PARENS([ AST_Assign, AST_Conditional ], function (output){
@@ -1026,7 +1030,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 0000000..8e32ad0
--- /dev/null
+++ b/test/compress/numbers.js
@@ -0,0 +1,19 @@
+hex_numbers_in_parentheses_for_prototype_functions: {
+ input: {
+ (-2);
+ (-2).toFixed(0);
+
+ (2);
+ (2).toFixed(0);
+
+ (0.2);
+ (0.2).toFixed(0);
+
+ (0.00000002);
+ (0.00000002).toFixed(0);
+
+ (1000000000000000128);
+ (1000000000000000128).toFixed(0);
+ }
+ expect_exact: "-2;(-2).toFixed(0);2;2..toFixed(0);.2;.2.toFixed(0);2e-8;2e-8.toFixed(0);0xde0b6b3a7640080;(0xde0b6b3a7640080).toFixed(0);"
+}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/uglifyjs.git
More information about the Pkg-javascript-commits
mailing list