Fix cases of missing parens with NewExpression (#230)

master
Brian Ng 2017-01-15 22:56:40 -06:00 committed by James Long
parent 0e1afd6312
commit 340a39b414
4 changed files with 13 additions and 0 deletions

View File

@ -239,6 +239,7 @@ FPp.needsParens = function(assumeExpressionContext) {
case "LogicalExpression":
switch (parent.type) {
case "CallExpression":
case "NewExpression":
return name === "callee" && parent.callee === node;
case "UnaryExpression":
@ -340,6 +341,7 @@ FPp.needsParens = function(assumeExpressionContext) {
case "SpreadProperty":
case "BinaryExpression":
case "LogicalExpression":
case "NewExpression":
return true;
case "CallExpression":

View File

@ -0,0 +1,8 @@
exports[`test new_expression.js 1`] = `
"new (memoize.Cache || MapCache)
new (typeof this == \"function\" ? this : Dict())
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
new (memoize.Cache || MapCache)();
new (typeof this == \"function\" ? this : Dict())();
"
`;

View File

@ -0,0 +1 @@
run_spec(__dirname);

View File

@ -0,0 +1,2 @@
new (memoize.Cache || MapCache)
new (typeof this == "function" ? this : Dict())