Allow passing null to JsonArray.Add()
[mono.git] / mcs / tests / test-26.cs
1 using System;
2
3 public class Blah {
4
5         public delegate int MyDelegate (int i, int j);
6         
7         public int Foo (int i, int j)
8         {
9                 return i+j;
10         }
11
12         public static int Test1 ()
13         {
14                 Blah f = new Blah ();
15
16                 MyDelegate del = new MyDelegate (f.Foo);
17
18                 MyDelegate another = new MyDelegate (del);
19
20                 int number = del (2, 3);
21
22                 int i = another (4, 6);
23                 
24                 Console.WriteLine ("Delegate invocation of one returned : " + number);
25
26                 Console.WriteLine ("Delegate invocation of the other returned : " + i);
27
28                 if (number == 5 && i == 10)
29                         return 0;
30                 else
31                         return 1;
32         }
33         
34         public delegate int List (params int [] args);
35
36         public static int Adder (params int [] args)
37         {
38                 int total = 0;
39                 
40                 foreach (int i in args)
41                         total += i;
42
43                 return total;
44         }
45
46         public static int Test2 ()
47         {
48                 List my_adder = new List (Adder);
49
50                 if (my_adder (1, 2, 3) != 6)
51                         return 2;
52
53                 return 0;
54         }
55         
56         public static int Main ()
57         {
58                 int v;
59
60                 v = Test1 ();
61                 if (v != 0)
62                         return v;
63
64                 v = Test2 ();
65                 if (v != 0)
66                         return v;
67
68                 Console.WriteLine ("All tests pass");
69                 return 0;
70         }
71
72 }