diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/compress.js | 1 | ||||
-rw-r--r-- | test/compress/numbers.js | 117 |
2 files changed, 84 insertions, 34 deletions
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: { |