update tests
This commit is contained in:
parent
06f17bd0ec
commit
7d8bcc06a1
|
|
@ -270,19 +270,14 @@ collapse_vars_if: {
|
|||
}
|
||||
expect: {
|
||||
function f1() {
|
||||
sideeffect();
|
||||
return "x" != "Bar" + (g1 + g2) / 4 ? g9 : g5;
|
||||
return sideeffect(), "x" != "Bar" + (g1 + g2) / 4 ? g9 : g5;
|
||||
}
|
||||
function f2() {
|
||||
var x = g1 + g2;
|
||||
sideeffect();
|
||||
return "x" != "Bar" + x / 4 ? g9 : g5;
|
||||
return sideeffect(), "x" != "Bar" + x / 4 ? g9 : g5;
|
||||
}
|
||||
function f3(x) {
|
||||
if (x) {
|
||||
return 1;
|
||||
}
|
||||
return 2;
|
||||
return x ? 1 : 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -551,13 +546,11 @@ collapse_vars_switch: {
|
|||
}
|
||||
expect: {
|
||||
function f1() {
|
||||
sideeffect();
|
||||
switch ("Bar" + (g1 + g2) / 4) { case 0: return g9 }
|
||||
switch (sideeffect(), "Bar" + (g1 + g2) / 4) { case 0: return g9 }
|
||||
}
|
||||
function f2() {
|
||||
var x = g1 + g2;
|
||||
sideeffect();
|
||||
switch ("Bar" + x / 4) { case 0: return g9 }
|
||||
switch (sideeffect(), "Bar" + x / 4) { case 0: return g9 }
|
||||
}
|
||||
function f3(x) {
|
||||
// verify no extraneous semicolon in case block before return
|
||||
|
|
@ -698,10 +691,10 @@ collapse_vars_lvalues_drop_assign: {
|
|||
function f3(x) { var a = (x -= 3); return x + a; }
|
||||
function f4(x) { var a = (x -= 3); return x + a; }
|
||||
function f5(x) { var v = (e1(), e2()), c = v = --x; return x - c; }
|
||||
function f6(x) { e1(), e2(); return --x - x; }
|
||||
function f7(x) { var v = (e1(), e2()), c = v - x; return x - c; }
|
||||
function f8(x) { var v = (e1(), e2()); return x - (v - x); }
|
||||
function f9(x) { e1(); return e2() - x - x; }
|
||||
function f6(x) { return e1(), e2(), --x - x; }
|
||||
function f7(x) { return x - (e1(), e2() - x); }
|
||||
function f8(x) { return x - (e1(), e2() - x); }
|
||||
function f9(x) { return e1(), e2() - x - x; }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1142,8 +1135,7 @@ collapse_vars_constants: {
|
|||
}
|
||||
function f3(x) {
|
||||
var b = x.prop;
|
||||
sideeffect1();
|
||||
return b + -9;
|
||||
return sideeffect1(), b + -9;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1193,10 +1185,10 @@ collapse_vars_short_circuit: {
|
|||
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 f0(x) { return foo(), bar() || x; }
|
||||
function f1(x) { return foo(), 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 f3(x) { var a = foo(); return bar(), 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; }
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ ifs_3_should_warn: {
|
|||
evaluate : true,
|
||||
booleans : true,
|
||||
side_effects : true,
|
||||
passes : 3,
|
||||
};
|
||||
input: {
|
||||
var x, y;
|
||||
|
|
@ -98,6 +99,7 @@ ifs_5: {
|
|||
if_return: true,
|
||||
conditionals: true,
|
||||
comparisons: true,
|
||||
passes: 2,
|
||||
};
|
||||
input: {
|
||||
function f() {
|
||||
|
|
@ -187,7 +189,8 @@ cond_1: {
|
|||
|
||||
cond_2: {
|
||||
options = {
|
||||
conditionals: true
|
||||
conditionals: true,
|
||||
passes: 2,
|
||||
};
|
||||
input: {
|
||||
var x, FooBar;
|
||||
|
|
@ -276,6 +279,7 @@ cond_7: {
|
|||
options = {
|
||||
conditionals: true,
|
||||
evaluate : true,
|
||||
passes : 3,
|
||||
side_effects: true,
|
||||
};
|
||||
input: {
|
||||
|
|
@ -338,7 +342,8 @@ cond_7: {
|
|||
cond_7_1: {
|
||||
options = {
|
||||
conditionals: true,
|
||||
evaluate : true
|
||||
evaluate : true,
|
||||
passes : 2,
|
||||
};
|
||||
input: {
|
||||
var x;
|
||||
|
|
@ -359,7 +364,8 @@ cond_8: {
|
|||
options = {
|
||||
conditionals: true,
|
||||
evaluate : true,
|
||||
booleans : false
|
||||
booleans : false,
|
||||
passes : 2,
|
||||
};
|
||||
input: {
|
||||
var a;
|
||||
|
|
@ -443,7 +449,8 @@ cond_8b: {
|
|||
options = {
|
||||
conditionals: true,
|
||||
evaluate : true,
|
||||
booleans : true
|
||||
booleans : true,
|
||||
passes : 2,
|
||||
};
|
||||
input: {
|
||||
var a;
|
||||
|
|
@ -526,7 +533,8 @@ cond_8c: {
|
|||
options = {
|
||||
conditionals: true,
|
||||
evaluate : false,
|
||||
booleans : false
|
||||
booleans : false,
|
||||
passes : 2,
|
||||
};
|
||||
input: {
|
||||
var a;
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ dead_code_constant_boolean_should_warn_more: {
|
|||
conditionals : true,
|
||||
evaluate : true,
|
||||
side_effects : true,
|
||||
passes : 2,
|
||||
};
|
||||
input: {
|
||||
while (!((foo && bar) || (x + "0"))) {
|
||||
|
|
|
|||
|
|
@ -696,7 +696,7 @@ in_boolean_context: {
|
|||
!b("foo"),
|
||||
!b([1, 2]),
|
||||
!b(/foo/),
|
||||
![1, foo()],
|
||||
(foo(), !1),
|
||||
(foo(), !1)
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ iifes_returning_constants_keep_fargs_true: {
|
|||
console.log(void 0);
|
||||
console.log(2);
|
||||
console.log(6);
|
||||
console.log((0, a(), b(), 6));
|
||||
console.log((a(), b(), 6));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ mixed: {
|
|||
}
|
||||
expect_warnings: [
|
||||
'WARN: global_defs CONFIG.VALUE redefined [test/compress/global_defs.js:126,22]',
|
||||
'WARN: global_defs CONFIG.VALUE redefined [test/compress/global_defs.js:127,22]',
|
||||
'WARN: global_defs CONFIG.VALUE redefined [test/compress/global_defs.js:129,8]',
|
||||
'WARN: global_defs CONFIG.VALUE redefined [test/compress/global_defs.js:127,22]',
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -152,25 +152,25 @@ should_warn: {
|
|||
"WARN: Dropping __PURE__ call [test/compress/issue-1261.js:128,23]",
|
||||
"WARN: Dropping side-effect-free statement [test/compress/issue-1261.js:128,23]",
|
||||
"WARN: Boolean || always true [test/compress/issue-1261.js:129,23]",
|
||||
"WARN: Dropping __PURE__ call [test/compress/issue-1261.js:129,23]",
|
||||
"WARN: Condition always true [test/compress/issue-1261.js:129,23]",
|
||||
"WARN: Boolean || always true [test/compress/issue-1261.js:130,8]",
|
||||
"WARN: Condition always true [test/compress/issue-1261.js:130,8]",
|
||||
"WARN: Boolean && always false [test/compress/issue-1261.js:131,23]",
|
||||
"WARN: Dropping __PURE__ call [test/compress/issue-1261.js:131,23]",
|
||||
"WARN: Condition always false [test/compress/issue-1261.js:131,23]",
|
||||
"WARN: Boolean && always false [test/compress/issue-1261.js:132,8]",
|
||||
"WARN: Condition always false [test/compress/issue-1261.js:132,8]",
|
||||
"WARN: + in boolean context always true [test/compress/issue-1261.js:133,23]",
|
||||
"WARN: Dropping __PURE__ call [test/compress/issue-1261.js:133,23]",
|
||||
"WARN: Condition always true [test/compress/issue-1261.js:133,23]",
|
||||
"WARN: + in boolean context always true [test/compress/issue-1261.js:134,8]",
|
||||
"WARN: Dropping __PURE__ call [test/compress/issue-1261.js:134,31]",
|
||||
"WARN: Condition always true [test/compress/issue-1261.js:134,8]",
|
||||
"WARN: Dropping __PURE__ call [test/compress/issue-1261.js:135,23]",
|
||||
"WARN: Dropping __PURE__ call [test/compress/issue-1261.js:136,24]",
|
||||
"WARN: Condition always true [test/compress/issue-1261.js:136,8]",
|
||||
"WARN: Dropping __PURE__ call [test/compress/issue-1261.js:137,31]",
|
||||
"WARN: Condition always false [test/compress/issue-1261.js:137,8]",
|
||||
"WARN: Condition always true [test/compress/issue-1261.js:129,23]",
|
||||
"WARN: Dropping __PURE__ call [test/compress/issue-1261.js:129,23]",
|
||||
"WARN: Condition always true [test/compress/issue-1261.js:130,8]",
|
||||
"WARN: Condition always false [test/compress/issue-1261.js:131,23]",
|
||||
"WARN: Dropping __PURE__ call [test/compress/issue-1261.js:131,23]",
|
||||
"WARN: Condition always false [test/compress/issue-1261.js:132,8]",
|
||||
"WARN: Condition always true [test/compress/issue-1261.js:133,23]",
|
||||
"WARN: Dropping __PURE__ call [test/compress/issue-1261.js:133,23]",
|
||||
"WARN: Condition always true [test/compress/issue-1261.js:134,8]",
|
||||
"WARN: Dropping __PURE__ call [test/compress/issue-1261.js:134,31]",
|
||||
"WARN: Dropping __PURE__ call [test/compress/issue-1261.js:135,23]",
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
inner_reference: {
|
||||
options = {
|
||||
passes: 2,
|
||||
side_effects: true,
|
||||
}
|
||||
input: {
|
||||
|
|
@ -14,6 +15,5 @@ inner_reference: {
|
|||
!function f(a) {
|
||||
return a && f(a - 1) + a;
|
||||
}(42);
|
||||
!void 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ wrongly_optimized: {
|
|||
options = {
|
||||
conditionals: true,
|
||||
booleans: true,
|
||||
evaluate: true
|
||||
evaluate: true,
|
||||
sequences: true,
|
||||
passes: 2,
|
||||
};
|
||||
input: {
|
||||
function func() {
|
||||
|
|
@ -16,7 +18,6 @@ wrongly_optimized: {
|
|||
function func() {
|
||||
foo();
|
||||
}
|
||||
// TODO: optimize to `func(), bar()`
|
||||
(func(), 0) || bar();
|
||||
func(), bar();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -381,6 +381,7 @@ issue_1288_side_effects: {
|
|||
conditionals: true,
|
||||
negate_iife: true,
|
||||
side_effects: true,
|
||||
passes: 2,
|
||||
}
|
||||
input: {
|
||||
if (w) ;
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ comparisons: {
|
|||
evaluate_1: {
|
||||
options = {
|
||||
evaluate: true,
|
||||
passes: 2,
|
||||
unsafe_math: false,
|
||||
}
|
||||
input: {
|
||||
|
|
@ -78,6 +79,7 @@ evaluate_1: {
|
|||
evaluate_2: {
|
||||
options = {
|
||||
evaluate: true,
|
||||
passes: 2,
|
||||
unsafe_math: true,
|
||||
}
|
||||
input: {
|
||||
|
|
@ -98,7 +100,7 @@ evaluate_2: {
|
|||
console.log(
|
||||
x + 1 + 2,
|
||||
2 * x,
|
||||
3 + +x,
|
||||
+x + 3,
|
||||
1 + x + 2 + 3,
|
||||
3 | x,
|
||||
6 + x--,
|
||||
|
|
@ -120,7 +122,7 @@ evaluate_3: {
|
|||
console.log(1 + Number(x) + 2);
|
||||
}
|
||||
expect: {
|
||||
console.log(3 + +x);
|
||||
console.log(+x + 3);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -53,9 +53,7 @@ reduce_vars: {
|
|||
console.log(-3);
|
||||
eval("console.log(a);");
|
||||
})(eval);
|
||||
(function() {
|
||||
return "yes";
|
||||
})();
|
||||
"yes";
|
||||
console.log(2);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,10 +50,71 @@ condition_evaluate: {
|
|||
}
|
||||
}
|
||||
|
||||
if_else_empty_1: {
|
||||
options = {
|
||||
conditionals: true,
|
||||
}
|
||||
input: {
|
||||
if ({} ? a : b); else {}
|
||||
}
|
||||
expect: {
|
||||
!{} ? b : a;
|
||||
}
|
||||
}
|
||||
|
||||
if_else_empty_2: {
|
||||
options = {
|
||||
conditionals: true,
|
||||
passes: 2,
|
||||
}
|
||||
input: {
|
||||
if ({} ? a : b); else {}
|
||||
}
|
||||
expect: {
|
||||
!{} ? b : a;
|
||||
}
|
||||
}
|
||||
|
||||
label_if_break_1: {
|
||||
options = {
|
||||
conditionals: true,
|
||||
dead_code: true,
|
||||
evaluate: true,
|
||||
}
|
||||
input: {
|
||||
L: if (true) {
|
||||
a;
|
||||
break L;
|
||||
}
|
||||
}
|
||||
expect: {
|
||||
a;
|
||||
}
|
||||
}
|
||||
|
||||
label_if_break_2: {
|
||||
options = {
|
||||
conditionals: true,
|
||||
dead_code: true,
|
||||
evaluate: true,
|
||||
passes: 2
|
||||
}
|
||||
input: {
|
||||
L: if (true) {
|
||||
a;
|
||||
break L;
|
||||
}
|
||||
}
|
||||
expect: {
|
||||
a;
|
||||
}
|
||||
}
|
||||
|
||||
while_if_break: {
|
||||
options = {
|
||||
conditionals: true,
|
||||
loops: true,
|
||||
passes: 2,
|
||||
sequences: true,
|
||||
}
|
||||
input: {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ var uglify = require("../../");
|
|||
|
||||
describe("spidermonkey export/import sanity test", function() {
|
||||
it("should produce a functional build when using --self with spidermonkey", function (done) {
|
||||
this.timeout(20000);
|
||||
this.timeout(60000);
|
||||
|
||||
var uglifyjs = '"' + process.argv[0] + '" bin/uglifyjs';
|
||||
var command = uglifyjs + " --self -cm --wrap SpiderUglify --dump-spidermonkey-ast | " +
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user