"disable_omit_fp" can now be included in MONO_DEBUG
[mono-project.git] / mcs / tests / gtest-269.cs
blob9c7dc6438740539f8275d81d33d36214e9b06064
1 using System;
3 [Flags]
4 enum IrishBeer {
5 Stout = 0x1000,
6 Ale = 0x2000,
7 Lager = 0x3000,
9 Guinness = 1 | Stout,
10 Smithwicks = 2 | Ale
13 struct IrishPub
15 public readonly IrishBeer Beer;
17 public IrishPub (IrishBeer beer)
19 this.Beer = beer;
22 public static implicit operator long (IrishPub? pub)
24 return pub.HasValue ? (long) pub.Value.Beer : 0;
27 public static implicit operator IrishPub? (long value)
29 return new IrishPub ((IrishBeer) value);
33 class X
35 static int Beer (IrishPub? pub)
37 switch (pub) {
38 case 0x1001:
39 return 1;
41 case 0x2002:
42 return 2;
44 default:
45 return 3;
49 static long PubToLong (IrishPub pub)
51 return pub;
54 static int Test (int? a)
56 switch (a) {
57 case 0:
58 return 0;
60 case 3:
61 return 1;
63 default:
64 return 2;
68 static int TestWithNull (int? a)
70 switch (a) {
71 case 0:
72 return 0;
74 case 3:
75 return 1;
77 case null:
78 return 2;
80 default:
81 return 3;
85 static long? Foo (bool flag)
87 if (flag)
88 return 4;
89 else
90 return null;
93 static int Test (bool flag)
95 switch (Foo (flag)) {
96 case 0:
97 return 0;
99 case 4:
100 return 1;
102 default:
103 return 2;
107 public static int Main ()
109 IrishPub pub = new IrishPub (IrishBeer.Guinness);
110 if (PubToLong (pub) != 0x1001)
111 return 1;
113 if (Beer (null) != 3)
114 return 2;
115 if (Beer (new IrishPub (IrishBeer.Guinness)) != 1)
116 return 3;
118 if (Test (null) != 2)
119 return 4;
120 if (Test (3) != 1)
121 return 5;
122 if (Test (true) != 1)
123 return 6;
124 if (Test (false) != 2)
125 return 7;
127 if (TestWithNull (null) != 2)
128 return 8;
129 if (TestWithNull (3) != 1)
130 return 9;
132 return 0;