Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mcs / tests / test-631.cs
1 using System;
2
3 enum E : uint
4 {
5         Value = 24
6 }
7
8 class A
9 {
10         public static implicit operator sbyte (A mask)
11         {
12                 return 1;
13         }
14
15         public static implicit operator byte (A mask)
16         {
17                 return 2;
18         }
19
20         public static implicit operator short (A mask)
21         {
22                 return 3;
23         }
24
25         public static implicit operator ushort (A mask)
26         {
27                 return 4;
28         }
29
30         public static implicit operator int (A mask)
31         {
32                 return 5;
33         }
34
35         public static implicit operator uint (A mask)
36         {
37                 return 6;
38         }
39
40         public static implicit operator long (A mask)
41         {
42                 return 7;
43         }
44
45         public static implicit operator ulong (A mask)
46         {
47                 return 8;
48         }
49 }
50
51 class A2
52 {
53         public static implicit operator sbyte (A2 mask)
54         {
55                 return 1;
56         }
57
58         public static implicit operator byte (A2 mask)
59         {
60                 return 2;
61         }
62
63         public static implicit operator short (A2 mask)
64         {
65                 return 3;
66         }
67
68         public static implicit operator uint (A2 mask)
69         {
70                 return 6;
71         }
72
73         public static implicit operator long (A2 mask)
74         {
75                 return 7;
76         }
77
78         public static implicit operator ulong (A2 mask)
79         {
80                 return 8;
81         }
82 }
83
84 class A3
85 {
86         public static implicit operator sbyte (A3 mask)
87         {
88                 return 1;
89         }
90
91         public static implicit operator uint (A3 mask)
92         {
93                 return 6;
94         }
95
96         public static implicit operator long (A3 mask)
97         {
98                 return 7;
99         }
100
101         public static implicit operator ulong (A3 mask)
102         {
103                 return 8;
104         }
105 }
106
107 class A4
108 {
109         public static implicit operator uint (A4 mask)
110         {
111                 return 6;
112         }
113
114         public static implicit operator long (A4 mask)
115         {
116                 return 7;
117         }
118
119         public static implicit operator ulong (A4 mask)
120         {
121                 return 8;
122         }
123 }
124
125 class A5
126 {
127         public static implicit operator uint (A5 mask)
128         {
129                 return 6;
130         }
131
132         public static implicit operator int (A5 mask)
133         {
134                 return 8;
135         }
136 }
137
138 class A6
139 {
140         public static implicit operator byte (A6 mask)
141         {
142                 return 2;
143         }
144 }
145
146 class MyDecimal
147 {
148         public static implicit operator decimal (MyDecimal d)
149         {
150                 return 42;
151         }
152 }
153
154 public class Constraint
155 {
156         public static int Main ()
157         {
158                 A a = null;
159                 A2 a2 = null;
160                 A3 a3 = null;
161                 A4 a4 = null;
162                 A5 a5 = null;
163                 A6 a6 = null;
164
165                 if (-a != -5)
166                         return 1;
167                 if (-a2 != -3)
168                         return 2;
169                 if (-a3 != -1)
170                         return 3;
171                 if (-a4 != -7)
172                         return 4;
173                 if (-a5 != -8)
174                         return 5;
175                 if (-a6 != -2)
176                         return 6;
177
178                 if (~a != -6)
179                         return 10;
180                 if (~a2 != -4)
181                         return 11;
182                 if (~a3 != -2)
183                         return 12;
184                 if (~a4 != 4294967289)
185                         return 13;
186                 if (~a5 != -9)
187                         return 14;
188                 if (~a6 != -3)
189                         return 15;
190
191                 MyDecimal d = new MyDecimal ();
192                 if (-d != -42)
193                         return 20;
194
195                 E e = E.Value;
196                 if (~e != (E)4294967271)
197                         return 21;
198                         
199                 uint dp = 0;
200                 dp = +dp;                       
201
202                 Console.WriteLine ("OK");
203                 return 0;
204         }
205
206 }