fix corner cases in evaluate & reduce_vars (#3879)

fixes #3878
This commit is contained in:
Alex Lam S.L
2020-05-11 15:46:00 +01:00
committed by GitHub
parent 35cc5aa06f
commit 2b24dc25fb
2 changed files with 78 additions and 10 deletions

View File

@@ -2326,3 +2326,46 @@ void_returns_recursive: {
"undefined",
]
}
issue_3878_1: {
options = {
evaluate: true,
reduce_vars: true,
toplevel: true,
unused: true,
}
input: {
var b = function(a) {
return (a = 0) == (a && this > (a += 0));
}();
console.log(b ? "PASS" : "FAIL");
}
expect: {
var b = function(a) {
return (a = 0) == (a && this > (a += 0));
}();
console.log(b ? "PASS" : "FAIL");
}
expect_stdout: "PASS"
}
issue_3878_2: {
options = {
evaluate: true,
reduce_vars: true,
toplevel: true,
}
input: {
var a = "foo";
a++ + a;
a && a;
console.log(a);
}
expect: {
var a = "foo";
a++ + a;
a;
console.log(a);
}
expect_stdout: "NaN"
}