enhance collapse_vars (#5555)
This commit is contained in:
@@ -1046,6 +1046,60 @@ collapse_vars_3: {
|
||||
node_version: ">=8"
|
||||
}
|
||||
|
||||
collapse_funarg_1: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
A = "FAIL";
|
||||
var a = "PASS";
|
||||
(async function({}, b) {
|
||||
return b;
|
||||
})(null, A = a);
|
||||
console.log(A);
|
||||
}
|
||||
expect: {
|
||||
A = "FAIL";
|
||||
var a = "PASS";
|
||||
(async function({}, b) {
|
||||
return b;
|
||||
})(null, A = a);
|
||||
console.log(A);
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
node_version: ">=8"
|
||||
}
|
||||
|
||||
collapse_funarg_2: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
A = "FAIL";
|
||||
B = "PASS";
|
||||
(async function() {
|
||||
console.log(function({}, a) {
|
||||
return a;
|
||||
}(null, A = B));
|
||||
})();
|
||||
console.log(A);
|
||||
}
|
||||
expect: {
|
||||
A = "FAIL";
|
||||
B = "PASS";
|
||||
(async function() {
|
||||
console.log(function({}, a) {
|
||||
return a;
|
||||
}(null, A = B));
|
||||
})();
|
||||
console.log(A);
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
node_version: ">=8"
|
||||
}
|
||||
|
||||
collapse_property_lambda: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
|
||||
@@ -1170,6 +1170,49 @@ mangle_arrow_2_toplevel: {
|
||||
node_version: ">=6.9.3"
|
||||
}
|
||||
|
||||
collapse_preceding_simple_arg: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
var a = "foo";
|
||||
console.log(function(b, c = "bar") {
|
||||
return b + c;
|
||||
}(a, a));
|
||||
}
|
||||
expect: {
|
||||
var a = "foo";
|
||||
console.log(function(b, c = "bar") {
|
||||
return a + c;
|
||||
}(0, a));
|
||||
}
|
||||
expect_stdout: "foofoo"
|
||||
node_version: ">=6"
|
||||
}
|
||||
|
||||
drop_preceding_simple_arg: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
keep_fargs: false,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
var a = "foo";
|
||||
console.log(function(b, c = "bar") {
|
||||
return b + c;
|
||||
}(a, a));
|
||||
}
|
||||
expect: {
|
||||
var a = "foo";
|
||||
console.log(function(c = "bar") {
|
||||
return a + c;
|
||||
}(a));
|
||||
}
|
||||
expect_stdout: "foofoo"
|
||||
node_version: ">=6"
|
||||
}
|
||||
|
||||
issue_4444: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
|
||||
@@ -472,6 +472,93 @@ funarg_collapse_vars_3: {
|
||||
node_version: ">=6"
|
||||
}
|
||||
|
||||
funarg_collapse_vars_4: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
var a = "PASS";
|
||||
(function(b, { log: c }) {
|
||||
c(b);
|
||||
})(a, console);
|
||||
}
|
||||
expect: {
|
||||
var a = "PASS";
|
||||
(function(b, { log: c }) {
|
||||
c(a);
|
||||
})(0, console);
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
node_version: ">=6"
|
||||
}
|
||||
|
||||
funarg_collapse_vars_5: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
A = "FAIL";
|
||||
B = "PASS";
|
||||
try {
|
||||
console.log(function({}, a) {
|
||||
return a;
|
||||
}(null, A = B));
|
||||
} catch (e) {}
|
||||
console.log(A);
|
||||
}
|
||||
expect: {
|
||||
A = "FAIL";
|
||||
B = "PASS";
|
||||
try {
|
||||
console.log(function({}, a) {
|
||||
return a;
|
||||
}(null, A = B));
|
||||
} catch (e) {}
|
||||
console.log(A);
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
node_version: ">=6"
|
||||
}
|
||||
|
||||
funarg_collapse_vars_6: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
A = "FAIL";
|
||||
B = "PASS";
|
||||
function f() {
|
||||
console.log(function({}, a) {
|
||||
return a;
|
||||
}(null, A = B));
|
||||
}
|
||||
try {
|
||||
f();
|
||||
} catch (e) {
|
||||
console.log(A);
|
||||
}
|
||||
}
|
||||
expect: {
|
||||
A = "FAIL";
|
||||
B = "PASS";
|
||||
function f() {
|
||||
console.log(function({}, a) {
|
||||
return a;
|
||||
}(null, A = B));
|
||||
}
|
||||
try {
|
||||
f();
|
||||
} catch (e) {
|
||||
console.log(A);
|
||||
}
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
node_version: ">=6"
|
||||
}
|
||||
|
||||
funarg_reduce_vars_1: {
|
||||
options = {
|
||||
reduce_vars: true,
|
||||
|
||||
Reference in New Issue
Block a user