Fix await ternary parenthesis (#740)

* Add missing case.

* Update tests.
master
Davy Duperron 2017-02-19 23:31:54 +01:00 committed by Christopher Chedeau
parent 9399c1b656
commit f106b1ec97
3 changed files with 17 additions and 0 deletions

View File

@ -419,6 +419,7 @@ FPp.needsParens = function(assumeExpressionContext) {
case "LogicalExpression":
case "NewExpression":
case "ExportDefaultDeclaration":
case "AwaitExpression":
return true;
case "CallExpression":

View File

@ -18,9 +18,19 @@ exports[`test conditional-expression.js 1`] = `
"async function f() {
const result = typeof fn === \'function\' ? await fn() : null;
}
(async function() {
console.log(
await (true ? Promise.resolve(\"A\") : Promise.resolve(\"B\"))
);
})()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
async function f() {
const result = typeof fn === \"function\" ? await fn() : null;
}
(async function() {
console.log(await (true ? Promise.resolve(\"A\") : Promise.resolve(\"B\")));
})();
"
`;

View File

@ -1,3 +1,9 @@
async function f() {
const result = typeof fn === 'function' ? await fn() : null;
}
(async function() {
console.log(
await (true ? Promise.resolve("A") : Promise.resolve("B"))
);
})()