aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--lib/output.js8
-rw-r--r--test/compress.js1
-rw-r--r--test/compress/numbers.js117
4 files changed, 91 insertions, 37 deletions
diff --git a/README.md b/README.md
index c0b1e8b9..0bfad01a 100644
--- a/README.md
+++ b/README.md
@@ -868,6 +868,8 @@ can pass additional arguments that control the code output:
}
```
+- `galio` (default `false`) -- enable workarounds for ANT Galio bugs
+
- `indent_level` (default `4`)
- `indent_start` (default `0`) -- prefix all lines by that many spaces
diff --git a/lib/output.js b/lib/output.js
index 12358ffc..218372a8 100644
--- a/lib/output.js
+++ b/lib/output.js
@@ -56,6 +56,7 @@ function OutputStream(options) {
beautify : false,
braces : false,
comments : false,
+ galio : false,
ie8 : false,
indent_level : 4,
indent_start : 0,
@@ -767,9 +768,10 @@ function OutputStream(options) {
var p = output.parent();
if (p instanceof AST_PropAccess && p.expression === this) {
var value = this.value;
- // https://github.com/mishoo/UglifyJS/issues/115
- // https://github.com/mishoo/UglifyJS/pull/1009
- return value < 0 || /^0/.test(make_num(value));
+ // https://github.com/mishoo/UglifyJS/issues/115
+ return value < 0
+ // https://github.com/mishoo/UglifyJS/pull/1009
+ || output.option("galio") && /^0/.test(make_num(value));
}
});
diff --git a/test/compress.js b/test/compress.js
index eda9b7b7..f35159b0 100644
--- a/test/compress.js
+++ b/test/compress.js
@@ -63,7 +63,6 @@ function make_code(ast, options) {
function parse_test(file) {
var script = fs.readFileSync(file, "utf8");
- // TODO try/catch can be removed after fixing https://github.com/mishoo/UglifyJS/issues/348
try {
var ast = U.parse(script, {
filename: file
diff --git a/test/compress/numbers.js b/test/compress/numbers.js
index c7aab685..7a9a3a7c 100644
--- a/test/compress/numbers.js
+++ b/test/compress/numbers.js
@@ -1,49 +1,100 @@
-hex_numbers_in_parentheses_for_prototype_functions: {
+parentheses_for_prototype_functions: {
beautify = {
beautify: true,
}
input: {
- function f() {
- (-2);
- (-2).toFixed(0);
+ (function() {
+ console.log((-2));
+ console.log((-2).toFixed(0));
- (2);
- (2).toFixed(0);
+ console.log((2));
+ console.log((2).toFixed(0));
- (0.2);
- (0.2).toFixed(0);
+ console.log((0.2));
+ console.log((0.2).toFixed(0));
- (2.34e20);
- (2.34e20).toFixed(0);
+ console.log((2.34e20));
+ console.log((2.34e20).toFixed(0));
- (0.00000002);
- (0.00000002).toFixed(0);
+ console.log((0.00000002));
+ console.log((0.00000002).toFixed(0));
- (1000000000000000128);
- (1000000000000000128).toFixed(0);
+ console.log((1000000000000000128));
+ console.log((1000000000000000128).toFixed(0));
- (-1000000000000000128);
- (-1000000000000000128).toFixed(0);
- }
+ console.log((-1000000000000000128));
+ console.log((-1000000000000000128).toFixed(0));
+ })();
+ }
+ expect_exact: [
+ "(function() {",
+ " console.log(-2);",
+ " console.log((-2).toFixed(0));",
+ " console.log(2);",
+ " console.log(2..toFixed(0));",
+ " console.log(.2);",
+ " console.log(.2.toFixed(0));",
+ " console.log(234e18);",
+ " console.log(234e18.toFixed(0));",
+ " console.log(2e-8);",
+ " console.log(2e-8.toFixed(0));",
+ " console.log(0xde0b6b3a7640080);",
+ " console.log(0xde0b6b3a7640080.toFixed(0));",
+ " console.log(-0xde0b6b3a7640080);",
+ " console.log((-0xde0b6b3a7640080).toFixed(0));",
+ "})();",
+ ]
+ expect_stdout: true
+}
+
+parentheses_for_prototype_functions_galio: {
+ beautify = {
+ beautify: true,
+ galio: true,
+ }
+ input: {
+ (function() {
+ console.log((-2));
+ console.log((-2).toFixed(0));
+
+ console.log((2));
+ console.log((2).toFixed(0));
+
+ console.log((0.2));
+ console.log((0.2).toFixed(0));
+
+ console.log((2.34e20));
+ console.log((2.34e20).toFixed(0));
+
+ console.log((0.00000002));
+ console.log((0.00000002).toFixed(0));
+
+ console.log((1000000000000000128));
+ console.log((1000000000000000128).toFixed(0));
+
+ console.log((-1000000000000000128));
+ console.log((-1000000000000000128).toFixed(0));
+ })();
}
expect_exact: [
- "function f() {",
- " -2;",
- " (-2).toFixed(0);",
- " 2;",
- " 2..toFixed(0);",
- " .2;",
- " .2.toFixed(0);",
- " 234e18;",
- " 234e18.toFixed(0);",
- " 2e-8;",
- " 2e-8.toFixed(0);",
- " 0xde0b6b3a7640080;",
- " (0xde0b6b3a7640080).toFixed(0);",
- " -0xde0b6b3a7640080;",
- " (-0xde0b6b3a7640080).toFixed(0);",
- "}",
+ "(function() {",
+ " console.log(-2);",
+ " console.log((-2).toFixed(0));",
+ " console.log(2);",
+ " console.log(2..toFixed(0));",
+ " console.log(.2);",
+ " console.log(.2.toFixed(0));",
+ " console.log(234e18);",
+ " console.log(234e18.toFixed(0));",
+ " console.log(2e-8);",
+ " console.log(2e-8.toFixed(0));",
+ " console.log(0xde0b6b3a7640080);",
+ " console.log((0xde0b6b3a7640080).toFixed(0));",
+ " console.log(-0xde0b6b3a7640080);",
+ " console.log((-0xde0b6b3a7640080).toFixed(0));",
+ "})();",
]
+ expect_stdout: true
}
comparisons: {