2 using System.Reflection;
6 public override string ToString ()
34 public static Enum1 return_enum1 () {
38 public static Enum2 return_enum2 () {
42 public static long return_long () {
46 public static ulong return_ulong () {
47 return UInt64.MaxValue - 5;
50 static int Main (string[] args)
52 return TestDriver.RunTests (typeof (Tests), args);
55 public static int test_0_base () {
56 Assembly ass = typeof (Tests).Assembly;
57 Type a_type = ass.GetType ("A");
58 MethodInfo a_method = a_type.GetMethod ("ToString");
60 Type d_type = ass.GetType ("D");
61 MethodInfo d_method = d_type.GetMethod ("Test");
63 Console.WriteLine ("TEST: {0} {1}", a_method, d_method);
68 object a_ret = a_method.Invoke (a, null);
69 Console.WriteLine (a_ret);
71 object d_ret = d_method.Invoke (d, null);
72 Console.WriteLine (d_ret);
77 public static int test_0_enum_sharing () {
78 /* Check sharing of wrappers returning enums */
79 if (typeof (Tests).GetMethod ("return_enum1").Invoke (null, null).GetType () != typeof (Enum1))
81 if (typeof (Tests).GetMethod ("return_enum2").Invoke (null, null).GetType () != typeof (Enum2))
86 public static int test_0_primitive_sharing () {
87 /* Check sharing of wrappers returning primitive types */
88 if (typeof (Tests).GetMethod ("return_long").Invoke (null, null).GetType () != typeof (long))
90 if (typeof (Tests).GetMethod ("return_ulong").Invoke (null, null).GetType () != typeof (ulong))
96 public static unsafe int test_0_ptr () {
97 int[] arr = new int [10];
98 fixed (void *p = &arr [5]) {
99 object o = typeof (Tests).GetMethod ("Test").Invoke (null, new object [1] { new IntPtr (p) });
100 void *p2 = Pointer.Unbox (o);
101 if (new IntPtr (p) != new IntPtr (p2))
104 o = typeof (Tests).GetMethod ("Test").Invoke (null, new object [1] { null });
105 p2 = Pointer.Unbox (o);
106 if (new IntPtr (p2) != IntPtr.Zero)
113 public static unsafe int* Test (int *val) {
114 Console.WriteLine (new IntPtr (val));