From 693cb9c6ca6ad7adf5b05a91a213595c03ad7ff3 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 6 Jun 2016 13:20:32 -0700 Subject: [PATCH] Add additional tests --- ...nFunctionParametersAndArguments.errors.txt | 35 +++++++++++++++++++ ...gCommasInFunctionParametersAndArguments.js | 15 ++++++++ ...gCommasInFunctionParametersAndArguments.ts | 8 +++++ 3 files changed, 58 insertions(+) create mode 100644 tests/baselines/reference/trailingCommasInFunctionParametersAndArguments.errors.txt diff --git a/tests/baselines/reference/trailingCommasInFunctionParametersAndArguments.errors.txt b/tests/baselines/reference/trailingCommasInFunctionParametersAndArguments.errors.txt new file mode 100644 index 00000000000..02e44fa0976 --- /dev/null +++ b/tests/baselines/reference/trailingCommasInFunctionParametersAndArguments.errors.txt @@ -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; + + f3(1,); + 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,); + \ No newline at end of file diff --git a/tests/baselines/reference/trailingCommasInFunctionParametersAndArguments.js b/tests/baselines/reference/trailingCommasInFunctionParametersAndArguments.js index 87c925fb22b..70e3e1ccf42 100644 --- a/tests/baselines/reference/trailingCommasInFunctionParametersAndArguments.js +++ b/tests/baselines/reference/trailingCommasInFunctionParametersAndArguments.js @@ -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); diff --git a/tests/cases/conformance/es7/trailingCommasInFunctionParametersAndArguments.ts b/tests/cases/conformance/es7/trailingCommasInFunctionParametersAndArguments.ts index 9c21d7f24ea..5f48920e4dd 100644 --- a/tests/cases/conformance/es7/trailingCommasInFunctionParametersAndArguments.ts +++ b/tests/cases/conformance/es7/trailingCommasInFunctionParametersAndArguments.ts @@ -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,);