219 lines
3.9 KiB
Text
219 lines
3.9 KiB
Text
=== 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
|
|
>1 : number
|
|
>E : EImpl1
|
|
>F : EImpl1
|
|
}
|
|
|
|
export enum EConst1 {
|
|
>EConst1 : EConst1
|
|
|
|
A = 3, B = 2, C = 1
|
|
>A : EConst1
|
|
>3 : number
|
|
>B : EConst1
|
|
>2 : number
|
|
>C : EConst1
|
|
>1 : number
|
|
}
|
|
|
|
export enum EConst1 {
|
|
>EConst1 : EConst1
|
|
|
|
D = 7, E = 9, F = 8
|
|
>D : EConst1
|
|
>7 : number
|
|
>E : EConst1
|
|
>9 : number
|
|
>F : EConst1
|
|
>8 : number
|
|
}
|
|
|
|
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
|
|
>'foo' : string
|
|
>length : number
|
|
>B : EComp2
|
|
>'foo'.length : number
|
|
>'foo' : string
|
|
>length : number
|
|
>C : EComp2
|
|
>'foo'.length : number
|
|
>'foo' : string
|
|
>length : number
|
|
}
|
|
|
|
export enum EComp2 {
|
|
>EComp2 : EComp2
|
|
|
|
D = 'foo'.length, E = 'foo'.length, F = 'foo'.length
|
|
>D : EComp2
|
|
>'foo'.length : number
|
|
>'foo' : string
|
|
>length : number
|
|
>E : EComp2
|
|
>'foo'.length : number
|
|
>'foo' : string
|
|
>length : number
|
|
>F : EComp2
|
|
>'foo'.length : number
|
|
>'foo' : string
|
|
>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
|
|
>1 : number
|
|
>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
|
|
>1 : number
|
|
}
|
|
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
|
|
}
|
|
|