fix corner cases in collapse_vars (#4462)

fixes #4460
fixes #4461
This commit is contained in:
Alex Lam S.L
2020-12-26 05:40:31 +00:00
committed by GitHub
parent 95aea0e33c
commit be1f5199f4
2 changed files with 111 additions and 33 deletions

View File

@@ -1100,3 +1100,63 @@ issue_4458: {
expect_stdout: "PASS 42"
node_version: ">=6"
}
issue_4460: {
options = {
collapse_vars: true,
}
input: {
var log = console.log, a = "FAIL";
var [ b = a ] = (a = "PASS", []);
log(a, b);
}
expect: {
var log = console.log, a = "FAIL";
var [ b = a ] = (a = "PASS", []);
log(a, b);
}
expect_stdout: "PASS PASS"
node_version: ">=6"
}
issue_4461_1: {
options = {
collapse_vars: true,
unused: true,
}
input: {
var a = 0;
(function(b = a && console.log("PASS"), c) {
return c;
})(void 0, a++);
}
expect: {
var a = 0;
(function(b = a && console.log("PASS"), c) {
return c;
})(void 0, a++);
}
expect_stdout: "PASS"
node_version: ">=6"
}
issue_4461_2: {
options = {
collapse_vars: true,
unused: true,
}
input: {
var a = 0;
(function([ b = a && console.log("PASS") ], c) {
return c;
})([], a++);
}
expect: {
var a = 0;
(function([ b = a && console.log("PASS") ], c) {
return c;
})([], a++);
}
expect_stdout: "PASS"
node_version: ">=6"
}