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