Add merged enum test

This commit is contained in:
Nathan Shively-Sanders
2015-12-10 14:28:46 -08:00
parent a995b23e4a
commit 7530409695
3 changed files with 78 additions and 15 deletions

View File

@@ -1,18 +1,20 @@
tests/cases/compiler/enumAssignmentCompat3.ts(49,1): error TS2322: Type 'Abcd.E' is not assignable to type 'First.E'.
tests/cases/compiler/enumAssignmentCompat3.ts(58,1): error TS2322: Type 'Abcd.E' is not assignable to type 'First.E'.
Property 'd' is missing in type 'First.E'.
tests/cases/compiler/enumAssignmentCompat3.ts(51,1): error TS2322: Type 'Cd.E' is not assignable to type 'First.E'.
tests/cases/compiler/enumAssignmentCompat3.ts(60,1): error TS2322: Type 'Cd.E' is not assignable to type 'First.E'.
Property 'd' is missing in type 'First.E'.
tests/cases/compiler/enumAssignmentCompat3.ts(52,1): error TS2322: Type 'Nope' is not assignable to type 'E'.
tests/cases/compiler/enumAssignmentCompat3.ts(56,1): error TS2322: Type 'First.E' is not assignable to type 'Ab.E'.
tests/cases/compiler/enumAssignmentCompat3.ts(61,1): error TS2322: Type 'Nope' is not assignable to type 'E'.
tests/cases/compiler/enumAssignmentCompat3.ts(65,1): error TS2322: Type 'First.E' is not assignable to type 'Ab.E'.
Property 'c' is missing in type 'Ab.E'.
tests/cases/compiler/enumAssignmentCompat3.ts(57,1): error TS2322: Type 'First.E' is not assignable to type 'Cd.E'.
tests/cases/compiler/enumAssignmentCompat3.ts(66,1): error TS2322: Type 'First.E' is not assignable to type 'Cd.E'.
Property 'a' is missing in type 'Cd.E'.
tests/cases/compiler/enumAssignmentCompat3.ts(58,1): error TS2322: Type 'E' is not assignable to type 'Nope'.
tests/cases/compiler/enumAssignmentCompat3.ts(62,1): error TS2322: Type 'Const.E' is not assignable to type 'First.E'.
tests/cases/compiler/enumAssignmentCompat3.ts(63,1): error TS2322: Type 'First.E' is not assignable to type 'Const.E'.
tests/cases/compiler/enumAssignmentCompat3.ts(67,1): error TS2322: Type 'E' is not assignable to type 'Nope'.
tests/cases/compiler/enumAssignmentCompat3.ts(72,1): error TS2322: Type 'Const.E' is not assignable to type 'First.E'.
tests/cases/compiler/enumAssignmentCompat3.ts(73,1): error TS2322: Type 'First.E' is not assignable to type 'Const.E'.
tests/cases/compiler/enumAssignmentCompat3.ts(76,1): error TS2322: Type 'Merged.E' is not assignable to type 'First.E'.
Property 'd' is missing in type 'First.E'.
==== tests/cases/compiler/enumAssignmentCompat3.ts (8 errors) ====
==== tests/cases/compiler/enumAssignmentCompat3.ts (9 errors) ====
namespace First {
export enum E {
a, b, c,
@@ -51,6 +53,14 @@ tests/cases/compiler/enumAssignmentCompat3.ts(63,1): error TS2322: Type 'First.E
a, b, c = 3,
}
}
namespace Merged {
export enum E {
a, b,
}
export enum E {
c = 3, d,
}
}
var abc: First.E;
var secondAbc: Abc.E;
@@ -60,6 +70,7 @@ tests/cases/compiler/enumAssignmentCompat3.ts(63,1): error TS2322: Type 'First.E
var nope: Abc.Nope;
var k: Const.E;
var decl: Decl.E;
var merged: Merged.E;
abc = secondAbc; // ok
abc = secondAbcd; // missing 'd'
~~~
@@ -89,11 +100,18 @@ tests/cases/compiler/enumAssignmentCompat3.ts(63,1): error TS2322: Type 'First.E
!!! error TS2322: Type 'E' is not assignable to type 'Nope'.
decl = abc; // ok
k = k; // const is only assignable to itself
// const is only assignable to itself
k = k;
abc = k; // error
~~~
!!! error TS2322: Type 'Const.E' is not assignable to type 'First.E'.
k = abc;
~
!!! error TS2322: Type 'First.E' is not assignable to type 'Const.E'.
// merged enums compare all their members
abc = merged; // missing 'd'
~~~
!!! error TS2322: Type 'Merged.E' is not assignable to type 'First.E'.
!!! error TS2322: Property 'd' is missing in type 'First.E'.
merged = abc; // ok

View File

@@ -37,6 +37,14 @@ namespace Decl {
a, b, c = 3,
}
}
namespace Merged {
export enum E {
a, b,
}
export enum E {
c = 3, d,
}
}
var abc: First.E;
var secondAbc: Abc.E;
@@ -46,6 +54,7 @@ var secondCd: Cd.E;
var nope: Abc.Nope;
var k: Const.E;
var decl: Decl.E;
var merged: Merged.E;
abc = secondAbc; // ok
abc = secondAbcd; // missing 'd'
abc = secondAb; // ok
@@ -59,10 +68,14 @@ secondCd = abc; // missing 'a' and 'b'
nope = abc; // nope!
decl = abc; // ok
k = k; // const is only assignable to itself
// const is only assignable to itself
k = k;
abc = k; // error
k = abc;
// merged enums compare all their members
abc = merged; // missing 'd'
merged = abc; // ok
//// [enumAssignmentCompat3.js]
var First;
@@ -118,6 +131,19 @@ var Cd;
var Decl;
(function (Decl) {
})(Decl || (Decl = {}));
var Merged;
(function (Merged) {
(function (E) {
E[E["a"] = 0] = "a";
E[E["b"] = 1] = "b";
})(Merged.E || (Merged.E = {}));
var E = Merged.E;
(function (E) {
E[E["c"] = 3] = "c";
E[E["d"] = 4] = "d";
})(Merged.E || (Merged.E = {}));
var E = Merged.E;
})(Merged || (Merged = {}));
var abc;
var secondAbc;
var secondAbcd;
@@ -126,6 +152,7 @@ var secondCd;
var nope;
var k;
var decl;
var merged;
abc = secondAbc; // ok
abc = secondAbcd; // missing 'd'
abc = secondAb; // ok
@@ -138,6 +165,10 @@ secondAb = abc; // missing 'c'
secondCd = abc; // missing 'a' and 'b'
nope = abc; // nope!
decl = abc; // ok
k = k; // const is only assignable to itself
// const is only assignable to itself
k = k;
abc = k; // error
k = abc;
// merged enums compare all their members
abc = merged; // missing 'd'
merged = abc; // ok

View File

@@ -36,6 +36,14 @@ namespace Decl {
a, b, c = 3,
}
}
namespace Merged {
export enum E {
a, b,
}
export enum E {
c = 3, d,
}
}
var abc: First.E;
var secondAbc: Abc.E;
@@ -45,6 +53,7 @@ var secondCd: Cd.E;
var nope: Abc.Nope;
var k: Const.E;
var decl: Decl.E;
var merged: Merged.E;
abc = secondAbc; // ok
abc = secondAbcd; // missing 'd'
abc = secondAb; // ok
@@ -58,6 +67,11 @@ secondCd = abc; // missing 'a' and 'b'
nope = abc; // nope!
decl = abc; // ok
k = k; // const is only assignable to itself
// const is only assignable to itself
k = k;
abc = k; // error
k = abc;
// merged enums compare all their members
abc = merged; // missing 'd'
merged = abc; // ok