From a6068e1c08553c843e34ca00ff76da550cfa4159 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 9 Nov 2015 10:21:54 -0800 Subject: [PATCH] More test cases and accept baselines --- .../genericClassExpressionInFunction.js | 104 +++++++++++++++++ .../genericClassExpressionInFunction.symbols | 92 +++++++++++++++ .../genericClassExpressionInFunction.types | 108 ++++++++++++++++++ .../genericClassExpressionInFunction.ts | 13 ++- 4 files changed, 313 insertions(+), 4 deletions(-) create mode 100644 tests/baselines/reference/genericClassExpressionInFunction.js create mode 100644 tests/baselines/reference/genericClassExpressionInFunction.symbols create mode 100644 tests/baselines/reference/genericClassExpressionInFunction.types diff --git a/tests/baselines/reference/genericClassExpressionInFunction.js b/tests/baselines/reference/genericClassExpressionInFunction.js new file mode 100644 index 00000000000..bb45587eea1 --- /dev/null +++ b/tests/baselines/reference/genericClassExpressionInFunction.js @@ -0,0 +1,104 @@ +//// [genericClassExpressionInFunction.ts] +class A { + genericVar: T +} +function B1() { + // class expression can use T + return class extends A { } +} +class B2 { + anon = class extends A { } +} +function B3() { + return class Inner extends A { } +} +// extends can call B +class K extends B1() { + namae: string; +} +class C extends (new B2().anon) { + name: string; +} +let b3Number = B3(); +class S extends b3Number { + nom: string; +} +var c = new C(); +var k = new K(); +var s = new S(); +c.genericVar = 12; +k.genericVar = 12; +s.genericVar = 12; + + +//// [genericClassExpressionInFunction.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var A = (function () { + function A() { + } + return A; +})(); +function B1() { + // class expression can use T + return (function (_super) { + __extends(class_1, _super); + function class_1() { + _super.apply(this, arguments); + } + return class_1; + })(A); +} +var B2 = (function () { + function B2() { + this.anon = (function (_super) { + __extends(class_2, _super); + function class_2() { + _super.apply(this, arguments); + } + return class_2; + })(A); + } + return B2; +})(); +function B3() { + return (function (_super) { + __extends(Inner, _super); + function Inner() { + _super.apply(this, arguments); + } + return Inner; + })(A); +} +// extends can call B +var K = (function (_super) { + __extends(K, _super); + function K() { + _super.apply(this, arguments); + } + return K; +})(B1()); +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + return C; +})((new B2().anon)); +var b3Number = B3(); +var S = (function (_super) { + __extends(S, _super); + function S() { + _super.apply(this, arguments); + } + return S; +})(b3Number); +var c = new C(); +var k = new K(); +var s = new S(); +c.genericVar = 12; +k.genericVar = 12; +s.genericVar = 12; diff --git a/tests/baselines/reference/genericClassExpressionInFunction.symbols b/tests/baselines/reference/genericClassExpressionInFunction.symbols new file mode 100644 index 00000000000..b5a6b8c6c70 --- /dev/null +++ b/tests/baselines/reference/genericClassExpressionInFunction.symbols @@ -0,0 +1,92 @@ +=== tests/cases/conformance/classes/classExpressions/genericClassExpressionInFunction.ts === +class A { +>A : Symbol(A, Decl(genericClassExpressionInFunction.ts, 0, 0)) +>T : Symbol(T, Decl(genericClassExpressionInFunction.ts, 0, 8)) + + genericVar: T +>genericVar : Symbol(genericVar, Decl(genericClassExpressionInFunction.ts, 0, 12)) +>T : Symbol(T, Decl(genericClassExpressionInFunction.ts, 0, 8)) +} +function B1() { +>B1 : Symbol(B1, Decl(genericClassExpressionInFunction.ts, 2, 1)) +>U : Symbol(U, Decl(genericClassExpressionInFunction.ts, 3, 12)) + + // class expression can use T + return class extends A { } +>A : Symbol(A, Decl(genericClassExpressionInFunction.ts, 0, 0)) +>U : Symbol(U, Decl(genericClassExpressionInFunction.ts, 3, 12)) +} +class B2 { +>B2 : Symbol(B2, Decl(genericClassExpressionInFunction.ts, 6, 1)) +>V : Symbol(V, Decl(genericClassExpressionInFunction.ts, 7, 9)) + + anon = class extends A { } +>anon : Symbol(anon, Decl(genericClassExpressionInFunction.ts, 7, 13)) +>A : Symbol(A, Decl(genericClassExpressionInFunction.ts, 0, 0)) +>V : Symbol(V, Decl(genericClassExpressionInFunction.ts, 7, 9)) +} +function B3() { +>B3 : Symbol(B3, Decl(genericClassExpressionInFunction.ts, 9, 1)) +>W : Symbol(W, Decl(genericClassExpressionInFunction.ts, 10, 12)) + + return class Inner extends A { } +>Inner : Symbol(Inner, Decl(genericClassExpressionInFunction.ts, 11, 10)) +>TInner : Symbol(TInner, Decl(genericClassExpressionInFunction.ts, 11, 23)) +>A : Symbol(A, Decl(genericClassExpressionInFunction.ts, 0, 0)) +>W : Symbol(W, Decl(genericClassExpressionInFunction.ts, 10, 12)) +} +// extends can call B +class K extends B1() { +>K : Symbol(K, Decl(genericClassExpressionInFunction.ts, 12, 1)) +>B1 : Symbol(B1, Decl(genericClassExpressionInFunction.ts, 2, 1)) + + namae: string; +>namae : Symbol(namae, Decl(genericClassExpressionInFunction.ts, 14, 30)) +} +class C extends (new B2().anon) { +>C : Symbol(C, Decl(genericClassExpressionInFunction.ts, 16, 1)) +>new B2().anon : Symbol(B2.anon, Decl(genericClassExpressionInFunction.ts, 7, 13)) +>B2 : Symbol(B2, Decl(genericClassExpressionInFunction.ts, 6, 1)) +>anon : Symbol(B2.anon, Decl(genericClassExpressionInFunction.ts, 7, 13)) + + name: string; +>name : Symbol(name, Decl(genericClassExpressionInFunction.ts, 17, 41)) +} +let b3Number = B3(); +>b3Number : Symbol(b3Number, Decl(genericClassExpressionInFunction.ts, 20, 3)) +>B3 : Symbol(B3, Decl(genericClassExpressionInFunction.ts, 9, 1)) + +class S extends b3Number { +>S : Symbol(S, Decl(genericClassExpressionInFunction.ts, 20, 28)) +>b3Number : Symbol(b3Number, Decl(genericClassExpressionInFunction.ts, 20, 3)) + + nom: string; +>nom : Symbol(nom, Decl(genericClassExpressionInFunction.ts, 21, 34)) +} +var c = new C(); +>c : Symbol(c, Decl(genericClassExpressionInFunction.ts, 24, 3)) +>C : Symbol(C, Decl(genericClassExpressionInFunction.ts, 16, 1)) + +var k = new K(); +>k : Symbol(k, Decl(genericClassExpressionInFunction.ts, 25, 3)) +>K : Symbol(K, Decl(genericClassExpressionInFunction.ts, 12, 1)) + +var s = new S(); +>s : Symbol(s, Decl(genericClassExpressionInFunction.ts, 26, 3)) +>S : Symbol(S, Decl(genericClassExpressionInFunction.ts, 20, 28)) + +c.genericVar = 12; +>c.genericVar : Symbol(A.genericVar, Decl(genericClassExpressionInFunction.ts, 0, 12)) +>c : Symbol(c, Decl(genericClassExpressionInFunction.ts, 24, 3)) +>genericVar : Symbol(A.genericVar, Decl(genericClassExpressionInFunction.ts, 0, 12)) + +k.genericVar = 12; +>k.genericVar : Symbol(A.genericVar, Decl(genericClassExpressionInFunction.ts, 0, 12)) +>k : Symbol(k, Decl(genericClassExpressionInFunction.ts, 25, 3)) +>genericVar : Symbol(A.genericVar, Decl(genericClassExpressionInFunction.ts, 0, 12)) + +s.genericVar = 12; +>s.genericVar : Symbol(A.genericVar, Decl(genericClassExpressionInFunction.ts, 0, 12)) +>s : Symbol(s, Decl(genericClassExpressionInFunction.ts, 26, 3)) +>genericVar : Symbol(A.genericVar, Decl(genericClassExpressionInFunction.ts, 0, 12)) + diff --git a/tests/baselines/reference/genericClassExpressionInFunction.types b/tests/baselines/reference/genericClassExpressionInFunction.types new file mode 100644 index 00000000000..943391fdd59 --- /dev/null +++ b/tests/baselines/reference/genericClassExpressionInFunction.types @@ -0,0 +1,108 @@ +=== tests/cases/conformance/classes/classExpressions/genericClassExpressionInFunction.ts === +class A { +>A : A +>T : T + + genericVar: T +>genericVar : T +>T : T +} +function B1() { +>B1 : () => typeof (Anonymous class) +>U : U + + // class expression can use T + return class extends A { } +>class extends A { } : typeof (Anonymous class) +>A : A +>U : U +} +class B2 { +>B2 : B2 +>V : V + + anon = class extends A { } +>anon : typeof (Anonymous class) +>class extends A { } : typeof (Anonymous class) +>A : A +>V : V +} +function B3() { +>B3 : () => typeof Inner +>W : W + + return class Inner extends A { } +>class Inner extends A { } : typeof Inner +>Inner : typeof Inner +>TInner : TInner +>A : A +>W : W +} +// extends can call B +class K extends B1() { +>K : K +>B1() : B1.(Anonymous class) +>B1 : () => typeof (Anonymous class) + + namae: string; +>namae : string +} +class C extends (new B2().anon) { +>C : C +>(new B2().anon) : B2.(Anonymous class) +>new B2().anon : typeof (Anonymous class) +>new B2() : B2 +>B2 : typeof B2 +>anon : typeof (Anonymous class) + + name: string; +>name : string +} +let b3Number = B3(); +>b3Number : typeof Inner +>B3() : typeof Inner +>B3 : () => typeof Inner + +class S extends b3Number { +>S : S +>b3Number : B3.Inner + + nom: string; +>nom : string +} +var c = new C(); +>c : C +>new C() : C +>C : typeof C + +var k = new K(); +>k : K +>new K() : K +>K : typeof K + +var s = new S(); +>s : S +>new S() : S +>S : typeof S + +c.genericVar = 12; +>c.genericVar = 12 : number +>c.genericVar : number +>c : C +>genericVar : number +>12 : number + +k.genericVar = 12; +>k.genericVar = 12 : number +>k.genericVar : number +>k : K +>genericVar : number +>12 : number + +s.genericVar = 12; +>s.genericVar = 12 : number +>s.genericVar : number +>s : S +>genericVar : number +>12 : number + diff --git a/tests/cases/conformance/classes/classExpressions/genericClassExpressionInFunction.ts b/tests/cases/conformance/classes/classExpressions/genericClassExpressionInFunction.ts index 70f63e8a929..14885ca9905 100644 --- a/tests/cases/conformance/classes/classExpressions/genericClassExpressionInFunction.ts +++ b/tests/cases/conformance/classes/classExpressions/genericClassExpressionInFunction.ts @@ -1,8 +1,6 @@ class A { genericVar: T } -class B3 extends A { -} function B1() { // class expression can use T return class extends A { } @@ -10,6 +8,9 @@ function B1() { class B2 { anon = class extends A { } } +function B3() { + return class Inner extends A { } +} // extends can call B class K extends B1() { namae: string; @@ -17,9 +18,13 @@ class K extends B1() { class C extends (new B2().anon) { name: string; } +let b3Number = B3(); +class S extends b3Number { + nom: string; +} var c = new C(); var k = new K(); -var b3 = new B3(); +var s = new S(); c.genericVar = 12; k.genericVar = 12; -b3.genericVar = 12 +s.genericVar = 12;