TypeScript/tests/baselines/reference/enumMerging.types
2014-08-28 12:40:58 -07:00

205 lines
3.7 KiB
Plaintext

=== tests/cases/conformance/enums/enumMerging.ts ===
// Enum with only constant members across 2 declarations with the same root module
// Enum with initializer in all declarations with constant members with the same root module
module M1 {
>M1 : typeof M1
enum EImpl1 {
>EImpl1 : EImpl1
A, B, C
>A : EImpl1
>B : EImpl1
>C : EImpl1
}
enum EImpl1 {
>EImpl1 : EImpl1
D = 1, E, F
>D : EImpl1
>E : EImpl1
>F : EImpl1
}
export enum EConst1 {
>EConst1 : EConst1
A = 3, B = 2, C = 1
>A : EConst1
>B : EConst1
>C : EConst1
}
export enum EConst1 {
>EConst1 : EConst1
D = 7, E = 9, F = 8
>D : EConst1
>E : EConst1
>F : EConst1
}
var x = [EConst1.A, EConst1.B, EConst1.C, EConst1.D, EConst1.E, EConst1.F];
>x : EConst1[]
>[EConst1.A, EConst1.B, EConst1.C, EConst1.D, EConst1.E, EConst1.F] : EConst1[]
>EConst1.A : EConst1
>EConst1 : typeof EConst1
>A : EConst1
>EConst1.B : EConst1
>EConst1 : typeof EConst1
>B : EConst1
>EConst1.C : EConst1
>EConst1 : typeof EConst1
>C : EConst1
>EConst1.D : EConst1
>EConst1 : typeof EConst1
>D : EConst1
>EConst1.E : EConst1
>EConst1 : typeof EConst1
>E : EConst1
>EConst1.F : EConst1
>EConst1 : typeof EConst1
>F : EConst1
}
// Enum with only computed members across 2 declarations with the same root module
module M2 {
>M2 : typeof M2
export enum EComp2 {
>EComp2 : EComp2
A = 'foo'.length, B = 'foo'.length, C = 'foo'.length
>A : EComp2
>'foo'.length : number
>length : number
>B : EComp2
>'foo'.length : number
>length : number
>C : EComp2
>'foo'.length : number
>length : number
}
export enum EComp2 {
>EComp2 : EComp2
D = 'foo'.length, E = 'foo'.length, F = 'foo'.length
>D : EComp2
>'foo'.length : number
>length : number
>E : EComp2
>'foo'.length : number
>length : number
>F : EComp2
>'foo'.length : number
>length : number
}
var x = [EComp2.A, EComp2.B, EComp2.C, EComp2.D, EComp2.E, EComp2.F];
>x : EComp2[]
>[EComp2.A, EComp2.B, EComp2.C, EComp2.D, EComp2.E, EComp2.F] : EComp2[]
>EComp2.A : EComp2
>EComp2 : typeof EComp2
>A : EComp2
>EComp2.B : EComp2
>EComp2 : typeof EComp2
>B : EComp2
>EComp2.C : EComp2
>EComp2 : typeof EComp2
>C : EComp2
>EComp2.D : EComp2
>EComp2 : typeof EComp2
>D : EComp2
>EComp2.E : EComp2
>EComp2 : typeof EComp2
>E : EComp2
>EComp2.F : EComp2
>EComp2 : typeof EComp2
>F : EComp2
}
// Enum with initializer in only one of two declarations with constant members with the same root module
module M3 {
>M3 : typeof M3
enum EInit {
>EInit : EInit
A,
>A : EInit
B
>B : EInit
}
enum EInit {
>EInit : EInit
C = 1, D, E
>C : EInit
>D : EInit
>E : EInit
}
}
// Enums with same name but different root module
module M4 {
>M4 : typeof M4
export enum Color { Red, Green, Blue }
>Color : Color
>Red : Color
>Green : Color
>Blue : Color
}
module M5 {
>M5 : typeof M5
export enum Color { Red, Green, Blue }
>Color : Color
>Red : Color
>Green : Color
>Blue : Color
}
module M6.A {
>M6 : typeof M6
>A : typeof A
export enum Color { Red, Green, Blue }
>Color : Color
>Red : Color
>Green : Color
>Blue : Color
}
module M6 {
>M6 : typeof M6
export module A {
>A : typeof A
export enum Color { Yellow = 1 }
>Color : Color
>Yellow : Color
}
var t = A.Color.Yellow;
>t : A.Color
>A.Color.Yellow : A.Color
>A.Color : typeof A.Color
>A : typeof A
>Color : typeof A.Color
>Yellow : A.Color
t = A.Color.Red;
>t = A.Color.Red : A.Color
>t : A.Color
>A.Color.Red : A.Color
>A.Color : typeof A.Color
>A : typeof A
>Color : typeof A.Color
>Red : A.Color
}