2003-01-10 Dietmar Maurer <dietmar@ximian.com>
[mono.git] / mono / tests / invoke.cs
1 using System;
2 using System.Reflection;
3
4 class Test {
5         
6         public struct SimpleStruct {
7                 public bool a;
8                 public bool b;
9         }
10         
11         static void Test2 () {
12                 Console.WriteLine ("Test2 called");
13         }
14         
15         public static SimpleStruct Test1 (SimpleStruct ss) {
16                 Console.WriteLine ("Test1 called " + ss.a + " " + ss.b);
17                 SimpleStruct res = new SimpleStruct ();
18                 res.a = !ss.a;
19                 res.b = !ss.b;
20                 return res;
21         }
22         
23         static int Main () {
24                 Type t = typeof (Test);
25
26                 MethodInfo m2 = t.GetMethod ("Test2");
27                 if (m2 != null)
28                         return 1;
29
30                 MethodInfo m1 = t.GetMethod ("Test1");
31                 if (m1 == null)
32                         return 1;
33
34                 object [] args = new object [1];
35                 SimpleStruct ss = new SimpleStruct ();
36                 ss.a = true;
37                 ss.b = false;
38                 args [0] = ss;
39                 
40                 SimpleStruct res = (SimpleStruct)m1.Invoke (null, args);
41
42                 if (res.a == true)
43                         return 1;
44                 if (res.b == false)
45                         return 1;
46         
47                 return 0;
48         }
49 }