Fix parenthesis when call inside of new (#1169)

Fixes #1167
This commit is contained in:
Christopher Chedeau authored and GitHub committed 2017-04-10 10:49:13 -07:00
1 parent 6552257ab0
commit 8cc5f22090
3 files changed
+20

No files matched your search

+3
View File
@@ -243,6 +243,9 @@ FPp.needsParens = function(assumeExpressionContext) {
switch (node.type) {
case "CallExpression":
if (parent.type === "NewExpression" && parent.callee === node) {
return true;
}
return false;
case "SpreadElement":
@@ -1,5 +1,18 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`call.js 1`] = `
"new (factory())()
new factory()()
new (factory())(factory())
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
new (factory())();
new factory()();
new (factory())(factory());
"
`;
exports[`new_expression.js 1`] = `
"new (memoize.Cache || MapCache)
new (typeof this == \\"function\\" ? this : Dict())
+4
View File
@@ -0,0 +1,4 @@
new (factory())()
new factory()()
new (factory())(factory())