cosmetic
[mcs.git] / tests / test-204.cs
blob3a003a31d96f3c809af43215ce114c83862aab33
1 using System;
3 class X
5 public readonly int x;
7 public X (int x)
9 this.x = x;
12 public override string ToString ()
14 return String.Format ("X ({0})", x);
17 public static X operator & (X a, X b)
19 return new X (a.x * b.x);
22 public static X operator | (X a, X b)
24 return new X (a.x + b.x);
27 // Returns true if the value is odd.
28 public static bool operator true (X x)
30 return (x.x % 2) != 0;
33 // Returns true if the value is even.
34 public static bool operator false (X x)
36 return (x.x % 2) == 0;
39 public static int Test ()
41 X x = new X (3);
42 X y = new X (4);
44 X t1 = x && y;
45 X t2 = y && x;
46 X t3 = x || y;
47 X t4 = y || x;
49 // Console.WriteLine ("TEST: {0} {1} {2} {3} {4} {5}", x, y, t1, t2, t3, t4);
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;
60 return 0;
63 public static int Main ()
65 int result = Test ();
66 Console.WriteLine ("RESULT: {0}", result);
67 return result;