From 2dbe40b01bc0cc946974b911b9d30d90794851af Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Mon, 5 Oct 2020 08:55:37 +0100 Subject: enhance `conditionals` (#4181) --- test/compress/conditionals.js | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'test/compress') diff --git a/test/compress/conditionals.js b/test/compress/conditionals.js index 4d54b83a..5dfd17bc 100644 --- a/test/compress/conditionals.js +++ b/test/compress/conditionals.js @@ -1159,7 +1159,7 @@ issue_1645_2: { expect_stdout: true } -condition_symbol_matches_consequent: { +condition_matches_consequent: { options = { conditionals: true, } @@ -1188,6 +1188,35 @@ condition_symbol_matches_consequent: { expect_stdout: "3 7 true 4" } +condition_matches_alternative: { + options = { + conditionals: true, + } + input: { + function foo(x, y) { + return x.p ? y[0] : x.p; + } + function bar() { + return g ? h : g; + } + var g = 4; + var h = 5; + console.log(foo({ p: 3 }, [ null ]), foo({ p: 0 }, [ 7 ]), foo({ p: true } , [ false ]), bar()); + } + expect: { + function foo(x, y) { + return x.p && y[0]; + } + function bar() { + return g && h; + } + var g = 4; + var h = 5; + console.log(foo({ p: 3 }, [ null ]), foo({ p: 0 }, [ 7 ]), foo({ p: true } , [ false ]), bar()); + } + expect_stdout: "null 0 false 5" +} + delete_conditional_1: { options = { booleans: true, -- cgit v1.2.3