[build] Fix warning (#4177)
[mono-project.git] / mcs / tests / test-40.cs
blobd62f1adabdc68275f4a573ec32c7e75d3d4552b1
1 using System;
3 public class Blah {
5 enum Bar {
6 a = MyEnum.Foo,
7 b = A.c,
8 c = MyEnum.Bar,
9 d = myconstant,
10 e = myconstant | 0x1fff
13 public enum MyEnum : byte {
14 Foo = 254,
15 Bar = (byte) B.y
18 enum A {
19 a, b, c
22 enum B {
23 x, y, z
26 enum AA : byte { a, b }
27 enum BB : ulong { x = ulong.MaxValue - 1, y }
29 const int myconstant = 30;
31 enum Compute : ulong {
32 two = AA.b + B.y,
33 three = AA.b - B.y,
34 four = A.a * BB.x,
35 five = AA.b >> B.y,
38 internal enum WindowAttributes : uint {
39 kWindowNoAttributes = 0,
40 kWindowCloseBoxAttribute = (1u << 0),
41 kWindowHorizontalZoomAttribute = (1u << 1),
42 kWindowVerticalZoomAttribute = (1u << 2),
43 kWindowCollapseBoxAttribute = (1u << 3),
44 kWindowNoConstrainAttribute = (1u << 31),
45 kWindowStandardFloatingAttributes = (kWindowCloseBoxAttribute | kWindowCollapseBoxAttribute)
48 // The constant assignment follows a different path
49 const Bar bar_assignment = 0;
51 public static int Main ()
53 byte b = (byte) MyEnum.Foo;
55 Console.WriteLine ("Foo has a value of " + b);
57 if (b != 254)
58 return 1;
60 int i = (int) A.a;
61 int j = (int) B.x;
62 int k = (int) A.c;
63 int l = (int) AA.b + 1;
65 if ((int) Compute.two != 2)
66 return 10;
67 if (i != j)
68 return 1;
70 if (k != l)
71 return 1;
73 A var = A.b;
75 i = (int) Bar.a;
77 if (i != 254)
78 return 1;
80 i = (int) Bar.b;
82 if (i != 2)
83 return 1;
85 j = (int) Bar.c;
87 if (j != 1)
88 return 1;
90 j = (int) Bar.d;
92 if (j != 30)
93 return 1;
95 Enum e = Bar.d;
96 if (e.ToString () != "d")
97 return 15;
100 // Test "U operator (E x, E x)"
102 // Notice that the Microsoft C# compiler wont compile the following
103 // code, that is a bug in their compiler, see section 14.7.5 of the
104 // spec.
106 if ((A.c - A.a) != 2)
107 return 16;
109 if ((A.c - 1) != A.b)
110 return 17;
112 Console.WriteLine ("Value: " + e.ToString ());
113 Console.WriteLine ("Enum emission test okay");
114 return 0;