2010-06-17 Geoff Norton <gnorton@novell.com>
[mono.git] / mono / tests / enum2.cs
blob724d99da0b183dab2b27ba103eef8bc2a8bb3e39
1 using System;
3 enum A {
4 Hello,
5 Bye
8 class X {
10 static int Main ()
12 int num = 0;
14 object x = A.Hello;
15 object y = A.Bye;
17 num++;
18 if ((int)x != 0)
19 return num;
21 num++;
22 if ((int)y != 1)
23 return num;
25 num++;
26 if ("Hello" != A.Hello.ToString ())
27 return num;
29 num++;
30 if (!x.Equals(x))
31 return num;
33 num++;
34 if (x.Equals(y))
35 return num;
37 num++;
38 if (x.Equals(0))
39 return num;
41 num++;
42 Type et = x.GetType ();
43 object z = Enum.ToObject (et, Int64.MaxValue);
44 if ((int)z != -1)
45 return num;
47 num++;
48 z = Enum.ToObject (et, 0);
49 if (!x.Equals(z))
50 return num;
52 num++;
53 z = Enum.ToObject (et, 1);
54 if (!y.Equals(z))
55 return num;
57 num++;
58 z = Enum.Parse (et, "Bye");
59 if (!y.Equals(z))
60 return num;
62 num++;
63 try {
64 z = Enum.Parse (et, "bye");
65 } catch {
66 z = null;
68 if (z != null)
69 return num;
71 num++;
72 z = Enum.Parse (et, "bye", true);
73 if (!y.Equals(z))
74 return num;
76 return 0;