Skip to content

Commit ff01388

Browse files
committed
Add tests from review
1 parent cc1d8cf commit ff01388

File tree

3 files changed

+77
-7
lines changed

3 files changed

+77
-7
lines changed

tests/baselines/reference/enumAssignmentCompat3.errors.txt

+31-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
tests/cases/compiler/enumAssignmentCompat3.ts(37,1): error TS2322: Type 'Abcd.E' is not assignable to type 'First.E'.
1+
tests/cases/compiler/enumAssignmentCompat3.ts(49,1): error TS2322: Type 'Abcd.E' is not assignable to type 'First.E'.
22
Property 'd' is missing in type 'First.E'.
3-
tests/cases/compiler/enumAssignmentCompat3.ts(39,1): error TS2322: Type 'Cd.E' is not assignable to type 'First.E'.
3+
tests/cases/compiler/enumAssignmentCompat3.ts(51,1): error TS2322: Type 'Cd.E' is not assignable to type 'First.E'.
44
Property 'd' is missing in type 'First.E'.
5-
tests/cases/compiler/enumAssignmentCompat3.ts(40,1): error TS2322: Type 'Nope' is not assignable to type 'E'.
6-
tests/cases/compiler/enumAssignmentCompat3.ts(43,1): error TS2322: Type 'First.E' is not assignable to type 'Ab.E'.
5+
tests/cases/compiler/enumAssignmentCompat3.ts(52,1): error TS2322: Type 'Nope' is not assignable to type 'E'.
6+
tests/cases/compiler/enumAssignmentCompat3.ts(56,1): error TS2322: Type 'First.E' is not assignable to type 'Ab.E'.
77
Property 'c' is missing in type 'Ab.E'.
8-
tests/cases/compiler/enumAssignmentCompat3.ts(44,1): error TS2322: Type 'First.E' is not assignable to type 'Cd.E'.
8+
tests/cases/compiler/enumAssignmentCompat3.ts(57,1): error TS2322: Type 'First.E' is not assignable to type 'Cd.E'.
99
Property 'a' is missing in type 'Cd.E'.
10-
tests/cases/compiler/enumAssignmentCompat3.ts(45,1): error TS2322: Type 'E' is not assignable to type 'Nope'.
10+
tests/cases/compiler/enumAssignmentCompat3.ts(58,1): error TS2322: Type 'E' is not assignable to type 'Nope'.
11+
tests/cases/compiler/enumAssignmentCompat3.ts(62,1): error TS2322: Type 'Const.E' is not assignable to type 'First.E'.
12+
tests/cases/compiler/enumAssignmentCompat3.ts(63,1): error TS2322: Type 'First.E' is not assignable to type 'Const.E'.
1113

1214

13-
==== tests/cases/compiler/enumAssignmentCompat3.ts (6 errors) ====
15+
==== tests/cases/compiler/enumAssignmentCompat3.ts (8 errors) ====
1416
namespace First {
1517
export enum E {
1618
a, b, c,
@@ -39,13 +41,25 @@ tests/cases/compiler/enumAssignmentCompat3.ts(45,1): error TS2322: Type 'E' is n
3941
c, d,
4042
}
4143
}
44+
namespace Const {
45+
export const enum E {
46+
a, b, c,
47+
}
48+
}
49+
namespace Decl {
50+
export declare enum E {
51+
a, b, c = 3,
52+
}
53+
}
4254

4355
var abc: First.E;
4456
var secondAbc: Abc.E;
4557
var secondAbcd: Abcd.E;
4658
var secondAb: Ab.E;
4759
var secondCd: Cd.E;
4860
var nope: Abc.Nope;
61+
var k: Const.E;
62+
var decl: Decl.E;
4963
abc = secondAbc; // ok
5064
abc = secondAbcd; // missing 'd'
5165
~~~
@@ -59,6 +73,7 @@ tests/cases/compiler/enumAssignmentCompat3.ts(45,1): error TS2322: Type 'E' is n
5973
abc = nope; // nope!
6074
~~~
6175
!!! error TS2322: Type 'Nope' is not assignable to type 'E'.
76+
abc = decl; // ok
6277
secondAbc = abc; // ok
6378
secondAbcd = abc; // ok
6479
secondAb = abc; // missing 'c'
@@ -72,4 +87,13 @@ tests/cases/compiler/enumAssignmentCompat3.ts(45,1): error TS2322: Type 'E' is n
7287
nope = abc; // nope!
7388
~~~~
7489
!!! error TS2322: Type 'E' is not assignable to type 'Nope'.
90+
decl = abc; // ok
91+
92+
k = k; // const is only assignable to itself
93+
abc = k; // error
94+
~~~
95+
!!! error TS2322: Type 'Const.E' is not assignable to type 'First.E'.
96+
k = abc;
97+
~
98+
!!! error TS2322: Type 'First.E' is not assignable to type 'Const.E'.
7599

tests/baselines/reference/enumAssignmentCompat3.js

+28
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,41 @@ namespace Cd {
2727
c, d,
2828
}
2929
}
30+
namespace Const {
31+
export const enum E {
32+
a, b, c,
33+
}
34+
}
35+
namespace Decl {
36+
export declare enum E {
37+
a, b, c = 3,
38+
}
39+
}
3040

3141
var abc: First.E;
3242
var secondAbc: Abc.E;
3343
var secondAbcd: Abcd.E;
3444
var secondAb: Ab.E;
3545
var secondCd: Cd.E;
3646
var nope: Abc.Nope;
47+
var k: Const.E;
48+
var decl: Decl.E;
3749
abc = secondAbc; // ok
3850
abc = secondAbcd; // missing 'd'
3951
abc = secondAb; // ok
4052
abc = secondCd; // missing 'd'
4153
abc = nope; // nope!
54+
abc = decl; // ok
4255
secondAbc = abc; // ok
4356
secondAbcd = abc; // ok
4457
secondAb = abc; // missing 'c'
4558
secondCd = abc; // missing 'a' and 'b'
4659
nope = abc; // nope!
60+
decl = abc; // ok
61+
62+
k = k; // const is only assignable to itself
63+
abc = k; // error
64+
k = abc;
4765

4866

4967
//// [enumAssignmentCompat3.js]
@@ -97,19 +115,29 @@ var Cd;
97115
})(Cd.E || (Cd.E = {}));
98116
var E = Cd.E;
99117
})(Cd || (Cd = {}));
118+
var Decl;
119+
(function (Decl) {
120+
})(Decl || (Decl = {}));
100121
var abc;
101122
var secondAbc;
102123
var secondAbcd;
103124
var secondAb;
104125
var secondCd;
105126
var nope;
127+
var k;
128+
var decl;
106129
abc = secondAbc; // ok
107130
abc = secondAbcd; // missing 'd'
108131
abc = secondAb; // ok
109132
abc = secondCd; // missing 'd'
110133
abc = nope; // nope!
134+
abc = decl; // ok
111135
secondAbc = abc; // ok
112136
secondAbcd = abc; // ok
113137
secondAb = abc; // missing 'c'
114138
secondCd = abc; // missing 'a' and 'b'
115139
nope = abc; // nope!
140+
decl = abc; // ok
141+
k = k; // const is only assignable to itself
142+
abc = k; // error
143+
k = abc;

tests/cases/compiler/enumAssignmentCompat3.ts

+18
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,38 @@ namespace Cd {
2626
c, d,
2727
}
2828
}
29+
namespace Const {
30+
export const enum E {
31+
a, b, c,
32+
}
33+
}
34+
namespace Decl {
35+
export declare enum E {
36+
a, b, c = 3,
37+
}
38+
}
2939

3040
var abc: First.E;
3141
var secondAbc: Abc.E;
3242
var secondAbcd: Abcd.E;
3343
var secondAb: Ab.E;
3444
var secondCd: Cd.E;
3545
var nope: Abc.Nope;
46+
var k: Const.E;
47+
var decl: Decl.E;
3648
abc = secondAbc; // ok
3749
abc = secondAbcd; // missing 'd'
3850
abc = secondAb; // ok
3951
abc = secondCd; // missing 'd'
4052
abc = nope; // nope!
53+
abc = decl; // ok
4154
secondAbc = abc; // ok
4255
secondAbcd = abc; // ok
4356
secondAb = abc; // missing 'c'
4457
secondCd = abc; // missing 'a' and 'b'
4558
nope = abc; // nope!
59+
decl = abc; // ok
60+
61+
k = k; // const is only assignable to itself
62+
abc = k; // error
63+
k = abc;

0 commit comments

Comments
 (0)