Add additional tests

This commit is contained in:
Andy Hanson
2016-06-06 13:20:32 -07:00
parent 2fc2f5c4b9
commit 693cb9c6ca
3 changed files with 58 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
tests/cases/conformance/es7/trailingCommasInFunctionParametersAndArguments.ts(20,11): error TS1138: Parameter declaration expected.
==== tests/cases/conformance/es7/trailingCommasInFunctionParametersAndArguments.ts (1 errors) ====
function f1(x,) {}
f1(1,);
function f2(...args,) {}
f2(...[],);
// Not confused by overloads
declare function f3(x, ): number;
declare function f3(x, y,): string;
<number>f3(1,);
<string>f3(1, 2,);
// Works for constructors too
class X {
constructor(a,) { }
// *Not* allowed in getter
get x(,) { return 0; }
~
!!! error TS1138: Parameter declaration expected.
set x(value,) { }
}
interface Y {
new(x,);
(x,);
}
new X(1,);

View File

@@ -17,7 +17,15 @@ declare function f3(x, y,): string;
// Works for constructors too
class X {
constructor(a,) { }
// *Not* allowed in getter
get x(,) { return 0; }
set x(value,) { }
}
interface Y {
new(x,);
(x,);
}
new X(1,);
@@ -37,6 +45,13 @@ f3(1, 2);
var X = (function () {
function X(a) {
}
Object.defineProperty(X.prototype, "x", {
// *Not* allowed in getter
get: function () { return 0; },
set: function (value) { },
enumerable: true,
configurable: true
});
return X;
}());
new X(1);

View File

@@ -16,5 +16,13 @@ declare function f3(x, y,): string;
// Works for constructors too
class X {
constructor(a,) { }
// *Not* allowed in getter
get x(,) { return 0; }
set x(value,) { }
}
interface Y {
new(x,);
(x,);
}
new X(1,);