blob: 3787fe6b9e2bb9f65d41f4d03faca181c37a5f9c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
//
// This test exhibits an old bug where we did not
// go into the underlying type for an enumeration, and
// hence implicit and explicit casts were not working when
// they were going from a type to an enum
//
namespace N1
{
public enum A
{
A_1, A_2, A_3
}
public class B
{
static bool ShortCasting ()
{
short i = 0;
N1.A a = N1.A.A_1;
i = (short) a; //<- crash
a = (N1.A)i;//<- used to fail, can't convert
if (a != N1.A.A_1)
return false;
return true;
}
static bool IntCasting ()
{
int i = 0;
N1.A a = N1.A.A_1;
i = (int) a;//<- works fine
a = (N1.A)i;//<- used to fail, can't convert
if (a != N1.A.A_1)
return false;
return true;
}
static int Main ()
{
if (!IntCasting ())
return 1;
if (!ShortCasting ())
return 2;
return 0;
}
}
}
|