diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-12-08 02:54:37 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-08 02:54:37 +0800 |
commit | 74a2f53683e2b8788eadc10762583491e3dbc7ea (patch) | |
tree | 9d586ea44e3c3f5a24e79b206f7014e6f8e2e749 /test/compress/reduce_vars.js | |
parent | e20935c3f2a03779b15ad225ae4616a1d80c2ec5 (diff) | |
download | tracifyjs-74a2f53683e2b8788eadc10762583491e3dbc7ea.tar.gz tracifyjs-74a2f53683e2b8788eadc10762583491e3dbc7ea.zip |
fix escape analysis for `AST_Throw` (#2564)
Diffstat (limited to 'test/compress/reduce_vars.js')
-rw-r--r-- | test/compress/reduce_vars.js | 163 |
1 files changed, 163 insertions, 0 deletions
diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js index 9a66d1cb..df2eb712 100644 --- a/test/compress/reduce_vars.js +++ b/test/compress/reduce_vars.js @@ -4621,3 +4621,166 @@ issue_2560_2: { } expect_stdout: "PASS" } + +issue_2560_3: { + options = { + reduce_funcs: true, + reduce_vars: true, + toplevel: true, + unused: true, + } + input: { + function main() { + var thing = baz(); + if (thing !== (thing = baz())) + console.log("FAIL"); + else + console.log("PASS"); + } + function baz() { + try { + throw foo; + } catch (bar) { + return bar; + } + } + function foo() {} + main(); + } + expect: { + function baz() { + try { + throw foo; + } catch (bar) { + return bar; + } + } + function foo() {} + (function() { + var thing = baz(); + if (thing !== (thing = baz())) + console.log("FAIL"); + else + console.log("PASS"); + })(); + } + expect_stdout: "PASS" +} + +issue_2560_4: { + options = { + reduce_funcs: true, + reduce_vars: true, + toplevel: true, + unused: true, + } + input: { + function main() { + var thing = baz(); + if (thing !== (thing = baz())) + console.log("PASS"); + else + console.log("FAIL"); + } + function baz(s) { + function foo() {} + function bar() {} + return s ? foo : bar; + } + main(); + } + expect: { + function baz(s) { + return s ? function() {} : function() {}; + } + (function() { + var thing = baz(); + if (thing !== (thing = baz())) + console.log("PASS"); + else + console.log("FAIL"); + })(); + } + expect_stdout: "PASS" +} + +issue_2560_5: { + options = { + reduce_funcs: true, + reduce_vars: true, + toplevel: true, + unused: true, + } + input: { + function main() { + var thing = baz(); + if (thing !== (thing = baz())) + console.log("PASS"); + else + console.log("FAIL"); + } + function baz() { + function foo() {} + function bar() {} + return foo, bar; + } + main(); + } + expect: { + function baz() { + return function() {}, function() {}; + } + (function() { + var thing = baz(); + if (thing !== (thing = baz())) + console.log("PASS"); + else + console.log("FAIL"); + })(); + } + expect_stdout: "PASS" +} + +issue_2560_6: { + options = { + reduce_funcs: true, + reduce_vars: true, + toplevel: true, + unused: true, + } + input: { + function main() { + var thing = baz(); + if (thing !== (thing = baz())) + console.log("PASS"); + else + console.log("FAIL"); + } + function baz() { + function foo() {} + try { + throw foo; + } catch (bar) { + return bar; + } + } + main(); + } + expect: { + function baz() { + try { + throw function() {}; + } catch (bar) { + return bar; + } + } + (function() { + var thing = baz(); + if (thing !== (thing = baz())) + console.log("PASS"); + else + console.log("FAIL"); + })(); + } + expect_stdout: "PASS" +} |