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))
98 public string ToString2 () {
103 public static object GetNSObject (IntPtr i) {
107 public static int test_0_vtype_method_sharing () {
108 /* Check sharing of wrappers of vtype methods with static methods having an IntPtr argument */
109 if ((string)(typeof (Foo).GetMethod ("ToString2").Invoke (new Foo (), null)) != "FOO")
111 object o = typeof (Tests).GetMethod ("GetNSObject").Invoke (null, new object [] { new IntPtr (42) });
112 if (!(o is IntPtr) || ((IntPtr)o != new IntPtr (42)))
118 public static unsafe int test_0_ptr () {
119 int[] arr = new int [10];
120 fixed (void *p = &arr [5]) {
121 object o = typeof (Tests).GetMethod ("data_types_ptr").Invoke (null, new object [1] { new IntPtr (p) });
122 void *p2 = Pointer.Unbox (o);
123 if (new IntPtr (p) != new IntPtr (p2))
126 o = typeof (Tests).GetMethod ("data_types_ptr").Invoke (null, new object [1] { null });
127 p2 = Pointer.Unbox (o);
128 if (new IntPtr (p2) != IntPtr.Zero)
135 public static int test_42_int () {
136 return (int)typeof (Tests).GetMethod ("data_types_int").Invoke (null, new object [] { Int32.MinValue, UInt32.MaxValue });
139 public static int test_42_short () {
140 return (short)typeof (Tests).GetMethod ("data_types_short").Invoke (null, new object [] { short.MinValue, ushort.MaxValue });
143 public static int test_0_bool_char () {
144 if ((int)typeof (Tests).GetMethod ("data_types_bool_char").Invoke (null, new object [] { true, false, 'A' }) != 0)
149 public static int test_0_byref_int () {
150 if ((int)typeof (Tests).GetMethod ("data_types_byref_int").Invoke (null, new object [] { 42 }) != 0)
155 public static int test_0_long () {
156 if ((long)typeof (Tests).GetMethod ("data_types_long").Invoke (null, new object [] { 0x123456789L, (ulong)0x123456789L }) == 0x12345678AL)
162 public static int test_0_float_ret () {
163 if ((float)typeof (Tests).GetMethod ("data_types_float_ret").Invoke (null, new object [] { }) == 0.123f)
169 public static int test_0_double_ret () {
170 if ((double)typeof (Tests).GetMethod ("data_types_double_ret").Invoke (null, new object [] { }) == 0.123f)
176 public class Foo<T> {
180 public static int test_0_ginst_ref () {
181 Foo<string> f = new Foo<string> { t = "A" };
182 Foo<string> f2 = (Foo<string>)typeof (Tests).GetMethod ("data_types_ginst_ref").MakeGenericMethod (new Type [] { typeof (string) }).Invoke (null, new object [] { f });
189 public static int test_0_ginst_vtype () {
190 FooStruct<string> f = new FooStruct<string> { t = "A" };
191 FooStruct<string> f2 = (FooStruct<string>)typeof (Tests).GetMethod ("data_types_ginst_vtype").MakeGenericMethod (new Type [] { typeof (string) }).Invoke (null, new object [] { f });
198 public static Foo<T> data_types_ginst_ref<T> (Foo<T> f) {
202 public struct FooStruct<T> {
206 public static FooStruct<T> data_types_ginst_vtype<T> (FooStruct<T> f) {
210 public static int data_types_int (int i, uint ui) {
211 if (i == Int32.MinValue && ui == UInt32.MaxValue)
217 public static short data_types_short (short i, ushort ui) {
218 if (i == short.MinValue && ui == ushort.MaxValue)
224 public static int data_types_bool_char (bool b1, bool b2, char c) {
225 if (b1 == true && b2 == false && c == 'A')
231 public static int data_types_byref_int (ref int i) {
238 public static long data_types_long (long i, ulong ui) {
239 if (i == 0x123456789L && ui == 0x123456789L)
245 public static float data_types_float_ret () {
249 public static double data_types_double_ret () {
253 public static unsafe int* data_types_ptr (int *val) {
254 //Console.WriteLine (new IntPtr (val));