diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2019-11-13 16:45:16 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-13 16:45:16 +0800 |
commit | fe65ce965885815a30d88aa7d9eccec5443e6a3b (patch) | |
tree | 16aeb373b9efe2a0b2ffdddabd054ded62eee43b /test/compress/collapse_vars.js | |
parent | d6fd18d0b000e1e4fbe01259139043f42d8fdebf (diff) | |
download | tracifyjs-fe65ce965885815a30d88aa7d9eccec5443e6a3b.tar.gz tracifyjs-fe65ce965885815a30d88aa7d9eccec5443e6a3b.zip |
fix corner case in `collapse_vars` (#3582)
fixes #3581
Diffstat (limited to 'test/compress/collapse_vars.js')
-rw-r--r-- | test/compress/collapse_vars.js | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js index e67425af..2e82cc9d 100644 --- a/test/compress/collapse_vars.js +++ b/test/compress/collapse_vars.js @@ -6468,3 +6468,63 @@ issue_3573: { } expect_stdout: "1" } + +issue_3581_1: { + options = { + collapse_vars: true, + } + input: { + var a = "PASS", b = "FAIL"; + try { + b = "PASS"; + if (a) throw 0; + b = 1 + b; + a = "FAIL"; + } catch (e) {} + console.log(a, b); + } + expect: { + var a = "PASS", b = "FAIL"; + try { + b = "PASS"; + if (a) throw 0; + b = 1 + b; + a = "FAIL"; + } catch (e) {} + console.log(a, b); + } + expect_stdout: "PASS PASS" +} + +issue_3581_2: { + options = { + collapse_vars: true, + } + input: { + (function() { + var a = "PASS", b = "FAIL"; + try { + b = "PASS"; + if (a) return; + b = 1 + b; + a = "FAIL"; + } finally { + console.log(a, b); + } + })(); + } + expect: { + (function() { + var a = "PASS", b = "FAIL"; + try { + b = "PASS"; + if (a) return; + b = 1 + b; + a = "FAIL"; + } finally { + console.log(a, b); + } + })(); + } + expect_stdout: "PASS PASS" +} |