Merge branch 'master' into harmony
This commit is contained in:
@@ -1487,6 +1487,7 @@ issue_1605_1: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
toplevel: false,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
function foo(x) {
|
||||
@@ -1509,6 +1510,7 @@ issue_1605_2: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
toplevel: "vars",
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
function foo(x) {
|
||||
@@ -1636,6 +1638,7 @@ issue_1631_3: {
|
||||
var_side_effects_1: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
var print = console.log.bind(console);
|
||||
@@ -1658,6 +1661,7 @@ var_side_effects_1: {
|
||||
var_side_effects_2: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
var print = console.log.bind(console);
|
||||
@@ -1683,6 +1687,7 @@ var_side_effects_3: {
|
||||
collapse_vars: true,
|
||||
pure_getters: true,
|
||||
unsafe: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
var print = console.log.bind(console);
|
||||
@@ -1758,6 +1763,7 @@ iife_2: {
|
||||
}(foo);
|
||||
}
|
||||
expect: {
|
||||
var foo;
|
||||
!function(x) {
|
||||
console.log(x);
|
||||
}(bar());
|
||||
@@ -2044,6 +2050,7 @@ ref_scope: {
|
||||
chained_1: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
var a = 2;
|
||||
@@ -2060,6 +2067,7 @@ chained_1: {
|
||||
chained_2: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
var a;
|
||||
@@ -2160,6 +2168,7 @@ inner_lvalues: {
|
||||
double_def: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
var a = x, a = a && y;
|
||||
@@ -2174,6 +2183,7 @@ double_def: {
|
||||
toplevel_single_reference: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
var a;
|
||||
@@ -2183,9 +2193,10 @@ toplevel_single_reference: {
|
||||
}
|
||||
}
|
||||
expect: {
|
||||
var a;
|
||||
for (var b in x)
|
||||
for (var b in x) {
|
||||
var a;
|
||||
b(a = b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3163,6 +3174,7 @@ pure_getters_chain: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
pure_getters: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
function o(t, r) {
|
||||
@@ -3183,6 +3195,7 @@ pure_getters_chain: {
|
||||
conditional_1: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
function f(a, b) {
|
||||
@@ -3207,6 +3220,7 @@ conditional_1: {
|
||||
conditional_2: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
function f(a, b) {
|
||||
@@ -3289,3 +3303,51 @@ issue_2425_3: {
|
||||
}
|
||||
expect_stdout: "15"
|
||||
}
|
||||
|
||||
issue_2437: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
conditionals: true,
|
||||
inline: true,
|
||||
join_vars: true,
|
||||
reduce_vars: true,
|
||||
side_effects: true,
|
||||
sequences: true,
|
||||
toplevel: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
function foo() {
|
||||
bar();
|
||||
}
|
||||
function bar() {
|
||||
if (xhrDesc) {
|
||||
var req = new XMLHttpRequest();
|
||||
var result = !!req.onreadystatechange;
|
||||
Object.defineProperty(XMLHttpRequest.prototype, 'onreadystatechange', xhrDesc || {});
|
||||
return result;
|
||||
}
|
||||
else {
|
||||
var req = new XMLHttpRequest();
|
||||
var detectFunc = function () { };
|
||||
req.onreadystatechange = detectFunc;
|
||||
var result = req[SYMBOL_FAKE_ONREADYSTATECHANGE_1] === detectFunc;
|
||||
req.onreadystatechange = null;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
foo();
|
||||
}
|
||||
expect: {
|
||||
!function() {
|
||||
if (xhrDesc)
|
||||
return result = !!(req = new XMLHttpRequest()).onreadystatechange,
|
||||
Object.defineProperty(XMLHttpRequest.prototype, "onreadystatechange", xhrDesc || {}),
|
||||
result;
|
||||
var req = new XMLHttpRequest(), detectFunc = function() {};
|
||||
req.onreadystatechange = detectFunc;
|
||||
var result = req[SYMBOL_FAKE_ONREADYSTATECHANGE_1] === detectFunc;
|
||||
req.onreadystatechange = null;
|
||||
}();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -508,3 +508,41 @@ issue_2114_2: {
|
||||
}
|
||||
expect_stdout: "2"
|
||||
}
|
||||
|
||||
issue_2428: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
inline: true,
|
||||
passes: 2,
|
||||
pure_getters: "strict",
|
||||
reduce_vars: true,
|
||||
side_effects: true,
|
||||
toplevel: true,
|
||||
unsafe: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
function bar(k) {
|
||||
console.log(k);
|
||||
}
|
||||
function foo(x) {
|
||||
return bar(x);
|
||||
}
|
||||
function baz(a) {
|
||||
foo(a);
|
||||
}
|
||||
baz(42);
|
||||
baz("PASS");
|
||||
}
|
||||
expect: {
|
||||
function baz(a) {
|
||||
console.log(a);
|
||||
}
|
||||
baz(42);
|
||||
baz("PASS");
|
||||
}
|
||||
expect_stdout: [
|
||||
"42",
|
||||
"PASS",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ this_binding_collapse_vars: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
toplevel: true,
|
||||
unused: true,
|
||||
};
|
||||
input: {
|
||||
var c = a; c();
|
||||
|
||||
@@ -2131,14 +2131,13 @@ redefine_farg_1: {
|
||||
}
|
||||
expect: {
|
||||
function f(a) {
|
||||
var a;
|
||||
return typeof a;
|
||||
}
|
||||
function g() {
|
||||
return"number";
|
||||
return "number";
|
||||
}
|
||||
function h(a, b) {
|
||||
var a = b;
|
||||
a = b;
|
||||
return typeof a;
|
||||
}
|
||||
console.log(f([]), g([]), h([]));
|
||||
@@ -2173,10 +2172,9 @@ redefine_farg_2: {
|
||||
}
|
||||
expect: {
|
||||
console.log(function(a) {
|
||||
var a;
|
||||
return typeof a;
|
||||
}([]), "number",function(a, b) {
|
||||
var a = b;
|
||||
a = b;
|
||||
return typeof a;
|
||||
}([]));
|
||||
}
|
||||
@@ -2185,11 +2183,13 @@ redefine_farg_2: {
|
||||
|
||||
redefine_farg_3: {
|
||||
options = {
|
||||
cascade: true,
|
||||
evaluate: true,
|
||||
inline: true,
|
||||
keep_fargs: false,
|
||||
passes: 3,
|
||||
passes: 2,
|
||||
reduce_vars: true,
|
||||
sequences: true,
|
||||
side_effects: true,
|
||||
toplevel: true,
|
||||
unused: true,
|
||||
@@ -3827,3 +3827,306 @@ issue_2423_6: {
|
||||
"2",
|
||||
]
|
||||
}
|
||||
|
||||
issue_2440_eval_1: {
|
||||
options = {
|
||||
reduce_vars: true,
|
||||
toplevel: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
function foo() {
|
||||
return bar();
|
||||
}
|
||||
baz = {
|
||||
quux: foo
|
||||
};
|
||||
exec = function() {
|
||||
return eval("foo()");
|
||||
};
|
||||
}
|
||||
expect: {
|
||||
function foo() {
|
||||
return bar();
|
||||
}
|
||||
baz = {
|
||||
quux: foo
|
||||
};
|
||||
exec = function() {
|
||||
return eval("foo()");
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
issue_2440_eval_2: {
|
||||
options = {
|
||||
reduce_vars: true,
|
||||
toplevel: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
baz = {
|
||||
quux: foo
|
||||
};
|
||||
exec = function() {
|
||||
return eval("foo()");
|
||||
};
|
||||
function foo() {
|
||||
return bar();
|
||||
}
|
||||
}
|
||||
expect: {
|
||||
baz = {
|
||||
quux: foo
|
||||
};
|
||||
exec = function() {
|
||||
return eval("foo()");
|
||||
};
|
||||
function foo() {
|
||||
return bar();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
issue_2440_with_1: {
|
||||
options = {
|
||||
reduce_vars: true,
|
||||
toplevel: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
function foo() {
|
||||
return bar();
|
||||
}
|
||||
baz = {
|
||||
quux: foo
|
||||
};
|
||||
with (o) whatever();
|
||||
}
|
||||
expect: {
|
||||
function foo() {
|
||||
return bar();
|
||||
}
|
||||
baz = {
|
||||
quux: foo
|
||||
};
|
||||
with (o) whatever();
|
||||
}
|
||||
}
|
||||
|
||||
issue_2440_with_2: {
|
||||
options = {
|
||||
reduce_vars: true,
|
||||
toplevel: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
baz = {
|
||||
quux: foo
|
||||
};
|
||||
with (o) whatever();
|
||||
function foo() {
|
||||
return bar();
|
||||
}
|
||||
}
|
||||
expect: {
|
||||
baz = {
|
||||
quux: foo
|
||||
};
|
||||
with (o) whatever();
|
||||
function foo() {
|
||||
return bar();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
issue_2442: {
|
||||
options = {
|
||||
reduce_vars: true,
|
||||
toplevel: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
function foo() {
|
||||
foo();
|
||||
}
|
||||
}
|
||||
expect: {}
|
||||
}
|
||||
|
||||
recursive_inlining_1: {
|
||||
options = {
|
||||
reduce_vars: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
!function() {
|
||||
function foo() { bar(); }
|
||||
function bar() { foo(); }
|
||||
console.log("PASS");
|
||||
}();
|
||||
}
|
||||
expect: {
|
||||
!function() {
|
||||
console.log("PASS");
|
||||
}();
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
}
|
||||
|
||||
recursive_inlining_2: {
|
||||
options = {
|
||||
reduce_vars: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
!function() {
|
||||
function foo() { qux(); }
|
||||
function bar() { foo(); }
|
||||
function qux() { bar(); }
|
||||
console.log("PASS");
|
||||
}();
|
||||
}
|
||||
expect: {
|
||||
!function() {
|
||||
console.log("PASS");
|
||||
}();
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
}
|
||||
|
||||
recursive_inlining_3: {
|
||||
options = {
|
||||
reduce_vars: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
!function() {
|
||||
function foo(x) { console.log("foo", x); if (x) bar(x-1); }
|
||||
function bar(x) { console.log("bar", x); if (x) qux(x-1); }
|
||||
function qux(x) { console.log("qux", x); if (x) foo(x-1); }
|
||||
qux(4);
|
||||
}();
|
||||
}
|
||||
expect: {
|
||||
!function() {
|
||||
function qux(x) {
|
||||
console.log("qux", x);
|
||||
if (x) (function(x) {
|
||||
console.log("foo", x);
|
||||
if (x) (function(x) {
|
||||
console.log("bar", x);
|
||||
if (x) qux(x - 1);
|
||||
})(x - 1);
|
||||
})(x - 1);
|
||||
}
|
||||
qux(4);
|
||||
}();
|
||||
}
|
||||
expect_stdout: [
|
||||
"qux 4",
|
||||
"foo 3",
|
||||
"bar 2",
|
||||
"qux 1",
|
||||
"foo 0",
|
||||
]
|
||||
}
|
||||
|
||||
recursive_inlining_4: {
|
||||
options = {
|
||||
reduce_vars: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
!function() {
|
||||
function foo(x) { console.log("foo", x); if (x) bar(x-1); }
|
||||
function bar(x) { console.log("bar", x); if (x) qux(x-1); }
|
||||
function qux(x) { console.log("qux", x); if (x) foo(x-1); }
|
||||
qux(4);
|
||||
bar(5);
|
||||
}();
|
||||
}
|
||||
expect: {
|
||||
!function() {
|
||||
function bar(x) {
|
||||
console.log("bar", x);
|
||||
if (x) qux(x - 1);
|
||||
}
|
||||
function qux(x) {
|
||||
console.log("qux", x);
|
||||
if (x) (function(x) {
|
||||
console.log("foo", x);
|
||||
if (x) bar(x - 1);
|
||||
})(x - 1);
|
||||
}
|
||||
qux(4);
|
||||
bar(5);
|
||||
}();
|
||||
}
|
||||
expect_stdout: [
|
||||
"qux 4",
|
||||
"foo 3",
|
||||
"bar 2",
|
||||
"qux 1",
|
||||
"foo 0",
|
||||
"bar 5",
|
||||
"qux 4",
|
||||
"foo 3",
|
||||
"bar 2",
|
||||
"qux 1",
|
||||
"foo 0",
|
||||
]
|
||||
}
|
||||
|
||||
recursive_inlining_5: {
|
||||
options = {
|
||||
reduce_vars: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
!function() {
|
||||
function foo(x) { console.log("foo", x); if (x) bar(x-1); }
|
||||
function bar(x) { console.log("bar", x); if (x) qux(x-1); }
|
||||
function qux(x) { console.log("qux", x); if (x) foo(x-1); }
|
||||
qux(4);
|
||||
bar(5);
|
||||
foo(3);
|
||||
}();
|
||||
}
|
||||
expect: {
|
||||
!function() {
|
||||
function foo(x) {
|
||||
console.log("foo", x);
|
||||
if (x) bar(x - 1);
|
||||
}
|
||||
function bar(x) {
|
||||
console.log("bar", x);
|
||||
if (x) qux(x - 1);
|
||||
}
|
||||
function qux(x) {
|
||||
console.log("qux", x);
|
||||
if (x) foo(x - 1);
|
||||
}
|
||||
qux(4);
|
||||
bar(5);
|
||||
foo(3);
|
||||
}();
|
||||
}
|
||||
expect_stdout: [
|
||||
"qux 4",
|
||||
"foo 3",
|
||||
"bar 2",
|
||||
"qux 1",
|
||||
"foo 0",
|
||||
"bar 5",
|
||||
"qux 4",
|
||||
"foo 3",
|
||||
"bar 2",
|
||||
"qux 1",
|
||||
"foo 0",
|
||||
"foo 3",
|
||||
"bar 2",
|
||||
"qux 1",
|
||||
"foo 0",
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user