Add a test

This commit is contained in:
Jason Freeman 2015-07-09 11:31:24 -07:00
parent f37fc1d42e
commit f56298a0cd
4 changed files with 69 additions and 0 deletions

View file

@ -0,0 +1,22 @@
//// [typeArgumentInferenceWithClassExpression.ts]
function foo<T>(x = class { static prop: T }): T {
return undefined;
}
foo(class { static prop = "hello" }).length;
//// [typeArgumentInferenceWithClassExpression.js]
function foo(x) {
if (x === void 0) { x = (function () {
function class_1() {
}
return class_1;
})(); }
return undefined;
}
foo((function () {
function class_2() {
}
class_2.prop = "hello";
return class_2;
})()).length;

View file

@ -0,0 +1,19 @@
=== tests/cases/conformance/es6/classExpressions/typeArgumentInferenceWithClassExpression.ts ===
function foo<T>(x = class { static prop: T }): T {
>foo : Symbol(foo, Decl(typeArgumentInferenceWithClassExpression.ts, 0, 0))
>T : Symbol(T, Decl(typeArgumentInferenceWithClassExpression.ts, 0, 13))
>x : Symbol(x, Decl(typeArgumentInferenceWithClassExpression.ts, 0, 16))
>prop : Symbol((Anonymous class).prop, Decl(typeArgumentInferenceWithClassExpression.ts, 0, 27))
>T : Symbol(T, Decl(typeArgumentInferenceWithClassExpression.ts, 0, 13))
>T : Symbol(T, Decl(typeArgumentInferenceWithClassExpression.ts, 0, 13))
return undefined;
>undefined : Symbol(undefined)
}
foo(class { static prop = "hello" }).length;
>foo(class { static prop = "hello" }).length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
>foo : Symbol(foo, Decl(typeArgumentInferenceWithClassExpression.ts, 0, 0))
>prop : Symbol((Anonymous class).prop, Decl(typeArgumentInferenceWithClassExpression.ts, 4, 11))
>length : Symbol(String.length, Decl(lib.d.ts, 414, 19))

View file

@ -0,0 +1,23 @@
=== tests/cases/conformance/es6/classExpressions/typeArgumentInferenceWithClassExpression.ts ===
function foo<T>(x = class { static prop: T }): T {
>foo : <T>(x?: typeof (Anonymous class)) => T
>T : T
>x : typeof (Anonymous class)
>class { static prop: T } : typeof (Anonymous class)
>prop : T
>T : T
>T : T
return undefined;
>undefined : undefined
}
foo(class { static prop = "hello" }).length;
>foo(class { static prop = "hello" }).length : number
>foo(class { static prop = "hello" }) : string
>foo : <T>(x?: typeof (Anonymous class)) => T
>class { static prop = "hello" } : typeof (Anonymous class)
>prop : string
>"hello" : string
>length : number

View file

@ -0,0 +1,5 @@
function foo<T>(x = class { static prop: T }): T {
return undefined;
}
foo(class { static prop = "hello" }).length;