fix corner case in conditionals (#5233)

fixes #5232
This commit is contained in:
Alex Lam S.L
2021-12-23 14:25:02 +00:00
committed by GitHub
parent 29a1e71705
commit bab416465f
3 changed files with 137 additions and 10 deletions

View File

@@ -1924,3 +1924,86 @@ object_super: {
expect_stdout: "PASS"
node_version: ">=4"
}
issue_5232_1: {
options = {
conditionals: true,
}
input: {
(function() {
if (Math) {
function f() {}
for (var a in [ 42 ])
console.log(typeof f);
} else {
var b = null;
return true;
}
})();
}
expect: {
(function() {
var b;
if (!Math)
return b = null, true;
function f() {}
for (var a in [ 42 ]) console.log(typeof f);
})();
}
expect_stdout: "function"
}
issue_5232_2: {
options = {
conditionals: true,
}
input: {
console.log(function() {
if (!Math);
else {
var b = null;
return "PASS";
}
}());
}
expect: {
console.log(function() {
var b;
if (Math)
return b = null, "PASS";
}());
}
expect_stdout: "PASS"
}
issue_5232_3: {
options = {
conditionals: true,
}
input: {
console.log(function() {
return function() {
if (console)
console.log("PASS");
else {
var a = null;
return "FAIL";
}
};
}()());
}
expect: {
console.log(function() {
return function() {
var a;
if (!console)
return a = null, "FAIL";
console.log("PASS");
};
}()());
}
expect_stdout: [
"PASS",
"undefined",
]
}