From 143fd5d954bd879a848fa2a61f208f22388a9b57 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 30 May 2015 09:19:10 -0700 Subject: [PATCH] New test and baselines --- tests/baselines/reference/localTypes3.types | 20 ++++---- tests/baselines/reference/localTypes5.js | 38 +++++++++++++++ tests/baselines/reference/localTypes5.symbols | 40 ++++++++++++++++ tests/baselines/reference/localTypes5.types | 47 +++++++++++++++++++ .../types/localTypes/localTypes5.ts | 14 ++++++ 5 files changed, 149 insertions(+), 10 deletions(-) create mode 100644 tests/baselines/reference/localTypes5.js create mode 100644 tests/baselines/reference/localTypes5.symbols create mode 100644 tests/baselines/reference/localTypes5.types create mode 100644 tests/cases/conformance/types/localTypes/localTypes5.ts diff --git a/tests/baselines/reference/localTypes3.types b/tests/baselines/reference/localTypes3.types index 77b397431b7..551096468c5 100644 --- a/tests/baselines/reference/localTypes3.types +++ b/tests/baselines/reference/localTypes3.types @@ -54,7 +54,7 @@ function f2() { >X : X class C { ->C : C +>C : C >Y : Y public x = x; @@ -75,21 +75,21 @@ function f2() { >10 : number let v = new C("hello"); ->v : C ->new C("hello") : C +>v : f.C +>new C("hello") : f.C >C : typeof C >"hello" : string let x = v.x; >x : number >v.x : number ->v : C +>v : f.C >x : number let y = v.y; >y : string >v.y : string ->v : C +>v : f.C >y : string } @@ -106,7 +106,7 @@ function f3() { >Y : Y class C { ->C : C +>C : C public x = x; >x : X @@ -127,20 +127,20 @@ function f3() { >"hello" : string let v = new C(); ->v : C ->new C() : C +>v : f.C +>new C() : f.C >C : typeof C let x = v.x; >x : number >v.x : number ->v : C +>v : f.C >x : number let y = v.y; >y : string >v.y : string ->v : C +>v : f.C >y : string } diff --git a/tests/baselines/reference/localTypes5.js b/tests/baselines/reference/localTypes5.js new file mode 100644 index 00000000000..872629276d2 --- /dev/null +++ b/tests/baselines/reference/localTypes5.js @@ -0,0 +1,38 @@ +//// [localTypes5.ts] +function foo() { + class X { + m() { + return (function () { + class Y { + } + return new Y(); + })(); + } + } + var x = new X(); + return x.m(); +} +var x = foo(); + + +//// [localTypes5.js] +function foo() { + var X = (function () { + function X() { + } + X.prototype.m = function () { + return (function () { + var Y = (function () { + function Y() { + } + return Y; + })(); + return new Y(); + })(); + }; + return X; + })(); + var x = new X(); + return x.m(); +} +var x = foo(); diff --git a/tests/baselines/reference/localTypes5.symbols b/tests/baselines/reference/localTypes5.symbols new file mode 100644 index 00000000000..4ffe53b3e53 --- /dev/null +++ b/tests/baselines/reference/localTypes5.symbols @@ -0,0 +1,40 @@ +=== tests/cases/conformance/types/localTypes/localTypes5.ts === +function foo() { +>foo : Symbol(foo, Decl(localTypes5.ts, 0, 0)) +>A : Symbol(A, Decl(localTypes5.ts, 0, 13)) + + class X { +>X : Symbol(X, Decl(localTypes5.ts, 0, 19)) + + m() { +>m : Symbol(m, Decl(localTypes5.ts, 1, 13)) +>B : Symbol(B, Decl(localTypes5.ts, 2, 10)) +>C : Symbol(C, Decl(localTypes5.ts, 2, 12)) + + return (function () { +>D : Symbol(D, Decl(localTypes5.ts, 3, 30)) + + class Y { +>Y : Symbol(Y, Decl(localTypes5.ts, 3, 36)) +>E : Symbol(E, Decl(localTypes5.ts, 4, 24)) + } + return new Y(); +>Y : Symbol(Y, Decl(localTypes5.ts, 3, 36)) + + })(); +>Date : Symbol(Date, Decl(lib.d.ts, 633, 23), Decl(lib.d.ts, 815, 11)) + } + } + var x = new X(); +>x : Symbol(x, Decl(localTypes5.ts, 10, 7)) +>X : Symbol(X, Decl(localTypes5.ts, 0, 19)) + + return x.m(); +>x.m : Symbol(X.m, Decl(localTypes5.ts, 1, 13)) +>x : Symbol(x, Decl(localTypes5.ts, 10, 7)) +>m : Symbol(X.m, Decl(localTypes5.ts, 1, 13)) +} +var x = foo(); +>x : Symbol(x, Decl(localTypes5.ts, 13, 3)) +>foo : Symbol(foo, Decl(localTypes5.ts, 0, 0)) + diff --git a/tests/baselines/reference/localTypes5.types b/tests/baselines/reference/localTypes5.types new file mode 100644 index 00000000000..b12e362f754 --- /dev/null +++ b/tests/baselines/reference/localTypes5.types @@ -0,0 +1,47 @@ +=== tests/cases/conformance/types/localTypes/localTypes5.ts === +function foo() { +>foo : () => X.m..Y +>A : A + + class X { +>X : X + + m() { +>m : () => .Y +>B : B +>C : C + + return (function () { +>(function () { class Y { } return new Y(); })() : .Y +>(function () { class Y { } return new Y(); }) : () => Y +>function () { class Y { } return new Y(); } : () => Y +>D : D + + class Y { +>Y : Y +>E : E + } + return new Y(); +>new Y() : Y +>Y : typeof Y + + })(); +>Date : Date + } + } + var x = new X(); +>x : X +>new X() : X +>X : typeof X + + return x.m(); +>x.m() : X.m..Y +>x.m : () => .Y +>x : X +>m : () => .Y +} +var x = foo(); +>x : foo.X.m..Y +>foo() : foo.X.m..Y +>foo : () => X.m..Y + diff --git a/tests/cases/conformance/types/localTypes/localTypes5.ts b/tests/cases/conformance/types/localTypes/localTypes5.ts new file mode 100644 index 00000000000..6aec24f183d --- /dev/null +++ b/tests/cases/conformance/types/localTypes/localTypes5.ts @@ -0,0 +1,14 @@ +function foo() { + class X { + m() { + return (function () { + class Y { + } + return new Y(); + })(); + } + } + var x = new X(); + return x.m(); +} +var x = foo();