Merge pull request #5675 from mono/glib-debug-symbols
[mono.git] / mcs / tests / test-204.cs
1 using System;
2
3 class X
4 {
5         public readonly int x;
6
7         public X (int x)
8         {
9                 this.x = x;
10         }
11
12         public override string ToString ()
13         {
14                 return String.Format ("X ({0})", x);
15         }
16
17         public static X operator & (X a, X b)
18         {
19                 return new X (a.x * b.x);
20         }
21
22         public static X operator | (X a, X b)
23         {
24                 return new X (a.x + b.x);
25         }
26
27         // Returns true if the value is odd.
28         public static bool operator true (X x)
29         {
30                 return (x.x % 2) != 0;
31         }
32
33         // Returns true if the value is even.
34         public static bool operator false (X x)
35         {
36                 return (x.x % 2) == 0;
37         }
38
39         public static int Test ()
40         {
41                 X x = new X (3);
42                 X y = new X (4);
43
44                 X t1 = x && y;
45                 X t2 = y && x;
46                 X t3 = x || y;
47                 X t4 = y || x;
48
49                 // Console.WriteLine ("TEST: {0} {1} {2} {3} {4} {5}", x, y, t1, t2, t3, t4);
50
51                 if (t1.x != 12)
52                         return 1;
53                 if (t2.x != 4)
54                         return 2;
55                 if (t3.x != 3)
56                         return 3;
57                 if (t4.x != 7)
58                         return 4;
59
60                 return 0;
61         }
62
63         public static int Main ()
64         {
65                 int result = Test ();
66                 Console.WriteLine ("RESULT: {0}", result);
67                 return result;
68         }
69 }