fix corner case in conditionals (#3809)

fixes #3808
This commit is contained in:
Alex Lam S.L
2020-04-21 23:30:08 +01:00
committed by GitHub
parent 925a0ca1a0
commit 9577c8c1b7
2 changed files with 52 additions and 6 deletions

View File

@@ -1759,3 +1759,37 @@ conditional_assignments_3: {
}
expect_stdout: "PASS"
}
issue_3808_1: {
options = {
conditionals: true,
side_effects: true,
}
input: {
var a;
a = "PASS", [] + "" && (a = "FAIL");
console.log(a);
}
expect: {
var a;
a = [] + "" ? "FAIL" : "PASS";
console.log(a);
}
expect_stdout: "PASS"
}
issue_3808_2: {
options = {
conditionals: true,
side_effects: true,
}
input: {
var a;
console.log((a = "PASS", [] + "" && (a = "FAIL")), a);
}
expect: {
var a;
console.log((a = "PASS", [] + "" && (a = "FAIL")), a);
}
expect_stdout: " PASS"
}