new test
authorDietmar Maurer <dietmar@mono-cvs.ximian.com>
Mon, 5 Aug 2002 16:45:03 +0000 (16:45 -0000)
committerDietmar Maurer <dietmar@mono-cvs.ximian.com>
Mon, 5 Aug 2002 16:45:03 +0000 (16:45 -0000)
svn path=/trunk/mono/; revision=6434

mono/tests/Makefile.am
mono/tests/delegate7.cs [new file with mode: 0644]

index 5c2dc98379ea4eafb71a2cbea36eb758c0be5e4a..231ed4fc04ef1c8f228017bc6fb5fd8a40bc1ac1 100644 (file)
@@ -111,6 +111,8 @@ TEST_CS_SRC=                        \
        delegate3.cs            \
        delegate4.cs            \
        delegate5.cs            \
+       delegate6.cs            \
+       delegate7.cs            \
        remoting1.cs            \
        remoting2.cs            \
        remoting3.cs            \
diff --git a/mono/tests/delegate7.cs b/mono/tests/delegate7.cs
new file mode 100644 (file)
index 0000000..e98ea40
--- /dev/null
@@ -0,0 +1,54 @@
+using System;
+using System.Runtime.InteropServices;
+
+class Test {
+       delegate void SimpleDelegate ();
+
+       public static int v = 0;
+       
+       static void F1 () {
+               v += 1;
+               Console.WriteLine ("Test.F1");
+       }
+       static void F2 () {
+               v += 2;
+               Console.WriteLine ("Test.F2");
+       }
+       static void F3 () {
+               v += 4;
+               Console.WriteLine ("Test.F3");
+       }
+
+       static int Main () {
+               SimpleDelegate t;
+               SimpleDelegate d1 = new SimpleDelegate (F1);
+               SimpleDelegate d2 = new SimpleDelegate (F2);
+               SimpleDelegate d3 = new SimpleDelegate (F3);
+
+               SimpleDelegate d12 = d1 + d2;
+               SimpleDelegate d13 = d1 + d3;
+               SimpleDelegate d23 = d2 + d3;
+               SimpleDelegate d123 = d1 + d2 + d3;
+
+               v = 0;
+               t = d123 - d13;
+               t ();
+               if (v != 7)
+                       return 1;
+               
+               v = 0;
+               t = d123 - d12;
+               t ();
+               if (v != 4)
+                       return 1;
+               
+               v = 0;
+               t = d123 - d23;
+               t ();
+               if (v != 1)
+                       return 1;
+               
+               
+               return 0;
+       }
+}