From 3055445d27c3d578e053541aae0fa30d7ab33191 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 10 Dec 2015 13:54:58 -0800 Subject: [PATCH] Adding test --- .../typeParameterConstraintInstantiation.js | 15 ++++++++ ...peParameterConstraintInstantiation.symbols | 32 +++++++++++++++++ ...typeParameterConstraintInstantiation.types | 34 +++++++++++++++++++ .../typeParameterConstraintInstantiation.ts | 8 +++++ 4 files changed, 89 insertions(+) create mode 100644 tests/baselines/reference/typeParameterConstraintInstantiation.js create mode 100644 tests/baselines/reference/typeParameterConstraintInstantiation.symbols create mode 100644 tests/baselines/reference/typeParameterConstraintInstantiation.types create mode 100644 tests/cases/compiler/typeParameterConstraintInstantiation.ts diff --git a/tests/baselines/reference/typeParameterConstraintInstantiation.js b/tests/baselines/reference/typeParameterConstraintInstantiation.js new file mode 100644 index 00000000000..225536941ca --- /dev/null +++ b/tests/baselines/reference/typeParameterConstraintInstantiation.js @@ -0,0 +1,15 @@ +//// [typeParameterConstraintInstantiation.ts] +// Check that type parameter constraints are properly instantiated + +interface Mapper { + map(f: (item: T) => U): V; +} + +var m: Mapper; +var a = m.map((x: string) => x); // string[] + + +//// [typeParameterConstraintInstantiation.js] +// Check that type parameter constraints are properly instantiated +var m; +var a = m.map(function (x) { return x; }); // string[] diff --git a/tests/baselines/reference/typeParameterConstraintInstantiation.symbols b/tests/baselines/reference/typeParameterConstraintInstantiation.symbols new file mode 100644 index 00000000000..9103d65c0e9 --- /dev/null +++ b/tests/baselines/reference/typeParameterConstraintInstantiation.symbols @@ -0,0 +1,32 @@ +=== tests/cases/compiler/typeParameterConstraintInstantiation.ts === +// Check that type parameter constraints are properly instantiated + +interface Mapper { +>Mapper : Symbol(Mapper, Decl(typeParameterConstraintInstantiation.ts, 0, 0)) +>T : Symbol(T, Decl(typeParameterConstraintInstantiation.ts, 2, 17)) + + map(f: (item: T) => U): V; +>map : Symbol(map, Decl(typeParameterConstraintInstantiation.ts, 2, 21)) +>U : Symbol(U, Decl(typeParameterConstraintInstantiation.ts, 3, 8)) +>T : Symbol(T, Decl(typeParameterConstraintInstantiation.ts, 2, 17)) +>V : Symbol(V, Decl(typeParameterConstraintInstantiation.ts, 3, 20)) +>U : Symbol(U, Decl(typeParameterConstraintInstantiation.ts, 3, 8)) +>f : Symbol(f, Decl(typeParameterConstraintInstantiation.ts, 3, 36)) +>item : Symbol(item, Decl(typeParameterConstraintInstantiation.ts, 3, 40)) +>T : Symbol(T, Decl(typeParameterConstraintInstantiation.ts, 2, 17)) +>U : Symbol(U, Decl(typeParameterConstraintInstantiation.ts, 3, 8)) +>V : Symbol(V, Decl(typeParameterConstraintInstantiation.ts, 3, 20)) +} + +var m: Mapper; +>m : Symbol(m, Decl(typeParameterConstraintInstantiation.ts, 6, 3)) +>Mapper : Symbol(Mapper, Decl(typeParameterConstraintInstantiation.ts, 0, 0)) + +var a = m.map((x: string) => x); // string[] +>a : Symbol(a, Decl(typeParameterConstraintInstantiation.ts, 7, 3)) +>m.map : Symbol(Mapper.map, Decl(typeParameterConstraintInstantiation.ts, 2, 21)) +>m : Symbol(m, Decl(typeParameterConstraintInstantiation.ts, 6, 3)) +>map : Symbol(Mapper.map, Decl(typeParameterConstraintInstantiation.ts, 2, 21)) +>x : Symbol(x, Decl(typeParameterConstraintInstantiation.ts, 7, 15)) +>x : Symbol(x, Decl(typeParameterConstraintInstantiation.ts, 7, 15)) + diff --git a/tests/baselines/reference/typeParameterConstraintInstantiation.types b/tests/baselines/reference/typeParameterConstraintInstantiation.types new file mode 100644 index 00000000000..5f806d57ea2 --- /dev/null +++ b/tests/baselines/reference/typeParameterConstraintInstantiation.types @@ -0,0 +1,34 @@ +=== tests/cases/compiler/typeParameterConstraintInstantiation.ts === +// Check that type parameter constraints are properly instantiated + +interface Mapper { +>Mapper : Mapper +>T : T + + map(f: (item: T) => U): V; +>map : (f: (item: T) => U) => V +>U : U +>T : T +>V : V +>U : U +>f : (item: T) => U +>item : T +>T : T +>U : U +>V : V +} + +var m: Mapper; +>m : Mapper +>Mapper : Mapper + +var a = m.map((x: string) => x); // string[] +>a : string[] +>m.map((x: string) => x) : string[] +>m.map : (f: (item: string) => U) => V +>m : Mapper +>map : (f: (item: string) => U) => V +>(x: string) => x : (x: string) => string +>x : string +>x : string + diff --git a/tests/cases/compiler/typeParameterConstraintInstantiation.ts b/tests/cases/compiler/typeParameterConstraintInstantiation.ts new file mode 100644 index 00000000000..f81ddaf8959 --- /dev/null +++ b/tests/cases/compiler/typeParameterConstraintInstantiation.ts @@ -0,0 +1,8 @@ +// Check that type parameter constraints are properly instantiated + +interface Mapper { + map(f: (item: T) => U): V; +} + +var m: Mapper; +var a = m.map((x: string) => x); // string[]