Update old test

This commit is contained in:
Anders Hejlsberg
2017-04-30 16:06:07 -07:00
parent 3a96b24531
commit 21d8e9a6fd
5 changed files with 71 additions and 151 deletions
@@ -1,86 +0,0 @@
tests/cases/conformance/enums/enumBasics.ts(13,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'e' must be of type 'typeof E1', but here has type '{ readonly [n: number]: string; readonly A: E1; readonly B: E1; readonly C: E1; }'.
==== tests/cases/conformance/enums/enumBasics.ts (1 errors) ====
// Enum without initializers have first member = 0 and successive members = N + 1
enum E1 {
A,
B,
C
}
// Enum type is a subtype of Number
var x: number = E1.A;
// Enum object type is anonymous with properties of the enum type and numeric indexer
var e = E1;
var e: {
~
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'e' must be of type 'typeof E1', but here has type '{ readonly [n: number]: string; readonly A: E1; readonly B: E1; readonly C: E1; }'.
readonly A: E1;
readonly B: E1;
readonly C: E1;
readonly [n: number]: string;
};
var e: typeof E1;
// Reverse mapping of enum returns string name of property
var s = E1[e.A];
var s: string;
// Enum with only constant members
enum E2 {
A = 1, B = 2, C = 3
}
// Enum with only computed members
enum E3 {
X = 'foo'.length, Y = 4 + 3, Z = +'foo'
}
// Enum with constant members followed by computed members
enum E4 {
X = 0, Y, Z = 'foo'.length
}
// Enum with > 2 constant members with no initializer for first member, non zero initializer for second element
enum E5 {
A,
B = 3,
C // 4
}
enum E6 {
A,
B = 0,
C // 1
}
// Enum with computed member initializer of type 'any'
enum E7 {
A = 'foo'['foo']
}
// Enum with computed member initializer of type number
enum E8 {
B = 'foo'['foo']
}
//Enum with computed member intializer of same enum type
enum E9 {
A,
B = A
}
// (refer to .js to validate)
// Enum constant members are propagated
var doNotPropagate = [
E8.B, E7.A, E4.Z, E3.X, E3.Y, E3.Z
];
// Enum computed members are not propagated
var doPropagate = [
E9.A, E9.B, E6.B, E6.C, E6.A, E5.A, E5.B, E5.C
];
+3 -3
View File
@@ -12,9 +12,9 @@ var x: number = E1.A;
// Enum object type is anonymous with properties of the enum type and numeric indexer
var e = E1;
var e: {
readonly A: E1;
readonly B: E1;
readonly C: E1;
readonly A: E1.A;
readonly B: E1.B;
readonly C: E1.C;
readonly [n: number]: string;
};
var e: typeof E1;
+8 -5
View File
@@ -28,17 +28,20 @@ var e = E1;
var e: {
>e : Symbol(e, Decl(enumBasics.ts, 11, 3), Decl(enumBasics.ts, 12, 3), Decl(enumBasics.ts, 18, 3))
readonly A: E1;
readonly A: E1.A;
>A : Symbol(A, Decl(enumBasics.ts, 12, 8))
>E1 : Symbol(E1, Decl(enumBasics.ts, 0, 0))
>A : Symbol(E1.A, Decl(enumBasics.ts, 1, 9))
readonly B: E1;
>B : Symbol(B, Decl(enumBasics.ts, 13, 19))
readonly B: E1.B;
>B : Symbol(B, Decl(enumBasics.ts, 13, 21))
>E1 : Symbol(E1, Decl(enumBasics.ts, 0, 0))
>B : Symbol(E1.B, Decl(enumBasics.ts, 2, 6))
readonly C: E1;
>C : Symbol(C, Decl(enumBasics.ts, 14, 19))
readonly C: E1.C;
>C : Symbol(C, Decl(enumBasics.ts, 14, 21))
>E1 : Symbol(E1, Decl(enumBasics.ts, 0, 0))
>C : Symbol(E1.C, Decl(enumBasics.ts, 3, 6))
readonly [n: number]: string;
>n : Symbol(n, Decl(enumBasics.ts, 16, 14))
+57 -54
View File
@@ -4,21 +4,21 @@ enum E1 {
>E1 : E1
A,
>A : E1
>A : E1.A
B,
>B : E1
>B : E1.B
C
>C : E1
>C : E1.C
}
// Enum type is a subtype of Number
var x: number = E1.A;
>x : number
>E1.A : E1
>E1.A : E1.A
>E1 : typeof E1
>A : E1
>A : E1.A
// Enum object type is anonymous with properties of the enum type and numeric indexer
var e = E1;
@@ -28,17 +28,20 @@ var e = E1;
var e: {
>e : typeof E1
readonly A: E1;
>A : E1
>E1 : E1
readonly A: E1.A;
>A : E1.A
>E1 : any
>A : E1.A
readonly B: E1;
>B : E1
>E1 : E1
readonly B: E1.B;
>B : E1.B
>E1 : any
>B : E1.B
readonly C: E1;
>C : E1
>E1 : E1
readonly C: E1.C;
>C : E1.C
>E1 : any
>C : E1.C
readonly [n: number]: string;
>n : number
@@ -53,9 +56,9 @@ var s = E1[e.A];
>s : string
>E1[e.A] : string
>E1 : typeof E1
>e.A : E1
>e.A : E1.A
>e : typeof E1
>A : E1
>A : E1.A
var s: string;
>s : string
@@ -66,12 +69,12 @@ enum E2 {
>E2 : E2
A = 1, B = 2, C = 3
>A : E2
>1 : number
>B : E2
>2 : number
>C : E2
>3 : number
>A : E2.A
>1 : 1
>B : E2.B
>2 : 2
>C : E2.C
>3 : 3
}
// Enum with only computed members
@@ -81,15 +84,15 @@ enum E3 {
X = 'foo'.length, Y = 4 + 3, Z = +'foo'
>X : E3
>'foo'.length : number
>'foo' : string
>'foo' : "foo"
>length : number
>Y : E3
>4 + 3 : number
>4 : number
>3 : number
>4 : 4
>3 : 3
>Z : E3
>+'foo' : number
>'foo' : string
>'foo' : "foo"
}
// Enum with constant members followed by computed members
@@ -98,11 +101,11 @@ enum E4 {
X = 0, Y, Z = 'foo'.length
>X : E4
>0 : number
>0 : 0
>Y : E4
>Z : E4
>'foo'.length : number
>'foo' : string
>'foo' : "foo"
>length : number
}
@@ -111,28 +114,28 @@ enum E5 {
>E5 : E5
A,
>A : E5
>A : E5.A
B = 3,
>B : E5
>3 : number
>B : E5.B
>3 : 3
C // 4
>C : E5
>C : E5.C
}
enum E6 {
>E6 : E6
A,
>A : E6
>A : E6.A
B = 0,
>B : E6
>0 : number
>B : E6.A
>0 : 0
C // 1
>C : E6
>C : E6.C
}
// Enum with computed member initializer of type 'any'
@@ -142,8 +145,8 @@ enum E7 {
A = 'foo'['foo']
>A : E7
>'foo'['foo'] : any
>'foo' : string
>'foo' : string
>'foo' : "foo"
>'foo' : "foo"
}
// Enum with computed member initializer of type number
@@ -153,8 +156,8 @@ enum E8 {
B = 'foo'['foo']
>B : E8
>'foo'['foo'] : any
>'foo' : string
>'foo' : string
>'foo' : "foo"
>'foo' : "foo"
}
//Enum with computed member intializer of same enum type
@@ -198,8 +201,8 @@ var doNotPropagate = [
];
// Enum computed members are not propagated
var doPropagate = [
>doPropagate : (E5 | E6 | E9)[]
>[ E9.A, E9.B, E6.B, E6.C, E6.A, E5.A, E5.B, E5.C] : (E5 | E6 | E9)[]
>doPropagate : (E9 | E6 | E5)[]
>[ E9.A, E9.B, E6.B, E6.C, E6.A, E5.A, E5.B, E5.C] : (E9 | E6 | E5)[]
E9.A, E9.B, E6.B, E6.C, E6.A, E5.A, E5.B, E5.C
>E9.A : E9
@@ -208,24 +211,24 @@ var doPropagate = [
>E9.B : E9
>E9 : typeof E9
>B : E9
>E6.B : E6
>E6.B : E6.A
>E6 : typeof E6
>B : E6
>E6.C : E6
>B : E6.A
>E6.C : E6.C
>E6 : typeof E6
>C : E6
>E6.A : E6
>C : E6.C
>E6.A : E6.A
>E6 : typeof E6
>A : E6
>E5.A : E5
>A : E6.A
>E5.A : E5.A
>E5 : typeof E5
>A : E5
>E5.B : E5
>A : E5.A
>E5.B : E5.B
>E5 : typeof E5
>B : E5
>E5.C : E5
>B : E5.B
>E5.C : E5.C
>E5 : typeof E5
>C : E5
>C : E5.C
];
+3 -3
View File
@@ -11,9 +11,9 @@ var x: number = E1.A;
// Enum object type is anonymous with properties of the enum type and numeric indexer
var e = E1;
var e: {
readonly A: E1;
readonly B: E1;
readonly C: E1;
readonly A: E1.A;
readonly B: E1.B;
readonly C: E1.C;
readonly [n: number]: string;
};
var e: typeof E1;