diff options
Diffstat (limited to 'test/compress')
-rw-r--r-- | test/compress/arrows.js | 18 | ||||
-rw-r--r-- | test/compress/classes.js | 2 | ||||
-rw-r--r-- | test/compress/exports.js | 4 | ||||
-rw-r--r-- | test/compress/functions.js | 2 | ||||
-rw-r--r-- | test/compress/loops.js | 4 | ||||
-rw-r--r-- | test/compress/new.js | 4 | ||||
-rw-r--r-- | test/compress/nullish.js | 111 | ||||
-rw-r--r-- | test/compress/numbers.js | 2 | ||||
-rw-r--r-- | test/compress/templates.js | 4 |
9 files changed, 131 insertions, 20 deletions
diff --git a/test/compress/arrows.js b/test/compress/arrows.js index e7322b72..096503d6 100644 --- a/test/compress/arrows.js +++ b/test/compress/arrows.js @@ -34,7 +34,7 @@ destructured_funarg: { node_version: ">=6" } -await_parenthesis: { +await_parentheses: { input: { async function f() { await (a => a); @@ -43,7 +43,7 @@ await_parenthesis: { expect_exact: "async function f(){await(a=>a)}" } -for_parenthesis_init: { +for_parentheses_init: { input: { for (a => (a in a); console.log(42);); } @@ -52,7 +52,7 @@ for_parenthesis_init: { node_version: ">=4" } -for_parenthesis_condition: { +for_parentheses_condition: { input: { for (console.log(42); a => (a in a);) break; @@ -62,7 +62,7 @@ for_parenthesis_condition: { node_version: ">=4" } -for_parenthesis_step: { +for_parentheses_step: { input: { for (; console.log(42); a => (a in a)); } @@ -71,7 +71,7 @@ for_parenthesis_step: { node_version: ">=4" } -for_assign_parenthesis_init: { +for_assign_parentheses_init: { input: { for (f = a => (a in a); console.log(42);); } @@ -80,7 +80,7 @@ for_assign_parenthesis_init: { node_version: ">=4" } -for_assign_parenthesis_condition: { +for_assign_parentheses_condition: { input: { for (console.log(42); f = a => (a in a);) break; @@ -90,7 +90,7 @@ for_assign_parenthesis_condition: { node_version: ">=4" } -for_assign_parenthesis_step: { +for_assign_parentheses_step: { input: { for (; console.log(42); f = a => (a in a)); } @@ -99,7 +99,7 @@ for_assign_parenthesis_step: { node_version: ">=4" } -for_declaration_parenthesis_init: { +for_declaration_parentheses_init: { input: { for (var f = a => (a in a); console.log(42);); } @@ -108,7 +108,7 @@ for_declaration_parenthesis_init: { node_version: ">=4" } -for_statement_parenthesis_init: { +for_statement_parentheses_init: { input: { for (a => { a in a; diff --git a/test/compress/classes.js b/test/compress/classes.js index 8c5575c0..390ae525 100644 --- a/test/compress/classes.js +++ b/test/compress/classes.js @@ -158,7 +158,7 @@ yield: { node_version: ">=12" } -conditional_parenthesis: { +conditional_parentheses: { options = { conditionals: true, } diff --git a/test/compress/exports.js b/test/compress/exports.js index d3a4ffce..e0690503 100644 --- a/test/compress/exports.js +++ b/test/compress/exports.js @@ -38,7 +38,7 @@ defaults: { expect_exact: "export default 42;export default async;export default(x,y)=>x*x;export default class{}export default function*(a,b){}export default async function f({c:c},...[d]){}" } -defaults_parenthesis_1: { +defaults_parentheses_1: { input: { export default function() { console.log("FAIL"); @@ -47,7 +47,7 @@ defaults_parenthesis_1: { expect_exact: 'export default function(){console.log("FAIL")}console.log("PASS");' } -defaults_parenthesis_2: { +defaults_parentheses_2: { input: { export default (async function() { console.log("PASS"); diff --git a/test/compress/functions.js b/test/compress/functions.js index f521433d..fe9307ca 100644 --- a/test/compress/functions.js +++ b/test/compress/functions.js @@ -2053,7 +2053,7 @@ issue_2898: { expect_stdout: "2" } -deduplicate_parenthesis: { +deduplicate_parentheses: { input: { ({}).a = b; (({}).a = b)(); diff --git a/test/compress/loops.js b/test/compress/loops.js index 0afffae5..b1128f1a 100644 --- a/test/compress/loops.js +++ b/test/compress/loops.js @@ -501,14 +501,14 @@ do_switch: { } } -in_parenthesis_1: { +in_parentheses_1: { input: { for (("foo" in {});0;); } expect_exact: 'for(("foo"in{});0;);' } -in_parenthesis_2: { +in_parentheses_2: { input: { for ((function(){ "foo" in {}; });0;); } diff --git a/test/compress/new.js b/test/compress/new.js index a823bb9c..9c99f016 100644 --- a/test/compress/new.js +++ b/test/compress/new.js @@ -85,7 +85,7 @@ new_with_unary_prefix: { expect_exact: 'var bar=(+new Date).toString(32);'; } -dot_parenthesis_1: { +dot_parentheses_1: { input: { console.log(new (Math.random().constructor) instanceof Number); } @@ -93,7 +93,7 @@ dot_parenthesis_1: { expect_stdout: "true" } -dot_parenthesis_2: { +dot_parentheses_2: { input: { console.log(typeof new function(){Math.random()}.constructor); } diff --git a/test/compress/nullish.js b/test/compress/nullish.js new file mode 100644 index 00000000..e8f5ad6c --- /dev/null +++ b/test/compress/nullish.js @@ -0,0 +1,111 @@ +parentheses: { + input: { + (console.log("foo") || console.log("bar") ?? console.log("baz")) && console.log("moo"); + } + expect_exact:'((console.log("foo")||console.log("bar"))??console.log("baz"))&&console.log("moo");' + expect_stdout: [ + "foo", + "bar", + "baz", + ] + node_version: ">=14" +} + +evaluate: { + options = { + evaluate: true, + side_effects: true, + } + input: { + void console.log("foo" ?? "bar") ?? console.log("baz"); + } + expect: { + console.log("foo"), + console.log("baz"); + } + expect_stdout: [ + "foo", + "baz", + ] + node_version: ">=14" +} + +conditional_assignment_1: { + options = { + collapse_vars: true, + } + input: { + console.log(function(a, b) { + b ?? (a = "FAIL"); + return a; + }("PASS", !console)); + } + expect: { + console.log(function(a, b) { + b ?? (a = "FAIL"); + return a; + }("PASS", !console)); + } + expect_stdout: "PASS" + node_version: ">=14" +} + +conditional_assignment_2: { + options = { + conditionals: true, + } + input: { + var a, b = false; + a = "PASS", + b ?? (a = "FAIL"), + console.log(a); + } + expect: { + var a, b = false; + a = "PASS", + b ?? (a = "FAIL"), + console.log(a); + } + expect_stdout: "PASS" + node_version: ">=14" +} + +conditional_assignment_3: { + options = { + conditionals: true, + join_vars: true, + } + input: { + var a, b = false; + a = "PASS", + b ?? (a = "FAIL"), + console.log(a); + } + expect: { + var a, b = false, a = "PASS"; + b ?? (a = "FAIL"), + console.log(a); + } + expect_stdout: "PASS" + node_version: ">=14" +} + +conditional_assignment_4: { + options = { + side_effects: true, + } + input: { + console.log(function(a) { + !console ?? (a = "FAIL"); + return a; + }("PASS")); + } + expect: { + console.log(function(a) { + !console ?? (a = "FAIL"); + return a; + }("PASS")); + } + expect_stdout: "PASS" + node_version: ">=14" +} diff --git a/test/compress/numbers.js b/test/compress/numbers.js index 994cd5cf..d7c0360c 100644 --- a/test/compress/numbers.js +++ b/test/compress/numbers.js @@ -777,7 +777,7 @@ issue_1710: { expect_stdout: true } -unary_binary_parenthesis: { +unary_binary_parentheses: { options = { evaluate: true, } diff --git a/test/compress/templates.js b/test/compress/templates.js index d9e95975..b75dc7d7 100644 --- a/test/compress/templates.js +++ b/test/compress/templates.js @@ -53,7 +53,7 @@ tagged_chain: { node_version: ">=4" } -tag_parenthesis_arrow: { +tag_parentheses_arrow: { input: { console.log((s => s.raw[0])`\tPASS`.slice(2)); } @@ -62,7 +62,7 @@ tag_parenthesis_arrow: { node_version: ">=4" } -tag_parenthesis_new: { +tag_parentheses_new: { input: { (new function() { return console.log; |