Stop dropping args in new expressions

This commit is contained in:
Anthony Van de Gejuchte
2016-06-10 15:42:55 +02:00
committed by Richard van Velzen
parent 9c53c7ada7
commit 6c8e001fee
3 changed files with 51 additions and 11 deletions

View File

@@ -5,19 +5,31 @@ describe("New", function() {
it("Should attach callback parens after some tokens", function() {
var tests = [
"new x(1);",
"new x;",
"new new x;",
"new (function(foo){this.foo=foo;})(1);",
"new (function(foo){this.foo=foo;})();",
"new (function test(foo){this.foo=foo;})(1);",
"new (function test(foo){this.foo=foo;})();",
"new true;",
"new (0);",
"new (!0);",
"new (bar = function(foo) {this.foo=foo;})(123);"
"new (bar = function(foo) {this.foo=foo;})(123);",
"new (bar = function(foo) {this.foo=foo;})();"
];
var expected = [
"new x(1);",
"new x;",
"new (new x);",
"new function(foo) {\n this.foo = foo;\n}(1);",
"new function(foo) {\n this.foo = foo;\n};",
"new function test(foo) {\n this.foo = foo;\n}(1);",
"new function test(foo) {\n this.foo = foo;\n};",
"new true;",
"new 0;",
"new (!0);",
"new (bar = function(foo) {\n this.foo = foo;\n})(123);"
"new (bar = function(foo) {\n this.foo = foo;\n})(123);",
"new (bar = function(foo) {\n this.foo = foo;\n});"
];
for (var i = 0; i < tests.length; i++) {
assert.strictEqual(