optimize conditional when condition symbol matches consequent (#1684)

This commit is contained in:
kzc
2017-03-26 04:36:33 -04:00
committed by Alex Lam S.L
parent 94f84727ce
commit 5509e51098
2 changed files with 40 additions and 0 deletions

View File

@@ -933,3 +933,32 @@ issue_1645_2: {
}
expect_stdout: true
}
condition_symbol_matches_consequent: {
options = {
conditionals: true,
}
input: {
function foo(x, y) {
return x ? x : y;
}
function bar() {
return g ? g : h;
}
var g = 4;
var h = 5;
console.log(foo(3, null), foo(0, 7), foo(true, false), bar());
}
expect: {
function foo(x, y) {
return x || y;
}
function bar() {
return g || h;
}
var g = 4;
var h = 5;
console.log(foo(3, null), foo(0, 7), foo(true, false), bar());
}
expect_stdout: "3 7 true 4"
}