2010-06-21 Rodrigo Kumpera <rkumpera@novell.com>
[mono.git] / mono / tests / delegate7.cs
blob6e1fe94e17ae896af4f52d07276956143371704f
1 using System;
2 using System.Runtime.InteropServices;
4 class Tests {
5 delegate void SimpleDelegate ();
7 public static int v = 0;
9 static void F1 () {
10 v += 1;
11 Console.WriteLine ("Test.F1");
13 static void F2 () {
14 v += 2;
15 Console.WriteLine ("Test.F2");
17 static void F3 () {
18 v += 4;
19 Console.WriteLine ("Test.F3");
22 public static int Main () {
23 return TestDriver.RunTests (typeof (Tests));
26 static public int test_0_test () {
27 SimpleDelegate t;
28 SimpleDelegate d1 = new SimpleDelegate (F1);
29 SimpleDelegate d2 = new SimpleDelegate (F2);
30 SimpleDelegate d3 = new SimpleDelegate (F3);
32 SimpleDelegate d12 = d1 + d2;
33 SimpleDelegate d13 = d1 + d3;
34 SimpleDelegate d23 = d2 + d3;
35 SimpleDelegate d123 = d1 + d2 + d3;
37 v = 0;
38 t = d123 - d13;
39 t ();
40 if (v != 7)
41 return 1;
43 v = 0;
44 t = d123 - d12;
45 t ();
46 if (v != 4)
47 return 1;
49 v = 0;
50 t = d123 - d23;
51 t ();
52 if (v != 1)
53 return 1;
56 return 0;
59 // Regression test for bug #50366
60 static public int test_0_delegate_equality () {
61 if (new SimpleDelegate (F1) == new SimpleDelegate (F1))
62 return 0;
63 else
64 return 1;