diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-07-03 04:17:37 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-03 04:17:37 +0800 |
commit | af0262b7e5fd3dbf83619cdb375ab18c41def3e7 (patch) | |
tree | ad9726b73baedc178c1ebd0cae26e6d58acacc46 /test/compress | |
parent | 6b3aeff1d8975f769f7e251c23405baf3a6f2b5a (diff) | |
download | tracifyjs-af0262b7e5fd3dbf83619cdb375ab18c41def3e7.tar.gz tracifyjs-af0262b7e5fd3dbf83619cdb375ab18c41def3e7.zip |
improve parenthesis emission (#2196)
- eliminate `throw` usages
- suppress extraneous parenthesis
- `new function() {foo.bar()}.baz`
- `for (function() { "foo" in bar; };;);`
Diffstat (limited to 'test/compress')
-rw-r--r-- | test/compress/loops.js | 14 | ||||
-rw-r--r-- | test/compress/new.js | 16 | ||||
-rw-r--r-- | test/compress/sequences.js | 9 |
3 files changed, 39 insertions, 0 deletions
diff --git a/test/compress/loops.js b/test/compress/loops.js index 89c7e7e9..bac40494 100644 --- a/test/compress/loops.js +++ b/test/compress/loops.js @@ -436,3 +436,17 @@ do_switch: { } while (false); } } + +in_parenthesis_1: { + input: { + for (("foo" in {});0;); + } + expect_exact: 'for(("foo"in{});0;);' +} + +in_parenthesis_2: { + input: { + for ((function(){ "foo" in {}; });0;); + } + expect_exact: 'for(function(){"foo"in{}};0;);' +} diff --git a/test/compress/new.js b/test/compress/new.js index 83da88e6..640f201a 100644 --- a/test/compress/new.js +++ b/test/compress/new.js @@ -82,3 +82,19 @@ new_with_unary_prefix: { } expect_exact: 'var bar=(+new Date).toString(32);'; } + +dot_parenthesis_1: { + input: { + console.log(new (Math.random().constructor) instanceof Number); + } + expect_exact: "console.log(new(Math.random().constructor)instanceof Number);" + expect_stdout: "true" +} + +dot_parenthesis_2: { + input: { + console.log(typeof new function(){Math.random()}.constructor); + } + expect_exact: "console.log(typeof new function(){Math.random()}.constructor);" + expect_stdout: "function" +} diff --git a/test/compress/sequences.js b/test/compress/sequences.js index f41b603f..5ce24ac0 100644 --- a/test/compress/sequences.js +++ b/test/compress/sequences.js @@ -176,6 +176,11 @@ for_sequences: { // 4 x = (foo in bar); for (y = 5; false;); + // 5 + x = function() { + foo in bar; + }; + for (y = 5; false;); } expect: { // 1 @@ -188,6 +193,10 @@ for_sequences: { // 4 x = (foo in bar); for (y = 5; false;); + // 5 + for (x = function() { + foo in bar; + }, y = 5; false;); } } |