Added tests for erroneous function expressions in both tagged/untagged template expressions.

This commit is contained in:
Daniel Rosenwasser 2014-12-15 16:39:12 -08:00
parent 0263d60071
commit 17c822966d
11 changed files with 95 additions and 0 deletions

View File

@ -0,0 +1,12 @@
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts(6,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts (1 errors) ====
function foo(...rest: any[]) {
}
foo `${function (x: number) { x = "bad"; } }`;
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.

View File

@ -0,0 +1,17 @@
//// [taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts]
function foo(...rest: any[]) {
}
foo `${function (x: number) { x = "bad"; } }`;
//// [taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.js]
function foo() {
var rest = [];
for (var _i = 0; _i < arguments.length; _i++) {
rest[_i - 0] = arguments[_i];
}
}
foo `${function (x) {
x = "bad";
}}`;

View File

@ -0,0 +1,14 @@
=== tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts ===
function foo(...rest: any[]) {
>foo : (...rest: any[]) => void
>rest : any[]
}
foo `${function (x: number) { x = "bad"; } }`;
>foo : (...rest: any[]) => void
>function (x: number) { x = "bad"; } : (x: number) => void
>x : number
>x = "bad" : string
>x : number

View File

@ -0,0 +1,9 @@
//// [templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts]
`${function (x: number) { x = "bad"; } }`;
//// [templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.js]
"" + function (x) {
x = "bad";
};

View File

@ -0,0 +1,9 @@
=== tests/cases/conformance/es6/templates/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts ===
`${function (x: number) { x = "bad"; } }`;
>function (x: number) { x = "bad"; } : (x: number) => void
>x : number
>x = "bad" : string
>x : number

View File

@ -0,0 +1,8 @@
//// [templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts]
`${function (x: number) { x = "bad"; } }`;
//// [templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.js]
`${function (x) {
x = "bad";
}}`;

View File

@ -0,0 +1,8 @@
=== tests/cases/conformance/es6/templates/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts ===
`${function (x: number) { x = "bad"; } }`;
>function (x: number) { x = "bad"; } : (x: number) => void
>x : number
>x = "bad" : string
>x : number

View File

@ -0,0 +1,6 @@

function foo(...rest: any[]) {
}
foo `${function (x: number) { x = "bad"; } }`;

View File

@ -0,0 +1,6 @@
//@target: es6
function foo(...rest: any[]) {
}
foo `${function (x: number) { x = "bad"; } }`;

View File

@ -0,0 +1,3 @@

`${function (x: number) { x = "bad"; } }`;

View File

@ -0,0 +1,3 @@
//@target: es6
`${function (x: number) { x = "bad"; } }`;