aboutsummaryrefslogtreecommitdiff
path: root/test/compress/collapse_vars.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/compress/collapse_vars.js')
-rw-r--r--test/compress/collapse_vars.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js
index e0235972..f67b3f47 100644
--- a/test/compress/collapse_vars.js
+++ b/test/compress/collapse_vars.js
@@ -1045,3 +1045,45 @@ collapse_vars_arguments: {
}
}
+collapse_vars_short_circuit: {
+ options = {
+ collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true,
+ comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true,
+ keep_fargs:true, if_return:true, join_vars:true, cascade:true, side_effects:true
+ }
+ input: {
+ function f0(x) { var a = foo(), b = bar(); return b || x; }
+ function f1(x) { var a = foo(), b = bar(); return b && x; }
+ function f2(x) { var a = foo(), b = bar(); return x && a && b; }
+ function f3(x) { var a = foo(), b = bar(); return a && x; }
+ function f4(x) { var a = foo(), b = bar(); return a && x && b; }
+ function f5(x) { var a = foo(), b = bar(); return x || a || b; }
+ function f6(x) { var a = foo(), b = bar(); return a || x || b; }
+ function f7(x) { var a = foo(), b = bar(); return a && b && x; }
+ function f8(x,y) { var a = foo(), b = bar(); return (x || a) && (y || b); }
+ function f9(x,y) { var a = foo(), b = bar(); return (x && a) || (y && b); }
+ function f10(x,y) { var a = foo(), b = bar(); return (x - a) || (y - b); }
+ function f11(x,y) { var a = foo(), b = bar(); return (x - b) || (y - a); }
+ function f12(x,y) { var a = foo(), b = bar(); return (x - y) || (b - a); }
+ function f13(x,y) { var a = foo(), b = bar(); return (a - b) || (x - y); }
+ function f14(x,y) { var a = foo(), b = bar(); return (b - a) || (x - y); }
+ }
+ expect: {
+ function f0(x) { foo(); return bar() || x; }
+ function f1(x) { foo(); return bar() && x; }
+ function f2(x) { var a = foo(), b = bar(); return x && a && b; }
+ function f3(x) { var a = foo(); bar(); return a && x; }
+ function f4(x) { var a = foo(), b = bar(); return a && x && b; }
+ function f5(x) { var a = foo(), b = bar(); return x || a || b; }
+ function f6(x) { var a = foo(), b = bar(); return a || x || b; }
+ function f7(x) { var a = foo(), b = bar(); return a && b && x; }
+ function f8(x,y) { var a = foo(), b = bar(); return (x || a) && (y || b); }
+ function f9(x,y) { var a = foo(), b = bar(); return (x && a) || (y && b); }
+ function f10(x,y) { var a = foo(), b = bar(); return (x - a) || (y - b); }
+ function f11(x,y) { var a = foo(); return (x - bar()) || (y - a); }
+ function f12(x,y) { var a = foo(), b = bar(); return (x - y) || (b - a); }
+ function f13(x,y) { return (foo() - bar()) || (x - y); }
+ function f14(x,y) { var a = foo(); return (bar() - a) || (x - y); }
+ }
+}
+