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