Add test case and accept baseline

This commit is contained in:
Nathan Shively-Sanders 2015-12-10 11:05:25 -08:00
parent 6cd5a4dac9
commit 6ed5b59f75
3 changed files with 235 additions and 0 deletions

View file

@ -0,0 +1,75 @@
tests/cases/compiler/enumAssignmentCompat3.ts(37,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(39,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(40,1): error TS2322: Type 'Nope' is not assignable to type 'E'.
tests/cases/compiler/enumAssignmentCompat3.ts(43,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(44,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(45,1): error TS2322: Type 'E' is not assignable to type 'Nope'.
==== tests/cases/compiler/enumAssignmentCompat3.ts (6 errors) ====
namespace First {
export enum E {
a, b, c,
}
}
namespace Abc {
export enum E {
a, b, c,
}
export enum Nope {
a, b, c,
}
}
namespace Abcd {
export enum E {
a, b, c, d,
}
}
namespace Ab {
export enum E {
a, b,
}
}
namespace Cd {
export enum E {
c, d,
}
}
var abc: First.E;
var secondAbc: Abc.E;
var secondAbcd: Abcd.E;
var secondAb: Ab.E;
var secondCd: Cd.E;
var nope: Abc.Nope;
abc = secondAbc; // ok
abc = secondAbcd; // missing 'd'
~~~
!!! error TS2322: Type 'Abcd.E' is not assignable to type 'First.E'.
!!! error TS2322: Property 'd' is missing in type 'First.E'.
abc = secondAb; // ok
abc = secondCd; // missing 'd'
~~~
!!! error TS2322: Type 'Cd.E' is not assignable to type 'First.E'.
!!! error TS2322: Property 'd' is missing in type 'First.E'.
abc = nope; // nope!
~~~
!!! error TS2322: Type 'Nope' is not assignable to type 'E'.
secondAbc = abc; // ok
secondAbcd = abc; // ok
secondAb = abc; // missing 'c'
~~~~~~~~
!!! error TS2322: Type 'First.E' is not assignable to type 'Ab.E'.
!!! error TS2322: Property 'c' is missing in type 'Ab.E'.
secondCd = abc; // missing 'a' and 'b'
~~~~~~~~
!!! error TS2322: Type 'First.E' is not assignable to type 'Cd.E'.
!!! error TS2322: Property 'a' is missing in type 'Cd.E'.
nope = abc; // nope!
~~~~
!!! error TS2322: Type 'E' is not assignable to type 'Nope'.

View file

@ -0,0 +1,115 @@
//// [enumAssignmentCompat3.ts]
namespace First {
export enum E {
a, b, c,
}
}
namespace Abc {
export enum E {
a, b, c,
}
export enum Nope {
a, b, c,
}
}
namespace Abcd {
export enum E {
a, b, c, d,
}
}
namespace Ab {
export enum E {
a, b,
}
}
namespace Cd {
export enum E {
c, d,
}
}
var abc: First.E;
var secondAbc: Abc.E;
var secondAbcd: Abcd.E;
var secondAb: Ab.E;
var secondCd: Cd.E;
var nope: Abc.Nope;
abc = secondAbc; // ok
abc = secondAbcd; // missing 'd'
abc = secondAb; // ok
abc = secondCd; // missing 'd'
abc = nope; // nope!
secondAbc = abc; // ok
secondAbcd = abc; // ok
secondAb = abc; // missing 'c'
secondCd = abc; // missing 'a' and 'b'
nope = abc; // nope!
//// [enumAssignmentCompat3.js]
var First;
(function (First) {
(function (E) {
E[E["a"] = 0] = "a";
E[E["b"] = 1] = "b";
E[E["c"] = 2] = "c";
})(First.E || (First.E = {}));
var E = First.E;
})(First || (First = {}));
var Abc;
(function (Abc) {
(function (E) {
E[E["a"] = 0] = "a";
E[E["b"] = 1] = "b";
E[E["c"] = 2] = "c";
})(Abc.E || (Abc.E = {}));
var E = Abc.E;
(function (Nope) {
Nope[Nope["a"] = 0] = "a";
Nope[Nope["b"] = 1] = "b";
Nope[Nope["c"] = 2] = "c";
})(Abc.Nope || (Abc.Nope = {}));
var Nope = Abc.Nope;
})(Abc || (Abc = {}));
var Abcd;
(function (Abcd) {
(function (E) {
E[E["a"] = 0] = "a";
E[E["b"] = 1] = "b";
E[E["c"] = 2] = "c";
E[E["d"] = 3] = "d";
})(Abcd.E || (Abcd.E = {}));
var E = Abcd.E;
})(Abcd || (Abcd = {}));
var Ab;
(function (Ab) {
(function (E) {
E[E["a"] = 0] = "a";
E[E["b"] = 1] = "b";
})(Ab.E || (Ab.E = {}));
var E = Ab.E;
})(Ab || (Ab = {}));
var Cd;
(function (Cd) {
(function (E) {
E[E["c"] = 0] = "c";
E[E["d"] = 1] = "d";
})(Cd.E || (Cd.E = {}));
var E = Cd.E;
})(Cd || (Cd = {}));
var abc;
var secondAbc;
var secondAbcd;
var secondAb;
var secondCd;
var nope;
abc = secondAbc; // ok
abc = secondAbcd; // missing 'd'
abc = secondAb; // ok
abc = secondCd; // missing 'd'
abc = nope; // nope!
secondAbc = abc; // ok
secondAbcd = abc; // ok
secondAb = abc; // missing 'c'
secondCd = abc; // missing 'a' and 'b'
nope = abc; // nope!

View file

@ -0,0 +1,45 @@
namespace First {
export enum E {
a, b, c,
}
}
namespace Abc {
export enum E {
a, b, c,
}
export enum Nope {
a, b, c,
}
}
namespace Abcd {
export enum E {
a, b, c, d,
}
}
namespace Ab {
export enum E {
a, b,
}
}
namespace Cd {
export enum E {
c, d,
}
}
var abc: First.E;
var secondAbc: Abc.E;
var secondAbcd: Abcd.E;
var secondAb: Ab.E;
var secondCd: Cd.E;
var nope: Abc.Nope;
abc = secondAbc; // ok
abc = secondAbcd; // missing 'd'
abc = secondAb; // ok
abc = secondCd; // missing 'd'
abc = nope; // nope!
secondAbc = abc; // ok
secondAbcd = abc; // ok
secondAb = abc; // missing 'c'
secondCd = abc; // missing 'a' and 'b'
nope = abc; // nope!