@@ -19,11 +19,11 @@ merge: {
|
||||
expect: {
|
||||
var a = "foo";
|
||||
console.log(a);
|
||||
function f(c) {
|
||||
var c;
|
||||
console.log(c);
|
||||
c = "bar";
|
||||
console.log(c);
|
||||
function f(b) {
|
||||
var b;
|
||||
console.log(b);
|
||||
b = "bar";
|
||||
console.log(b);
|
||||
}
|
||||
f("baz");
|
||||
var d = "moo";
|
||||
@@ -56,17 +56,17 @@ merge_toplevel: {
|
||||
console.log(d);
|
||||
}
|
||||
expect: {
|
||||
var d = "foo";
|
||||
console.log(d);
|
||||
function f(c) {
|
||||
var c;
|
||||
console.log(c);
|
||||
c = "bar";
|
||||
console.log(c);
|
||||
var a = "foo";
|
||||
console.log(a);
|
||||
function f(b) {
|
||||
var b;
|
||||
console.log(b);
|
||||
b = "bar";
|
||||
console.log(b);
|
||||
}
|
||||
f("baz");
|
||||
var d = "moo";
|
||||
console.log(d);
|
||||
var a = "moo";
|
||||
console.log(a);
|
||||
}
|
||||
expect_stdout: [
|
||||
"foo",
|
||||
@@ -94,16 +94,16 @@ segment: {
|
||||
console.log(d);
|
||||
}
|
||||
expect: {
|
||||
var d = "foo";
|
||||
console.log(d);
|
||||
for (var c, i = 0; i < 1; i++) {
|
||||
var c = "bar";
|
||||
console.log(c);
|
||||
c = "baz";
|
||||
console.log(c);
|
||||
var a = "foo";
|
||||
console.log(a);
|
||||
for (var b, i = 0; i < 1; i++) {
|
||||
var b = "bar";
|
||||
console.log(b);
|
||||
b = "baz";
|
||||
console.log(b);
|
||||
}
|
||||
var d = "moo";
|
||||
console.log(d);
|
||||
var a = "moo";
|
||||
console.log(a);
|
||||
}
|
||||
expect_stdout: [
|
||||
"foo",
|
||||
@@ -298,6 +298,89 @@ read_before_assign_2: {
|
||||
expect_stdout: "PASS"
|
||||
}
|
||||
|
||||
collapse_vars_1: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
merge_vars: true,
|
||||
toplevel: true,
|
||||
}
|
||||
input: {
|
||||
var a = a && a.p;
|
||||
var b = "PASS";
|
||||
var b = b && console.log(b);
|
||||
}
|
||||
expect: {
|
||||
var a = a && a.p;
|
||||
var a;
|
||||
var a = (a = "PASS") && console.log(a);
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
}
|
||||
|
||||
collapse_vars_2: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
merge_vars: true,
|
||||
}
|
||||
input: {
|
||||
"use strict";
|
||||
var log = console.log;
|
||||
(function g(a) {
|
||||
var b = a;
|
||||
var c = Math.random();
|
||||
var c = b;
|
||||
log(c);
|
||||
return c;
|
||||
})("PASS");
|
||||
}
|
||||
expect: {
|
||||
"use strict";
|
||||
var log = console.log;
|
||||
(function g(a) {
|
||||
var a = a;
|
||||
var c = Math.random();
|
||||
var c;
|
||||
log(c = a);
|
||||
return c;
|
||||
})("PASS");
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
}
|
||||
|
||||
not_redefined: {
|
||||
options = {
|
||||
inline: true,
|
||||
join_vars: true,
|
||||
merge_vars: true,
|
||||
reduce_vars: true,
|
||||
unused: true,
|
||||
varify: true,
|
||||
}
|
||||
input: {
|
||||
var log = console.log;
|
||||
(function() {
|
||||
return f("PASS");
|
||||
function f(a) {
|
||||
const b = a;
|
||||
const c = log(b);
|
||||
const d = log;
|
||||
c && log(d);
|
||||
}
|
||||
})();
|
||||
}
|
||||
expect: {
|
||||
var log = console.log;
|
||||
(function() {
|
||||
return a = "PASS",
|
||||
a = log(a),
|
||||
d = log,
|
||||
void (a && log(d));
|
||||
var a, d;
|
||||
})();
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
}
|
||||
|
||||
issue_4103: {
|
||||
options = {
|
||||
merge_vars: true,
|
||||
@@ -325,7 +408,7 @@ issue_4103: {
|
||||
]
|
||||
}
|
||||
|
||||
issue_4107: {
|
||||
issue_4107_1: {
|
||||
options = {
|
||||
keep_fargs: false,
|
||||
merge_vars: true,
|
||||
@@ -342,6 +425,38 @@ issue_4107: {
|
||||
})();
|
||||
console.log(typeof a);
|
||||
}
|
||||
expect: {
|
||||
(function() {
|
||||
(function(c) {
|
||||
c = console || c;
|
||||
console.log(typeof c);
|
||||
})();
|
||||
})();
|
||||
console.log(typeof a);
|
||||
}
|
||||
expect_stdout: [
|
||||
"object",
|
||||
"undefined",
|
||||
]
|
||||
}
|
||||
|
||||
issue_4107_2: {
|
||||
options = {
|
||||
keep_fargs: false,
|
||||
merge_vars: true,
|
||||
reduce_vars: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
(function() {
|
||||
function f(b, b, a) {
|
||||
var d = 1 && c, c = console || a;
|
||||
console.log(typeof c);
|
||||
}
|
||||
f();
|
||||
})();
|
||||
console.log(typeof a);
|
||||
}
|
||||
expect: {
|
||||
(function() {
|
||||
(function(a) {
|
||||
@@ -538,12 +653,12 @@ cross_branch_1_1: {
|
||||
expect: {
|
||||
var a;
|
||||
function f() {
|
||||
var y, y;
|
||||
var x, x;
|
||||
if (a)
|
||||
y = "foo";
|
||||
console.log(y);
|
||||
y = "bar";
|
||||
console.log(y);
|
||||
x = "foo";
|
||||
console.log(x);
|
||||
x = "bar";
|
||||
console.log(x);
|
||||
}
|
||||
a = 0;
|
||||
f();
|
||||
@@ -581,13 +696,13 @@ cross_branch_1_2: {
|
||||
expect: {
|
||||
var a;
|
||||
function f() {
|
||||
var y, y;
|
||||
var x, x;
|
||||
if (a) {
|
||||
y = "foo";
|
||||
console.log(y);
|
||||
x = "foo";
|
||||
console.log(x);
|
||||
}
|
||||
y = "bar";
|
||||
console.log(y);
|
||||
x = "bar";
|
||||
console.log(x);
|
||||
}
|
||||
a = 0;
|
||||
f();
|
||||
@@ -624,13 +739,13 @@ cross_branch_1_3: {
|
||||
expect: {
|
||||
var a;
|
||||
function f() {
|
||||
var y, y;
|
||||
var x, x;
|
||||
if (a) {
|
||||
y = "foo";
|
||||
console.log(y);
|
||||
y = "bar";
|
||||
x = "foo";
|
||||
console.log(x);
|
||||
x = "bar";
|
||||
}
|
||||
console.log(y);
|
||||
console.log(x);
|
||||
}
|
||||
a = 0;
|
||||
f();
|
||||
@@ -666,12 +781,12 @@ cross_branch_1_4: {
|
||||
expect: {
|
||||
var a;
|
||||
function f() {
|
||||
var y, y;
|
||||
y = "foo";
|
||||
var x, x;
|
||||
x = "foo";
|
||||
if (a)
|
||||
console.log(y);
|
||||
y = "bar";
|
||||
console.log(y);
|
||||
console.log(x);
|
||||
x = "bar";
|
||||
console.log(x);
|
||||
}
|
||||
a = 0;
|
||||
f();
|
||||
@@ -751,12 +866,12 @@ cross_branch_1_6: {
|
||||
expect: {
|
||||
var a;
|
||||
function f() {
|
||||
var y, y;
|
||||
y = "foo";
|
||||
var x, x;
|
||||
x = "foo";
|
||||
if (a) {
|
||||
console.log(y);
|
||||
y = "bar";
|
||||
console.log(y);
|
||||
console.log(x);
|
||||
x = "bar";
|
||||
console.log(x);
|
||||
}
|
||||
}
|
||||
a = 0;
|
||||
@@ -835,12 +950,12 @@ cross_branch_1_8: {
|
||||
expect: {
|
||||
var a;
|
||||
function f() {
|
||||
var y, y;
|
||||
y = "foo";
|
||||
console.log(y);
|
||||
var x, x;
|
||||
x = "foo";
|
||||
console.log(x);
|
||||
if (a) {
|
||||
y = "bar";
|
||||
console.log(y);
|
||||
x = "bar";
|
||||
console.log(x);
|
||||
}
|
||||
}
|
||||
a = 0;
|
||||
@@ -877,12 +992,12 @@ cross_branch_1_9: {
|
||||
expect: {
|
||||
var a;
|
||||
function f() {
|
||||
var y, y;
|
||||
y = "foo";
|
||||
console.log(y);
|
||||
y = "bar";
|
||||
var x, x;
|
||||
x = "foo";
|
||||
console.log(x);
|
||||
x = "bar";
|
||||
if (a)
|
||||
console.log(y);
|
||||
console.log(x);
|
||||
}
|
||||
a = 0;
|
||||
f();
|
||||
@@ -924,14 +1039,14 @@ cross_branch_2a_1: {
|
||||
expect: {
|
||||
var a, b;
|
||||
function f() {
|
||||
var y, y;
|
||||
var x, x;
|
||||
if (a) {
|
||||
if (b)
|
||||
y = "foo";
|
||||
console.log(y);
|
||||
x = "foo";
|
||||
console.log(x);
|
||||
}
|
||||
y = "bar";
|
||||
console.log(y);
|
||||
x = "bar";
|
||||
console.log(x);
|
||||
}
|
||||
a = 0, b = 0;
|
||||
f();
|
||||
@@ -980,14 +1095,14 @@ cross_branch_2a_2: {
|
||||
expect: {
|
||||
var a, b;
|
||||
function f() {
|
||||
var y, y;
|
||||
var x, x;
|
||||
if (a) {
|
||||
y = "foo";
|
||||
x = "foo";
|
||||
if (b)
|
||||
console.log(y);
|
||||
console.log(x);
|
||||
}
|
||||
y = "bar";
|
||||
console.log(y);
|
||||
x = "bar";
|
||||
console.log(x);
|
||||
}
|
||||
a = 0, b = 0;
|
||||
f();
|
||||
@@ -1035,14 +1150,14 @@ cross_branch_2a_3: {
|
||||
expect: {
|
||||
var a, b;
|
||||
function f() {
|
||||
var y, y;
|
||||
var x, x;
|
||||
if (a) {
|
||||
if (b)
|
||||
y = "foo";
|
||||
console.log(y);
|
||||
y = "bar";
|
||||
x = "foo";
|
||||
console.log(x);
|
||||
x = "bar";
|
||||
}
|
||||
console.log(y);
|
||||
console.log(x);
|
||||
}
|
||||
a = 0, b = 0;
|
||||
f();
|
||||
@@ -1092,15 +1207,15 @@ cross_branch_2a_4: {
|
||||
expect: {
|
||||
var a, b;
|
||||
function f() {
|
||||
var y, y;
|
||||
var x, x;
|
||||
if (a) {
|
||||
if (b) {
|
||||
y = "foo";
|
||||
console.log(y);
|
||||
x = "foo";
|
||||
console.log(x);
|
||||
}
|
||||
y = "bar";
|
||||
x = "bar";
|
||||
}
|
||||
console.log(y);
|
||||
console.log(x);
|
||||
}
|
||||
a = 0, b = 0;
|
||||
f();
|
||||
@@ -1148,14 +1263,14 @@ cross_branch_2a_5: {
|
||||
expect: {
|
||||
var a, b;
|
||||
function f() {
|
||||
var y, y;
|
||||
var x, x;
|
||||
if (a) {
|
||||
y = "foo";
|
||||
x = "foo";
|
||||
if (b)
|
||||
console.log(y);
|
||||
y = "bar";
|
||||
console.log(x);
|
||||
x = "bar";
|
||||
}
|
||||
console.log(y);
|
||||
console.log(x);
|
||||
}
|
||||
a = 0, b = 0;
|
||||
f();
|
||||
@@ -1427,13 +1542,13 @@ cross_branch_2a_10: {
|
||||
expect: {
|
||||
var a, b;
|
||||
function f() {
|
||||
var y, y;
|
||||
y = "foo";
|
||||
var x, x;
|
||||
x = "foo";
|
||||
if (a) {
|
||||
if (b)
|
||||
console.log(y);
|
||||
y = "bar";
|
||||
console.log(y);
|
||||
console.log(x);
|
||||
x = "bar";
|
||||
console.log(x);
|
||||
}
|
||||
}
|
||||
a = 0, b = 0;
|
||||
@@ -1590,13 +1705,13 @@ cross_branch_2a_13: {
|
||||
expect: {
|
||||
var a, b;
|
||||
function f() {
|
||||
var y, y;
|
||||
y = "foo";
|
||||
var x, x;
|
||||
x = "foo";
|
||||
if (a) {
|
||||
console.log(y);
|
||||
console.log(x);
|
||||
if (b) {
|
||||
y = "bar";
|
||||
console.log(y);
|
||||
x = "bar";
|
||||
console.log(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1644,13 +1759,13 @@ cross_branch_2a_14: {
|
||||
expect: {
|
||||
var a, b;
|
||||
function f() {
|
||||
var y, y;
|
||||
y = "foo";
|
||||
var x, x;
|
||||
x = "foo";
|
||||
if (a) {
|
||||
console.log(y);
|
||||
y = "bar";
|
||||
console.log(x);
|
||||
x = "bar";
|
||||
if (b)
|
||||
console.log(y);
|
||||
console.log(x);
|
||||
}
|
||||
}
|
||||
a = 0, b = 0;
|
||||
@@ -1753,13 +1868,13 @@ cross_branch_2a_16: {
|
||||
expect: {
|
||||
var a, b;
|
||||
function f() {
|
||||
var y, y;
|
||||
y = "foo";
|
||||
console.log(y);
|
||||
var x, x;
|
||||
x = "foo";
|
||||
console.log(x);
|
||||
if (a) {
|
||||
y = "bar";
|
||||
x = "bar";
|
||||
if (b)
|
||||
console.log(y);
|
||||
console.log(x);
|
||||
}
|
||||
}
|
||||
a = 0, b = 0;
|
||||
@@ -1807,13 +1922,13 @@ cross_branch_2b_1: {
|
||||
expect: {
|
||||
var a, b;
|
||||
function f() {
|
||||
var y, y;
|
||||
var x, x;
|
||||
if (a)
|
||||
y = "foo";
|
||||
x = "foo";
|
||||
if (b)
|
||||
console.log(y);
|
||||
y = "bar";
|
||||
console.log(y);
|
||||
console.log(x);
|
||||
x = "bar";
|
||||
console.log(x);
|
||||
}
|
||||
a = 0, b = 0;
|
||||
f();
|
||||
@@ -1918,13 +2033,13 @@ cross_branch_2b_3: {
|
||||
expect: {
|
||||
var a, b;
|
||||
function f() {
|
||||
var y, y;
|
||||
var x, x;
|
||||
if (a)
|
||||
y = "foo";
|
||||
x = "foo";
|
||||
if (b) {
|
||||
console.log(y);
|
||||
y = "bar";
|
||||
console.log(y);
|
||||
console.log(x);
|
||||
x = "bar";
|
||||
console.log(x);
|
||||
}
|
||||
}
|
||||
a = 0, b = 0;
|
||||
@@ -2028,13 +2143,13 @@ cross_branch_2b_5: {
|
||||
expect: {
|
||||
var a, b;
|
||||
function f() {
|
||||
var y, y;
|
||||
var x, x;
|
||||
if (a)
|
||||
y = "foo";
|
||||
console.log(y);
|
||||
x = "foo";
|
||||
console.log(x);
|
||||
if (b) {
|
||||
y = "bar";
|
||||
console.log(y);
|
||||
x = "bar";
|
||||
console.log(x);
|
||||
}
|
||||
}
|
||||
a = 0, b = 0;
|
||||
@@ -2141,14 +2256,14 @@ cross_branch_2b_7: {
|
||||
expect: {
|
||||
var a, b;
|
||||
function f() {
|
||||
var y, y;
|
||||
var x, x;
|
||||
if (a) {
|
||||
y = "foo";
|
||||
console.log(y);
|
||||
x = "foo";
|
||||
console.log(x);
|
||||
}
|
||||
if (b) {
|
||||
y = "bar";
|
||||
console.log(y);
|
||||
x = "bar";
|
||||
console.log(x);
|
||||
}
|
||||
}
|
||||
a = 0, b = 0;
|
||||
@@ -2195,13 +2310,13 @@ cross_branch_2b_8: {
|
||||
expect: {
|
||||
var a, b;
|
||||
function f() {
|
||||
var y, y;
|
||||
var x, x;
|
||||
if (a)
|
||||
y = "foo";
|
||||
console.log(y);
|
||||
y = "bar";
|
||||
x = "foo";
|
||||
console.log(x);
|
||||
x = "bar";
|
||||
if (b)
|
||||
console.log(y);
|
||||
console.log(x);
|
||||
}
|
||||
a = 0, b = 0;
|
||||
f();
|
||||
@@ -2250,14 +2365,14 @@ cross_branch_2b_9: {
|
||||
expect: {
|
||||
var a, b;
|
||||
function f() {
|
||||
var y, y;
|
||||
var x, x;
|
||||
if (a) {
|
||||
y = "foo";
|
||||
console.log(y);
|
||||
x = "foo";
|
||||
console.log(x);
|
||||
}
|
||||
y = "bar";
|
||||
x = "bar";
|
||||
if (b)
|
||||
console.log(y);
|
||||
console.log(x);
|
||||
}
|
||||
a = 0, b = 0;
|
||||
f();
|
||||
@@ -2304,14 +2419,14 @@ cross_branch_2b_10: {
|
||||
expect: {
|
||||
var a, b;
|
||||
function f() {
|
||||
var y, y;
|
||||
var x, x;
|
||||
if (a) {
|
||||
y = "foo";
|
||||
console.log(y);
|
||||
y = "bar";
|
||||
x = "foo";
|
||||
console.log(x);
|
||||
x = "bar";
|
||||
}
|
||||
if (b)
|
||||
console.log(y);
|
||||
console.log(x);
|
||||
}
|
||||
a = 0, b = 0;
|
||||
f();
|
||||
@@ -2412,13 +2527,13 @@ cross_branch_2b_12: {
|
||||
expect: {
|
||||
var a, b;
|
||||
function f() {
|
||||
var y, y;
|
||||
y = "foo";
|
||||
var x, x;
|
||||
x = "foo";
|
||||
if (a)
|
||||
console.log(y);
|
||||
console.log(x);
|
||||
if (b) {
|
||||
y = "bar";
|
||||
console.log(y);
|
||||
x = "bar";
|
||||
console.log(x);
|
||||
}
|
||||
}
|
||||
a = 0, b = 0;
|
||||
@@ -2465,13 +2580,13 @@ cross_branch_2b_13: {
|
||||
expect: {
|
||||
var a, b;
|
||||
function f() {
|
||||
var y, y;
|
||||
y = "foo";
|
||||
var x, x;
|
||||
x = "foo";
|
||||
if (a)
|
||||
console.log(y);
|
||||
y = "bar";
|
||||
console.log(x);
|
||||
x = "bar";
|
||||
if (b)
|
||||
console.log(y);
|
||||
console.log(x);
|
||||
}
|
||||
a = 0, b = 0;
|
||||
f();
|
||||
@@ -2620,11 +2735,11 @@ issue_4126_1: {
|
||||
try {
|
||||
console.log("PASS");
|
||||
} catch (e) {
|
||||
var c = a;
|
||||
var b = a;
|
||||
} finally {
|
||||
var c = c;
|
||||
var a = b;
|
||||
}
|
||||
console.log(c);
|
||||
console.log(a);
|
||||
}
|
||||
f("FAIL");
|
||||
}
|
||||
@@ -2816,11 +2931,11 @@ conditional_write: {
|
||||
console.log(b);
|
||||
}
|
||||
expect: {
|
||||
var b = "FAIL", b;
|
||||
var a = "FAIL", a;
|
||||
if (console)
|
||||
b = "PASS";
|
||||
b = [b, 42].join();
|
||||
console.log(b);
|
||||
a = "PASS";
|
||||
a = [a, 42].join();
|
||||
console.log(a);
|
||||
}
|
||||
expect_stdout: "PASS,42"
|
||||
}
|
||||
@@ -2994,13 +3109,13 @@ issue_4168_use_strict: {
|
||||
expect: {
|
||||
"use strict";
|
||||
var o = {
|
||||
f: function(d, e, f) {
|
||||
var d = d.d;
|
||||
var e = e.e;
|
||||
var f = f.f;
|
||||
f: function(a, b, c) {
|
||||
var a = a.d;
|
||||
var b = b.e;
|
||||
var c = c.f;
|
||||
this.g(arguments);
|
||||
if (d)
|
||||
console.log(e, f);
|
||||
if (a)
|
||||
console.log(b, c);
|
||||
},
|
||||
g: function(args) {
|
||||
console.log(args[0], args[1], args[2]);
|
||||
|
||||
Reference in New Issue
Block a user