fix assignment extraction from conditional (#1651)

fixes #1645
fixes #1646
This commit is contained in:
Alex Lam S.L
2017-03-24 18:52:48 +08:00
committed by GitHub
parent f3a1694a41
commit 0432a7abb9
2 changed files with 47 additions and 9 deletions

View File

@@ -893,3 +893,43 @@ equality_conditionals_true: {
}
expect_stdout: true
}
issue_1645_1: {
options = {
conditionals: true,
}
input: {
var a = 100, b = 10;
(b = a) ? a++ + (b += a) ? b += a : b += a : b ^= a;
console.log(a, b);
}
expect: {
var a = 100, b = 10;
(b = a) ? (a++ + (b += a), b += a) : b ^= a;
console.log(a,b);
}
expect_stdout: true
}
issue_1645_2: {
options = {
conditionals: true,
}
input: {
var a = 0;
function f() {
return a++;
}
f() ? a += 2 : a += 4;
console.log(a);
}
expect: {
var a = 0;
function f(){
return a++;
}
f() ? a += 2 : a += 4;
console.log(a);
}
expect_stdout: true
}