gate galio workaround (#4310)
This commit is contained in:
@@ -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_level` (default `4`)
|
||||||
|
|
||||||
- `indent_start` (default `0`) -- prefix all lines by that many spaces
|
- `indent_start` (default `0`) -- prefix all lines by that many spaces
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ function OutputStream(options) {
|
|||||||
beautify : false,
|
beautify : false,
|
||||||
braces : false,
|
braces : false,
|
||||||
comments : false,
|
comments : false,
|
||||||
|
galio : false,
|
||||||
ie8 : false,
|
ie8 : false,
|
||||||
indent_level : 4,
|
indent_level : 4,
|
||||||
indent_start : 0,
|
indent_start : 0,
|
||||||
@@ -768,8 +769,9 @@ function OutputStream(options) {
|
|||||||
if (p instanceof AST_PropAccess && p.expression === this) {
|
if (p instanceof AST_PropAccess && p.expression === this) {
|
||||||
var value = this.value;
|
var value = this.value;
|
||||||
// https://github.com/mishoo/UglifyJS/issues/115
|
// https://github.com/mishoo/UglifyJS/issues/115
|
||||||
|
return value < 0
|
||||||
// https://github.com/mishoo/UglifyJS/pull/1009
|
// https://github.com/mishoo/UglifyJS/pull/1009
|
||||||
return value < 0 || /^0/.test(make_num(value));
|
|| output.option("galio") && /^0/.test(make_num(value));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,6 @@ function make_code(ast, options) {
|
|||||||
|
|
||||||
function parse_test(file) {
|
function parse_test(file) {
|
||||||
var script = fs.readFileSync(file, "utf8");
|
var script = fs.readFileSync(file, "utf8");
|
||||||
// TODO try/catch can be removed after fixing https://github.com/mishoo/UglifyJS/issues/348
|
|
||||||
try {
|
try {
|
||||||
var ast = U.parse(script, {
|
var ast = U.parse(script, {
|
||||||
filename: file
|
filename: file
|
||||||
|
|||||||
@@ -1,49 +1,100 @@
|
|||||||
hex_numbers_in_parentheses_for_prototype_functions: {
|
parentheses_for_prototype_functions: {
|
||||||
beautify = {
|
beautify = {
|
||||||
beautify: true,
|
beautify: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function f() {
|
(function() {
|
||||||
(-2);
|
console.log((-2));
|
||||||
(-2).toFixed(0);
|
console.log((-2).toFixed(0));
|
||||||
|
|
||||||
(2);
|
console.log((2));
|
||||||
(2).toFixed(0);
|
console.log((2).toFixed(0));
|
||||||
|
|
||||||
(0.2);
|
console.log((0.2));
|
||||||
(0.2).toFixed(0);
|
console.log((0.2).toFixed(0));
|
||||||
|
|
||||||
(2.34e20);
|
console.log((2.34e20));
|
||||||
(2.34e20).toFixed(0);
|
console.log((2.34e20).toFixed(0));
|
||||||
|
|
||||||
(0.00000002);
|
console.log((0.00000002));
|
||||||
(0.00000002).toFixed(0);
|
console.log((0.00000002).toFixed(0));
|
||||||
|
|
||||||
(1000000000000000128);
|
console.log((1000000000000000128));
|
||||||
(1000000000000000128).toFixed(0);
|
console.log((1000000000000000128).toFixed(0));
|
||||||
|
|
||||||
(-1000000000000000128);
|
console.log((-1000000000000000128));
|
||||||
(-1000000000000000128).toFixed(0);
|
console.log((-1000000000000000128).toFixed(0));
|
||||||
}
|
})();
|
||||||
}
|
}
|
||||||
expect_exact: [
|
expect_exact: [
|
||||||
"function f() {",
|
"(function() {",
|
||||||
" -2;",
|
" console.log(-2);",
|
||||||
" (-2).toFixed(0);",
|
" console.log((-2).toFixed(0));",
|
||||||
" 2;",
|
" console.log(2);",
|
||||||
" 2..toFixed(0);",
|
" console.log(2..toFixed(0));",
|
||||||
" .2;",
|
" console.log(.2);",
|
||||||
" .2.toFixed(0);",
|
" console.log(.2.toFixed(0));",
|
||||||
" 234e18;",
|
" console.log(234e18);",
|
||||||
" 234e18.toFixed(0);",
|
" console.log(234e18.toFixed(0));",
|
||||||
" 2e-8;",
|
" console.log(2e-8);",
|
||||||
" 2e-8.toFixed(0);",
|
" console.log(2e-8.toFixed(0));",
|
||||||
" 0xde0b6b3a7640080;",
|
" console.log(0xde0b6b3a7640080);",
|
||||||
" (0xde0b6b3a7640080).toFixed(0);",
|
" console.log(0xde0b6b3a7640080.toFixed(0));",
|
||||||
" -0xde0b6b3a7640080;",
|
" console.log(-0xde0b6b3a7640080);",
|
||||||
" (-0xde0b6b3a7640080).toFixed(0);",
|
" 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() {",
|
||||||
|
" 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: {
|
comparisons: {
|
||||||
|
|||||||
Reference in New Issue
Block a user