Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add tests and baselines
  • Loading branch information
Kanchalai Tanglertsampan committed May 12, 2016
commit 516d759836ae358e933f65d9f5ceaf9dea6d4e18
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//// [classExpressionWithStaticPropertiesES63.ts]

declare var console: any;
const arr: {y(): number}[] = [];
for (let i = 0; i < 3; i++) {
arr.push(class C {
static x = i;
static y = () => C.x * 2;
});
}
arr.forEach(C => console.log(C.y()));

//// [classExpressionWithStaticPropertiesES63.js]
const arr = [];
for (let i = 0; i < 3; i++) {
arr.push((C_1 = class C {
},
C_1.x = i,
C_1.y = () => C_1.x * 2,
C_1));
}
arr.forEach(C => console.log(C.y()));
var C_1;
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
=== tests/cases/compiler/classExpressionWithStaticPropertiesES63.ts ===

declare var console: any;
>console : Symbol(console, Decl(classExpressionWithStaticPropertiesES63.ts, 1, 11))

const arr: {y(): number}[] = [];
>arr : Symbol(arr, Decl(classExpressionWithStaticPropertiesES63.ts, 2, 5))
>y : Symbol(y, Decl(classExpressionWithStaticPropertiesES63.ts, 2, 12))

for (let i = 0; i < 3; i++) {
>i : Symbol(i, Decl(classExpressionWithStaticPropertiesES63.ts, 3, 8))
>i : Symbol(i, Decl(classExpressionWithStaticPropertiesES63.ts, 3, 8))
>i : Symbol(i, Decl(classExpressionWithStaticPropertiesES63.ts, 3, 8))

arr.push(class C {
>arr.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
>arr : Symbol(arr, Decl(classExpressionWithStaticPropertiesES63.ts, 2, 5))
>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
>C : Symbol(C, Decl(classExpressionWithStaticPropertiesES63.ts, 4, 13))

static x = i;
>x : Symbol(C.x, Decl(classExpressionWithStaticPropertiesES63.ts, 4, 22))
>i : Symbol(i, Decl(classExpressionWithStaticPropertiesES63.ts, 3, 8))

static y = () => C.x * 2;
>y : Symbol(C.y, Decl(classExpressionWithStaticPropertiesES63.ts, 5, 21))
>C.x : Symbol(C.x, Decl(classExpressionWithStaticPropertiesES63.ts, 4, 22))
>C : Symbol(C, Decl(classExpressionWithStaticPropertiesES63.ts, 4, 13))
>x : Symbol(C.x, Decl(classExpressionWithStaticPropertiesES63.ts, 4, 22))

});
}
arr.forEach(C => console.log(C.y()));
>arr.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --))
>arr : Symbol(arr, Decl(classExpressionWithStaticPropertiesES63.ts, 2, 5))
>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --))
>C : Symbol(C, Decl(classExpressionWithStaticPropertiesES63.ts, 9, 12))
>console : Symbol(console, Decl(classExpressionWithStaticPropertiesES63.ts, 1, 11))
>C.y : Symbol(y, Decl(classExpressionWithStaticPropertiesES63.ts, 2, 12))
>C : Symbol(C, Decl(classExpressionWithStaticPropertiesES63.ts, 9, 12))
>y : Symbol(y, Decl(classExpressionWithStaticPropertiesES63.ts, 2, 12))

Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
=== tests/cases/compiler/classExpressionWithStaticPropertiesES63.ts ===

declare var console: any;
>console : any

const arr: {y(): number}[] = [];
>arr : { y(): number; }[]
>y : () => number
>[] : undefined[]

for (let i = 0; i < 3; i++) {
>i : number
>0 : number
>i < 3 : boolean
>i : number
>3 : number
>i++ : number
>i : number

arr.push(class C {
>arr.push(class C { static x = i; static y = () => C.x * 2; }) : number
>arr.push : (...items: { y(): number; }[]) => number
>arr : { y(): number; }[]
>push : (...items: { y(): number; }[]) => number
>class C { static x = i; static y = () => C.x * 2; } : typeof C
>C : typeof C

static x = i;
>x : number
>i : number

static y = () => C.x * 2;
>y : () => number
>() => C.x * 2 : () => number
>C.x * 2 : number
>C.x : number
>C : typeof C
>x : number
>2 : number

});
}
arr.forEach(C => console.log(C.y()));
>arr.forEach(C => console.log(C.y())) : void
>arr.forEach : (callbackfn: (value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg?: any) => void
>arr : { y(): number; }[]
>forEach : (callbackfn: (value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg?: any) => void
>C => console.log(C.y()) : (C: { y(): number; }) => any
>C : { y(): number; }
>console.log(C.y()) : any
>console.log : any
>console : any
>log : any
>C.y() : number
>C.y : () => number
>C : { y(): number; }
>y : () => number

11 changes: 11 additions & 0 deletions tests/cases/compiler/classExpressionWithStaticPropertiesES63.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//@target: es6

declare var console: any;
const arr: {y(): number}[] = [];
for (let i = 0; i < 3; i++) {
arr.push(class C {
static x = i;
static y = () => C.x * 2;
});
}
arr.forEach(C => console.log(C.y()));