enhance dead_code (#3575)

This commit is contained in:
Alex Lam S.L
2019-11-08 13:45:28 +08:00
committed by GitHub
parent 87e67ec299
commit 10648c9af6
2 changed files with 60 additions and 17 deletions

View File

@@ -1064,3 +1064,41 @@ issue_3552: {
}
expect_stdout: "PASS"
}
unreachable_assign: {
options = {
dead_code: true,
}
input: {
console.log(A = "P" + (A = "A" + (B = "S" + (A = B = "S"))), A, B);
}
expect: {
console.log(A = "P" + "A" + (B = "S" + "S"), A, B);
}
expect_stdout: "PASS PASS SS"
}
catch_return_assign: {
options = {
dead_code: true,
}
input: {
console.log(function() {
try {
throw "FAIL";
} catch (e) {
return e = "PASS";
}
}());
}
expect: {
console.log(function() {
try {
throw "FAIL";
} catch (e) {
return "PASS";
}
}());
}
expect_stdout: "PASS"
}