diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2018-01-15 18:47:23 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-15 18:47:23 +0800 |
commit | 10f961c27b0db61c3a197f8f88080d9197361ea4 (patch) | |
tree | fe8a20a55b1525485e42fd7e4117a8726b30274c /test/compress | |
parent | b483678ca7f5e539cef9c57324ecc92d65800f7d (diff) | |
download | tracifyjs-10f961c27b0db61c3a197f8f88080d9197361ea4.tar.gz tracifyjs-10f961c27b0db61c3a197f8f88080d9197361ea4.zip |
enhance `collapse_vars` (#2788)
Diffstat (limited to 'test/compress')
-rw-r--r-- | test/compress/collapse_vars.js | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js index 12b49230..f252a7f4 100644 --- a/test/compress/collapse_vars.js +++ b/test/compress/collapse_vars.js @@ -4012,3 +4012,53 @@ replace_all_var: { } expect_stdout: "PASS" } + +cascade_statement: { + options = { + collapse_vars: true, + } + input: { + function f1(a, b) { + var c; + if (a) + return c = b, c || a; + else + c = a, c(b); + } + function f2(a, b) { + var c; + while (a) + c = b, a = c + b; + do + throw c = a + b, c; + while (c); + } + function f3(a, b) { + for (; a < b; a++) + if (c = a, c && b) + var c = (c = b(a), c); + } + } + expect: { + function f1(a, b) { + var c; + if (a) + return (c = b) || a; + else + (c = a)(b); + } + function f2(a, b) { + var c; + while (a) + a = (c = b) + b; + do + throw c = a + b; + while (c); + } + function f3(a, b) { + for (; a < b; a++) + if ((c = a) && b) + var c = c = b(a); + } + } +} |