New test.
[mono.git] / mono / tests / delegate7.cs
1 using System;
2 using System.Runtime.InteropServices;
3
4 class Tests {
5         delegate void SimpleDelegate ();
6
7         public static int v = 0;
8         
9         static void F1 () {
10                 v += 1;
11                 Console.WriteLine ("Test.F1");
12         }
13         static void F2 () {
14                 v += 2;
15                 Console.WriteLine ("Test.F2");
16         }
17         static void F3 () {
18                 v += 4;
19                 Console.WriteLine ("Test.F3");
20         }
21
22         public static int Main () {
23                 return TestDriver.RunTests (typeof (Tests));
24         }
25
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);
31
32                 SimpleDelegate d12 = d1 + d2;
33                 SimpleDelegate d13 = d1 + d3;
34                 SimpleDelegate d23 = d2 + d3;
35                 SimpleDelegate d123 = d1 + d2 + d3;
36
37                 v = 0;
38                 t = d123 - d13;
39                 t ();
40                 if (v != 7)
41                         return 1;
42                 
43                 v = 0;
44                 t = d123 - d12;
45                 t ();
46                 if (v != 4)
47                         return 1;
48                 
49                 v = 0;
50                 t = d123 - d23;
51                 t ();
52                 if (v != 1)
53                         return 1;
54                 
55                 
56                 return 0;
57         }
58
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;
65         }
66 }