diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-01-28 12:33:21 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-28 12:33:21 +0800 |
commit | b499e03f82987d59814c81fb9f211fee5e3a7ba4 (patch) | |
tree | 2f7b22c777dea6822cfa416fc3e41cd83b8bdeb5 /test/compress/conditionals.js | |
parent | a478f275e421ccbb428f38272e8e673f6684729c (diff) | |
download | tracifyjs-b499e03f82987d59814c81fb9f211fee5e3a7ba4.tar.gz tracifyjs-b499e03f82987d59814c81fb9f211fee5e3a7ba4.zip |
enhance `conditionals` (#3694)
Diffstat (limited to 'test/compress/conditionals.js')
-rw-r--r-- | test/compress/conditionals.js | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/test/compress/conditionals.js b/test/compress/conditionals.js index 2049b401..8044489e 100644 --- a/test/compress/conditionals.js +++ b/test/compress/conditionals.js @@ -294,6 +294,45 @@ cond_5: { } } +cond_6: { + options = { + booleans: true, + conditionals: true, + } + input: { + x ? a : b; + x ? a : a; + + x ? y ? a : b : c; + x ? y ? a : a : b; + x ? y ? a : b : b; + x ? y ? a : b : a; + x ? y ? a : a : a; + + x ? a : y ? b : c; + x ? a : y ? a : b; + x ? a : y ? b : b; + x ? a : y ? b : a; + x ? a : y ? a : a; + } + expect: { + x ? a : b; + x, a; + + x ? y ? a : b : c; + x ? (y, a) : b; + x && y ? a : b; + !x || y ? a : b; + x && y, a; + + x ? a : y ? b : c; + x || y ? a : b; + x ? a : (y, b); + !x && y ? b : a; + !x && y, a; + } +} + cond_7: { options = { conditionals: true, @@ -726,6 +765,24 @@ cond_11: { expect_stdout: "foo bar" } +cond_12: { + options = { + conditionals: true, + } + input: { + x ? y && a : a; + x ? y || a : a; + x ? a : y && a; + x ? a : y || a; + } + expect: { + (!x || y) && a; + x && y || a; + (x || y) && a; + !x && y || a; + } +} + ternary_boolean_consequent: { options = { booleans: true, |