add parenthesis around sequence in yield (#2833)

fixes #2832
This commit is contained in:
Alex Lam S.L
2018-01-22 14:57:23 +08:00
committed by GitHub
parent c7c7960b5f
commit bc01a85ba0
2 changed files with 41 additions and 0 deletions

View File

@@ -211,3 +211,43 @@ issue_2689: {
}
expect_exact: "function*y(){return new(yield x())}"
}
issue_2832: {
beautify = {
beautify: true,
}
input: {
function* gen(i) {
const result = yield (x = i, -x);
var x;
console.log(x);
console.log(result);
yield 2;
}
var x = gen(1);
console.log(x.next("first").value);
console.log(x.next("second").value);
}
expect_exact: [
"function* gen(i) {",
" const result = yield (x = i, -x);",
" var x;",
" console.log(x);",
" console.log(result);",
" yield 2;",
"}",
"",
"var x = gen(1);",
"",
'console.log(x.next("first").value);',
"",
'console.log(x.next("second").value);',
]
expect_stdout: [
"-1",
"1",
"second",
"2",
]
node_version: ">=4"
}