aboutsummaryrefslogtreecommitdiff
path: root/test/compress
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-12-08 01:50:38 +0800
committerGitHub <noreply@github.com>2017-12-08 01:50:38 +0800
commite20935c3f2a03779b15ad225ae4616a1d80c2ec5 (patch)
tree116ddfd714d75af3ed0ebfdd7015448f11200935 /test/compress
parent3e34f62a1c48ab45db34cfb08d8dd2118c5780f0 (diff)
downloadtracifyjs-e20935c3f2a03779b15ad225ae4616a1d80c2ec5.tar.gz
tracifyjs-e20935c3f2a03779b15ad225ae4616a1d80c2ec5.zip
fix escape analysis for `AST_Conditional` & `AST_Sequence` (#2563)
fixes #2560
Diffstat (limited to 'test/compress')
-rw-r--r--test/compress/reduce_vars.js77
1 files changed, 77 insertions, 0 deletions
diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js
index 4a098f78..9a66d1cb 100644
--- a/test/compress/reduce_vars.js
+++ b/test/compress/reduce_vars.js
@@ -4544,3 +4544,80 @@ issue_2455: {
}
}
}
+
+issue_2560_1: {
+ 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(s) {
+ return s ? foo : bar;
+ }
+ function foo() {}
+ function bar() {}
+ main();
+ }
+ expect: {
+ function baz(s) {
+ return s ? foo : bar;
+ }
+ function foo() {}
+ function bar() {}
+ (function() {
+ var thing = baz();
+ if (thing !== (thing = baz()))
+ console.log("FAIL");
+ else
+ console.log("PASS");
+ })();
+ }
+ expect_stdout: "PASS"
+}
+
+issue_2560_2: {
+ 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() {
+ return foo, bar;
+ }
+ function foo() {}
+ function bar() {}
+ main();
+ }
+ expect: {
+ function baz() {
+ return function() {}, bar;
+ }
+ function bar() {}
+ (function() {
+ var thing = baz();
+ if (thing !== (thing = baz()))
+ console.log("FAIL");
+ else
+ console.log("PASS");
+ })();
+ }
+ expect_stdout: "PASS"
+}