diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2018-08-30 01:06:34 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-30 01:06:34 +0800 |
commit | 2bdaca10ae05136843d8e99da50925091a593373 (patch) | |
tree | 311af8231275afa875296b0b0ac6107d7f82c60b /test/compress | |
parent | aa0029204ebb7f52db4c70e9579caa1712d1261f (diff) | |
download | tracifyjs-2bdaca10ae05136843d8e99da50925091a593373.tar.gz tracifyjs-2bdaca10ae05136843d8e99da50925091a593373.zip |
enhance `conditionals` (#3243)
Diffstat (limited to 'test/compress')
-rw-r--r-- | test/compress/conditionals.js | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/test/compress/conditionals.js b/test/compress/conditionals.js index 577e7871..35505c87 100644 --- a/test/compress/conditionals.js +++ b/test/compress/conditionals.js @@ -1292,3 +1292,75 @@ to_and_or: { } expect_stdout: true } + +cond_seq_assign_1: { + options = { + conditionals: true, + sequences: true, + } + input: { + function f(a) { + var t; + if (a) { + t = "foo"; + t = "bar"; + } else { + console.log(t); + t = 42; + } + console.log(t); + } + f(f); + f(); + } + expect: { + function f(a) { + var t; + t = a ? (t = "foo", "bar") : (console.log(t), 42), + console.log(t); + } + f(f), + f(); + } + expect_stdout: [ + "bar", + "undefined", + "42", + ] +} + +cond_seq_assign_2: { + options = { + conditionals: true, + sequences: true, + } + input: { + function f(a) { + var t; + if (a) { + t = "foo"; + a = "bar"; + } else { + console.log(t); + t = 42; + } + console.log(t); + } + f(f); + f(); + } + expect: { + function f(a) { + var t; + a ? (t = "foo", a = "bar") : (console.log(t), t = 42), + console.log(t); + } + f(f), + f(); + } + expect_stdout: [ + "foo", + "undefined", + "42", + ] +} |