New test.
[mono.git] / mcs / tests / test-40.cs
1 using System;
2
3 public class Blah {
4
5         enum Bar {
6                 a = MyEnum.Foo,
7                 b = A.c,
8                 c = MyEnum.Bar,
9                 d = myconstant,
10                 e = myconstant | 0x1fff
11         }
12         
13         public enum MyEnum : byte {
14                 Foo = 254,
15                 Bar = (byte) B.y
16         }
17
18         enum A {
19                 a, b, c
20         }
21         
22         enum B {
23                 x, y, z
24         }
25         
26         enum AA : byte { a, b }
27         enum BB : ulong { x, y }
28
29         const int myconstant = 30;
30
31         enum Compute { two = AA.b + B.y }
32         
33         // The constant assignment follows a different path             
34         const Bar bar_assignment = 0;
35         
36         public static int Main ()
37         {
38                 byte b = (byte) MyEnum.Foo;
39                 
40                 Console.WriteLine ("Foo has a value of " + b);
41
42                 if (b != 254)
43                         return 1;
44                 
45                 int i = (int) A.a;
46                 int j = (int) B.x;
47                 int k = (int) A.c;
48                 int l = (int) AA.b + 1;
49
50                 if ((int) Compute.two != 2)
51                         return 10;
52                 if (i != j)
53                         return 1;
54
55                 if (k != l)
56                         return 1;
57
58                 A var = A.b;
59
60                 i = (int) Bar.a;
61
62                 if (i != 254)
63                         return 1;
64
65                 i = (int) Bar.b;
66
67                 if (i != 2)
68                         return 1;
69
70                 j = (int) Bar.c;
71
72                 if (j != 1)
73                         return 1;
74
75                 j = (int) Bar.d;
76
77                 if (j != 30)
78                         return 1;
79
80                 Enum e = Bar.d;
81                 if (e.ToString () != "d")
82                         return 15;
83
84                 //
85                 // Test "U operator (E x, E x)"
86                 //
87                 // Notice that the Microsoft C# compiler wont compile the following
88                 // code, that is a bug in their compiler, see section 14.7.5 of the
89                 // spec.
90
91                 if ((A.c - A.a) != 2)
92                         return 16;
93
94                 if ((A.c - 1) != A.b)
95                         return 17;
96                 
97                 Console.WriteLine ("Value: " + e.ToString ());
98                 Console.WriteLine ("Enum emission test okay");
99                 return 0;
100         }
101 }