From e11fa3fcc7c62a7bce2f758ff28b6f184b12a23a Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 10 Nov 2014 16:30:09 -0800 Subject: [PATCH] Tests for type reference annotation --- .../declFileTypeAnnotationTypeReference.js | 120 ++++++++++++++++++ .../declFileTypeAnnotationTypeReference.types | 98 ++++++++++++++ .../declFileTypeAnnotationTypeReference.ts | 45 +++++++ 3 files changed, 263 insertions(+) create mode 100644 tests/baselines/reference/declFileTypeAnnotationTypeReference.js create mode 100644 tests/baselines/reference/declFileTypeAnnotationTypeReference.types create mode 100644 tests/cases/compiler/declFileTypeAnnotationTypeReference.ts diff --git a/tests/baselines/reference/declFileTypeAnnotationTypeReference.js b/tests/baselines/reference/declFileTypeAnnotationTypeReference.js new file mode 100644 index 00000000000..3818f38d2c1 --- /dev/null +++ b/tests/baselines/reference/declFileTypeAnnotationTypeReference.js @@ -0,0 +1,120 @@ +//// [declFileTypeAnnotationTypeReference.ts] + +class c { +} +module m { + export class c { + } + export class g { + } +} +class g { +} + +// Just the name +function foo(): c { + return new c(); +} +function foo2() { + return new c(); +} + +// Qualified name +function foo3(): m.c { + return new m.c(); +} +function foo4() { + return new m.c(); +} + +// Just the name with type arguments +function foo5(): g { + return new g(); +} +function foo6() { + return new g(); +} + +// Qualified name with type arguments +function foo7(): m.g { + return new m.g(); +} +function foo8() { + return new m.g(); +} + +//// [declFileTypeAnnotationTypeReference.js] +var c = (function () { + function c() { + } + return c; +})(); +var m; +(function (m) { + var c = (function () { + function c() { + } + return c; + })(); + m.c = c; + var g = (function () { + function g() { + } + return g; + })(); + m.g = g; +})(m || (m = {})); +var g = (function () { + function g() { + } + return g; +})(); +// Just the name +function foo() { + return new c(); +} +function foo2() { + return new c(); +} +// Qualified name +function foo3() { + return new m.c(); +} +function foo4() { + return new m.c(); +} +// Just the name with type arguments +function foo5() { + return new g(); +} +function foo6() { + return new g(); +} +// Qualified name with type arguments +function foo7() { + return new m.g(); +} +function foo8() { + return new m.g(); +} + + +//// [declFileTypeAnnotationTypeReference.d.ts] +declare class c { +} +declare module m { + class c { + } + class g { + } +} +declare class g { +} +declare function foo(): c; +declare function foo2(): c; +declare function foo3(): m.c; +declare function foo4(): m.c; +declare function foo5(): g; +declare function foo6(): g; +declare function foo7(): m.g; +declare function foo8(): m.g; diff --git a/tests/baselines/reference/declFileTypeAnnotationTypeReference.types b/tests/baselines/reference/declFileTypeAnnotationTypeReference.types new file mode 100644 index 00000000000..765c86c3415 --- /dev/null +++ b/tests/baselines/reference/declFileTypeAnnotationTypeReference.types @@ -0,0 +1,98 @@ +=== tests/cases/compiler/declFileTypeAnnotationTypeReference.ts === + +class c { +>c : c +} +module m { +>m : typeof m + + export class c { +>c : c + } + export class g { +>g : g +>T : T + } +} +class g { +>g : g +>T : T +} + +// Just the name +function foo(): c { +>foo : () => c +>c : c + + return new c(); +>new c() : c +>c : typeof c +} +function foo2() { +>foo2 : () => c + + return new c(); +>new c() : c +>c : typeof c +} + +// Qualified name +function foo3(): m.c { +>foo3 : () => m.c +>m : unknown +>c : m.c + + return new m.c(); +>new m.c() : m.c +>m.c : typeof m.c +>m : typeof m +>c : typeof m.c +} +function foo4() { +>foo4 : () => m.c + + return new m.c(); +>new m.c() : m.c +>m.c : typeof m.c +>m : typeof m +>c : typeof m.c +} + +// Just the name with type arguments +function foo5(): g { +>foo5 : () => g +>g : g + + return new g(); +>new g() : g +>g : typeof g +} +function foo6() { +>foo6 : () => g + + return new g(); +>new g() : g +>g : typeof g +} + +// Qualified name with type arguments +function foo7(): m.g { +>foo7 : () => m.g +>m : unknown +>g : m.g + + return new m.g(); +>new m.g() : m.g +>m.g : typeof m.g +>m : typeof m +>g : typeof m.g +} +function foo8() { +>foo8 : () => m.g + + return new m.g(); +>new m.g() : m.g +>m.g : typeof m.g +>m : typeof m +>g : typeof m.g +} diff --git a/tests/cases/compiler/declFileTypeAnnotationTypeReference.ts b/tests/cases/compiler/declFileTypeAnnotationTypeReference.ts new file mode 100644 index 00000000000..e20ecff32f0 --- /dev/null +++ b/tests/cases/compiler/declFileTypeAnnotationTypeReference.ts @@ -0,0 +1,45 @@ +// @target: ES5 +// @declaration: true + +class c { +} +module m { + export class c { + } + export class g { + } +} +class g { +} + +// Just the name +function foo(): c { + return new c(); +} +function foo2() { + return new c(); +} + +// Qualified name +function foo3(): m.c { + return new m.c(); +} +function foo4() { + return new m.c(); +} + +// Just the name with type arguments +function foo5(): g { + return new g(); +} +function foo6() { + return new g(); +} + +// Qualified name with type arguments +function foo7(): m.g { + return new m.g(); +} +function foo8() { + return new m.g(); +} \ No newline at end of file