Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Baulig <martin@novell.com>2003-07-14 20:49:40 +0400
committerMartin Baulig <martin@novell.com>2003-07-14 20:49:40 +0400
commit38bbe13433263889bad9c4656f985d05a2acac97 (patch)
tree4506e9b2014ff4b7ed49811e4d0d510cddd3b622 /mcs/tests/test-204.cs
parent6872f858c1b7b6685fa88000108aa81176eafd5a (diff)
2003-07-14 Martin Baulig <martin@ximian.com>
* test-204.cs: User defined conditional logical operators; bug #40505. 2003-07-14 Martin Baulig <martin@ximian.com> * test-203.cs: Added test for bug #33026. svn path=/trunk/mcs/; revision=16226
Diffstat (limited to 'mcs/tests/test-204.cs')
-rw-r--r--mcs/tests/test-204.cs69
1 files changed, 69 insertions, 0 deletions
diff --git a/mcs/tests/test-204.cs b/mcs/tests/test-204.cs
new file mode 100644
index 00000000000..3a003a31d96
--- /dev/null
+++ b/mcs/tests/test-204.cs
@@ -0,0 +1,69 @@
+using System;
+
+class X
+{
+ public readonly int x;
+
+ public X (int x)
+ {
+ this.x = x;
+ }
+
+ public override string ToString ()
+ {
+ return String.Format ("X ({0})", x);
+ }
+
+ public static X operator & (X a, X b)
+ {
+ return new X (a.x * b.x);
+ }
+
+ public static X operator | (X a, X b)
+ {
+ return new X (a.x + b.x);
+ }
+
+ // Returns true if the value is odd.
+ public static bool operator true (X x)
+ {
+ return (x.x % 2) != 0;
+ }
+
+ // Returns true if the value is even.
+ public static bool operator false (X x)
+ {
+ return (x.x % 2) == 0;
+ }
+
+ public static int Test ()
+ {
+ X x = new X (3);
+ X y = new X (4);
+
+ X t1 = x && y;
+ X t2 = y && x;
+ X t3 = x || y;
+ X t4 = y || x;
+
+ // Console.WriteLine ("TEST: {0} {1} {2} {3} {4} {5}", x, y, t1, t2, t3, t4);
+
+ if (t1.x != 12)
+ return 1;
+ if (t2.x != 4)
+ return 2;
+ if (t3.x != 3)
+ return 3;
+ if (t4.x != 7)
+ return 4;
+
+ return 0;
+ }
+
+ public static int Main ()
+ {
+ int result = Test ();
+ Console.WriteLine ("RESULT: {0}", result);
+ return result;
+ }
+}