2 using System.Reflection;
6 public override string ToString ()
33 public int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10;
34 public int a11, a12, a13, a14, a15, a16, a17, a18, a19, a20;
39 public static Enum1 return_enum1 () {
43 public static Enum2 return_enum2 () {
47 public static long return_long () {
51 public static ulong return_ulong () {
52 return UInt64.MaxValue - 5;
55 public static object return_t<T> (T t) {
59 static int Main (string[] args)
61 return TestDriver.RunTests (typeof (Tests), args);
64 public static int test_0_base () {
65 Assembly ass = typeof (Tests).Assembly;
66 Type a_type = ass.GetType ("A");
67 MethodInfo a_method = a_type.GetMethod ("ToString");
69 Type d_type = ass.GetType ("D");
70 MethodInfo d_method = d_type.GetMethod ("Test");
72 Console.WriteLine ("TEST: {0} {1}", a_method, d_method);
77 object a_ret = a_method.Invoke (a, null);
78 Console.WriteLine (a_ret);
80 object d_ret = d_method.Invoke (d, null);
81 Console.WriteLine (d_ret);
86 public static int test_0_enum_sharing () {
87 /* Check sharing of wrappers returning enums */
88 if (typeof (Tests).GetMethod ("return_enum1").Invoke (null, null).GetType () != typeof (Enum1))
90 if (typeof (Tests).GetMethod ("return_enum2").Invoke (null, null).GetType () != typeof (Enum2))
95 public static int test_0_primitive_sharing () {
96 /* Check sharing of wrappers returning primitive types */
97 if (typeof (Tests).GetMethod ("return_long").Invoke (null, null).GetType () != typeof (long))
99 if (typeof (Tests).GetMethod ("return_ulong").Invoke (null, null).GetType () != typeof (ulong))
107 public string ToString2 () {
112 public static object GetNSObject (IntPtr i) {
116 public static int test_0_vtype_method_sharing () {
117 /* Check sharing of wrappers of vtype methods with static methods having an IntPtr argument */
118 if ((string)(typeof (Foo).GetMethod ("ToString2").Invoke (new Foo (), null)) != "FOO")
120 object o = typeof (Tests).GetMethod ("GetNSObject").Invoke (null, new object [] { new IntPtr (42) });
121 if (!(o is IntPtr) || ((IntPtr)o != new IntPtr (42)))
127 public static unsafe int test_0_ptr () {
128 int[] arr = new int [10];
129 fixed (void *p = &arr [5]) {
130 object o = typeof (Tests).GetMethod ("data_types_ptr").Invoke (null, new object [1] { new IntPtr (p) });
131 void *p2 = Pointer.Unbox (o);
132 if (new IntPtr (p) != new IntPtr (p2))
135 o = typeof (Tests).GetMethod ("data_types_ptr").Invoke (null, new object [1] { null });
136 p2 = Pointer.Unbox (o);
137 if (new IntPtr (p2) != IntPtr.Zero)
144 public static int test_0_string_ctor () {
145 string res = (string)typeof (String).GetConstructor (new Type [] { typeof (char[]) }).Invoke (new object [] { new char [] { 'A', 'B', 'C' } });
152 public class Foo<T> {
156 public static int test_0_ginst_ref () {
157 Foo<string> f = new Foo<string> { t = "A" };
158 Foo<string> f2 = (Foo<string>)typeof (Tests).GetMethod ("data_types_ginst_ref").MakeGenericMethod (new Type [] { typeof (string) }).Invoke (null, new object [] { f });
165 public static int test_0_ginst_vtype () {
166 FooStruct<string> f = new FooStruct<string> { t = "A" };
167 FooStruct<string> f2 = (FooStruct<string>)typeof (Tests).GetMethod ("data_types_ginst_vtype").MakeGenericMethod (new Type [] { typeof (string) }).Invoke (null, new object [] { f });
174 public static Foo<T> data_types_ginst_ref<T> (Foo<T> f) {
178 public struct FooStruct<T> {
182 public static FooStruct<T> data_types_ginst_vtype<T> (FooStruct<T> f) {
186 public static unsafe int* data_types_ptr (int *val) {
187 //Console.WriteLine (new IntPtr (val));
191 public static bool pack_u2 (ushort us) {
195 public static bool pack_i2 (short value) {
197 // Force 'value' to be register allocated
198 for (int i = 0; i < value; ++i)
204 public static int test_0_i2_u2 () {
205 typeof (Tests).GetMethod ("pack_u2").Invoke (null, new object [] { (ushort)0 });
206 var res = typeof (Tests).GetMethod ("pack_i2").Invoke (null, new object [] { (short)-1 });
207 return (bool)res ? 0 : 1;
210 public static bool pack_bool (bool b) {
214 public static bool pack_i1 (sbyte value) {
216 // Force 'value' to be register allocated
217 for (int i = 0; i < value; ++i)
222 public static int test_0_i1_bool () {
223 typeof (Tests).GetMethod ("pack_bool").Invoke (null, new object [] { true });
224 var res = typeof (Tests).GetMethod ("pack_i1").Invoke (null, new object [] { (sbyte)-0x40 });
225 return (bool)res ? 0 : 1;
233 public Point Location {
235 return new Point () { x = 10, y = 20 };
240 public static int test_0_vtype_method_vtype_ret () {
242 var p = (Point)typeof (Foo2).GetMethod ("get_Location").Invoke (f, null);
243 if (p.x != 10 || p.y != 20)
248 public static int test_0_array_get_set () {
249 int[,,] arr = new int [10, 10, 10];
251 var gm = arr.GetType ().GetMethod ("Get");
252 int i = (int) gm.Invoke (arr, new object [] { 0, 1, 2 });
255 var sm = arr.GetType ().GetMethod ("Set");
256 sm.Invoke (arr, new object [] { 0, 1, 2, 33 });
257 if (arr [0, 1, 2] != 33)
262 public static int test_0_multi_dim_array_ctor () {
263 var type1 = Type.GetType ("System.Char[,]").GetTypeInfo ();
265 ConstructorInfo ci = null;
266 foreach (var c in type1.DeclaredConstructors) {
267 if (c.GetParameters ().Length == 4)
270 var res = ci.Invoke (new object[] { 1, 5, -10, 7 });
272 if (a.GetLength (0) != 5 || a.GetLowerBound (0) != 1 || a.GetLength (1) != 7 || a.GetLowerBound (1) != -10)
277 private static void method_invoke_no_modify_by_value_arg_helper (int dummy)
281 public static int test_0_method_invoke_no_modify_by_value_arg ()
283 var args = new object[] { null };
284 var method = typeof (Tests).GetMethod ("method_invoke_no_modify_by_value_arg_helper", BindingFlags.NonPublic | BindingFlags.Static);
285 method.Invoke (null, args);
292 public static int test_0_large_arg ()
294 var arg = new AStruct ();
299 var res = typeof (Tests).GetMethod ("return_t").MakeGenericMethod (new Type [] { typeof (AStruct) }).Invoke (null, new object [] { arg });
300 var arg2 = (AStruct)res;