diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-10-05 08:55:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-05 15:55:37 +0800 |
commit | 2dbe40b01bc0cc946974b911b9d30d90794851af (patch) | |
tree | c0f6dd044971d73416c6bfcf8b1bd5af47d79c24 /test/compress | |
parent | 813ac3ba9663d4123043aa823da59b6c3387f30f (diff) | |
download | tracifyjs-2dbe40b01bc0cc946974b911b9d30d90794851af.tar.gz tracifyjs-2dbe40b01bc0cc946974b911b9d30d90794851af.zip |
enhance `conditionals` (#4181)
Diffstat (limited to 'test/compress')
-rw-r--r-- | test/compress/conditionals.js | 31 |
1 files changed, 30 insertions, 1 deletions
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, |