2008-04-10 Mark Probst <mark.probst@gmail.com>
[mono.git] / mono / tests / generic-delegate.2.cs
1 public class ClassA {}
2
3 public delegate int IntDelegate (int x);
4 public delegate T[] TDelegate<T> ();
5
6 public class Gen<T> {
7         public int intFunction (int x) {
8                 return x + 1;
9         }
10
11         public IntDelegate getIntDelegate () {
12                 return intFunction;
13         }
14
15         public virtual int virtIntFunction (int x) {
16                 return x + 2;
17         }
18
19         public IntDelegate getVirtIntDelegate () {
20                 return virtIntFunction;
21         }
22
23         public T[] tFunction () {
24                 return new T[3];
25         }
26
27         public TDelegate<T> getTDelegate () {
28                 return tFunction;
29         }
30
31         public static T[] staticTFunction () {
32                 return new T[3];
33         }
34
35         public TDelegate<T> getStaticTDelegate () {
36                 return staticTFunction;
37         }
38 }
39
40 public class main {
41         public static int Main () {
42                 Gen<ClassA> ga = new Gen<ClassA> ();
43                 IntDelegate id = ga.getIntDelegate ();
44                 TDelegate<ClassA> tda = ga.getTDelegate ();
45                 IntDelegate vid = ga.getVirtIntDelegate ();
46                 TDelegate<ClassA> stda = ga.getStaticTDelegate ();
47
48                 if (id (123) != 124)
49                         return 1;
50                 if (tda ().GetType () != typeof (ClassA[]))
51                         return 1;
52                 if (vid (123) != 125)
53                         return 1;
54                 if (stda ().GetType () != typeof (ClassA[]))
55                         return 1;
56                 return 0;
57         }
58 }