Merge pull request #4327 from vkargov/vk-abcremedy
[mono.git] / mcs / tests / test-99.cs
1 //
2 // Tests the resulting value of operator + (U x, E y)
3 // as well as implicit conversions in the above operator.
4 //
5 using System;
6 class X {
7         enum A : int {
8                 a = 1, b, c
9         }
10         
11         enum Test : short {
12                 A = 1,
13                 B
14         }
15         
16         public static int Main ()
17         {
18                 int v = 1;
19                 object foo = (v + A.a);
20                 object foo2 = (1 + A.a);
21
22                 if (foo.GetType ().ToString () != "X+A"){
23                         Console.WriteLine ("Expression evaluator bug in E operator + (U x, E y)");
24                         return 1;
25                 }
26                 
27                 if (foo2.GetType ().ToString () != "X+A"){
28                         Console.WriteLine ("Constant folder bug in E operator + (U x, E y)");
29                         return 2;
30                 }
31
32                 // Now try the implicit conversions for underlying types in enum operators
33                 byte b = 1;
34                 short s = (short) (Test.A + b);
35                 
36                 const int e = A.b + 1 - A.a;
37
38                 //
39                 // Make sure that other operators still work
40                 if (Test.A != Test.A)
41                         return 3;
42                 if (Test.A == Test.B)
43                         return 4;
44                 
45                 return 0;
46         }
47 }