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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
using System;
public class Blah {
enum Bar {
a = MyEnum.Foo,
b = A.c,
c = MyEnum.Bar,
d = myconstant,
e = myconstant | 0x1fff
}
public enum MyEnum : byte {
Foo = 254,
Bar = (byte) B.y
}
enum A {
a, b, c
}
enum B {
x, y, z
}
enum AA : byte { a, b }
enum BB : ulong { x = ulong.MaxValue - 1, y }
const int myconstant = 30;
enum Compute : ulong {
two = AA.b + B.y,
three = AA.b - B.y,
four = A.a * BB.x,
five = AA.b >> B.y,
}
internal enum WindowAttributes : uint {
kWindowNoAttributes = 0,
kWindowCloseBoxAttribute = (1u << 0),
kWindowHorizontalZoomAttribute = (1u << 1),
kWindowVerticalZoomAttribute = (1u << 2),
kWindowCollapseBoxAttribute = (1u << 3),
kWindowNoConstrainAttribute = (1u << 31),
kWindowStandardFloatingAttributes = (kWindowCloseBoxAttribute | kWindowCollapseBoxAttribute)
}
// The constant assignment follows a different path
const Bar bar_assignment = 0;
public static int Main ()
{
byte b = (byte) MyEnum.Foo;
Console.WriteLine ("Foo has a value of " + b);
if (b != 254)
return 1;
int i = (int) A.a;
int j = (int) B.x;
int k = (int) A.c;
int l = (int) AA.b + 1;
if ((int) Compute.two != 2)
return 10;
if (i != j)
return 1;
if (k != l)
return 1;
A var = A.b;
i = (int) Bar.a;
if (i != 254)
return 1;
i = (int) Bar.b;
if (i != 2)
return 1;
j = (int) Bar.c;
if (j != 1)
return 1;
j = (int) Bar.d;
if (j != 30)
return 1;
Enum e = Bar.d;
if (e.ToString () != "d")
return 15;
//
// Test "U operator (E x, E x)"
//
// Notice that the Microsoft C# compiler wont compile the following
// code, that is a bug in their compiler, see section 14.7.5 of the
// spec.
if ((A.c - A.a) != 2)
return 16;
if ((A.c - 1) != A.b)
return 17;
Console.WriteLine ("Value: " + e.ToString ());
Console.WriteLine ("Enum emission test okay");
return 0;
}
}
|