Don't overparenthesize, add yield tests

This commit is contained in:
Henry Zhu
2016-01-05 17:37:07 -05:00
parent ab2135bc9f
commit cf41c321af
5 changed files with 30 additions and 14 deletions

View File

@@ -145,23 +145,17 @@ export function SequenceExpression(node: Object, parent: Object): boolean {
}
export function AwaitExpression(node: Object, parent: Object): boolean {
return t.isBinary(parent) ||
t.isUnaryLike(parent) ||
return t.isUnaryLike(parent) ||
t.isCallExpression(parent) ||
t.isMemberExpression(parent) ||
t.isNewExpression(parent) ||
t.isConditionalExpression(parent) ||
t.isAwaitExpression(parent);
t.isNewExpression(parent);
}
export function YieldExpression(node: Object, parent: Object): boolean {
return t.isBinary(parent) ||
t.isUnaryLike(parent) ||
return t.isUnaryLike(parent) ||
t.isCallExpression(parent) ||
t.isMemberExpression(parent) ||
t.isNewExpression(parent) ||
t.isConditionalExpression(parent) ||
t.isYieldExpression(parent);
t.isNewExpression(parent);
}
export function ClassExpression(node: Object, parent: Object): boolean {

View File

@@ -4,5 +4,5 @@ function* foo() {
var c = yield a = b;
yield a, yield b;
yield a = b;
return (yield 1) || (yield 2);
return yield 1 || yield 2;
}

View File

@@ -1,9 +1,9 @@
async function asdf() {
(await 1) || (await 2);
await 1 || await 2;
(await b)();
new (await b)();
true ? (await 1) : (await 2);
await (await 1);
true ? await 1 : await 2;
await await 1;
}
async function a(b) {

View File

@@ -0,0 +1,11 @@
function* asdf() {
(yield 1) || (yield 2);
(yield b)();
new (yield b)();
true ? (yield 1) : (yield 2);
yield (yield 1);
}
function* a(b) {
(yield xhr({ url: "views/test.html" })).data;
}

View File

@@ -0,0 +1,11 @@
function* asdf() {
yield 1 || yield 2;
(yield b)();
new (yield b)();
true ? yield 1 : yield 2;
yield yield 1;
}
function* a(b) {
(yield xhr({ url: "views/test.html" })).data;
}