new test
[mono.git] / mono / tests / delegate7.cs
1 using System;
2 using System.Runtime.InteropServices;
3
4 class Test {
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         static int Main () {
23                 SimpleDelegate t;
24                 SimpleDelegate d1 = new SimpleDelegate (F1);
25                 SimpleDelegate d2 = new SimpleDelegate (F2);
26                 SimpleDelegate d3 = new SimpleDelegate (F3);
27
28                 SimpleDelegate d12 = d1 + d2;
29                 SimpleDelegate d13 = d1 + d3;
30                 SimpleDelegate d23 = d2 + d3;
31                 SimpleDelegate d123 = d1 + d2 + d3;
32
33                 v = 0;
34                 t = d123 - d13;
35                 t ();
36                 if (v != 7)
37                         return 1;
38                 
39                 v = 0;
40                 t = d123 - d12;
41                 t ();
42                 if (v != 4)
43                         return 1;
44                 
45                 v = 0;
46                 t = d123 - d23;
47                 t ();
48                 if (v != 1)
49                         return 1;
50                 
51                 
52                 return 0;
53         }
54 }