3 using System.Reflection;
4 using System.Runtime.InteropServices;
5 using System.Runtime.CompilerServices;
6 using System.Collections.Generic;
9 * Regression tests for the AOT/FULL-AOT code.
19 static int Main (String[] args) {
20 return TestDriver.RunTests (typeof (Tests), args);
24 public delegate void ArrayDelegate (int[,] arr);
26 static int test_0_array_delegate_full_aot () {
27 ArrayDelegate d = delegate (int[,] arr) {
29 int[,] a = new int[5, 6];
30 d.BeginInvoke (a, null, null);
43 /* The 'd' argument is used to shift the register indexes so 't' doesn't start at the first reg */
44 public static T Get_T (double d, T t) {
50 public static T Get_T (double d, T t) {
53 public static T Get_T2 (double d, int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, T t) {
59 public static T Get_T (double d, T t) {
60 return Foo2<T>.Get_T (d, t);
64 [Category ("DYNCALL")]
65 static int test_0_arm64_dyncall_double () {
68 var res = (double)typeof (Foo<double>).GetMethod ("Get_T").Invoke (null, new object [] { arg1, s });
74 [Category ("DYNCALL")]
75 static int test_0_arm64_dyncall_float () {
78 var res = (float)typeof (Foo<float>).GetMethod ("Get_T").Invoke (null, new object [] { arg1, s });
84 [Category ("DYNCALL")]
85 static int test_0_arm64_dyncall_hfa_double () {
87 // HFA with double members
88 var s = new Struct1 ();
91 var s_res = (Struct1)typeof (Foo<Struct1>).GetMethod ("Get_T").Invoke (null, new object [] { arg1, s });
92 if (s_res.a != 1.0f || s_res.b != 2.0f)
97 [Category ("DYNCALL")]
98 static int test_0_arm64_dyncall_hfa_float () {
100 var s = new Struct2 ();
103 var s_res = (Struct2)typeof (Foo<Struct2>).GetMethod ("Get_T").Invoke (null, new object [] { arg1, s });
104 if (s_res.a != 1.0f || s_res.b != 2.0f)
109 [Category ("GSHAREDVT")]
110 static int test_0_arm64_dyncall_gsharedvt_out_hfa_double () {
111 /* gsharedvt out trampoline with double hfa argument */
114 var s = new Struct1 ();
117 // Call Foo2.Get_T directly, so its gets an instance
118 Foo2<Struct1>.Get_T (arg1, s);
119 Type t = typeof (Foo3<>).MakeGenericType (new Type [] { typeof (Struct1) });
120 // Call Foo3.Get_T, this will call the gsharedvt instance, which will call the non-gsharedvt instance
121 var s_res = (Struct1)t.GetMethod ("Get_T").Invoke (null, new object [] { arg1, s });
122 if (s_res.a != 1.0f || s_res.b != 2.0f)
127 [Category ("GSHAREDVT")]
128 static int test_0_arm64_dyncall_gsharedvt_out_hfa_float () {
129 /* gsharedvt out trampoline with double hfa argument */
132 var s = new Struct2 ();
135 // Call Foo2.Get_T directly, so its gets an instance
136 Foo2<Struct2>.Get_T (arg1, s);
137 Type t = typeof (Foo3<>).MakeGenericType (new Type [] { typeof (Struct2) });
138 // Call Foo3.Get_T, this will call the gsharedvt instance, which will call the non-gsharedvt instance
139 var s_res = (Struct2)t.GetMethod ("Get_T").Invoke (null, new object [] { arg1, s });
140 if (s_res.a != 1.0f || s_res.b != 2.0f)
145 interface IFaceFoo4<T> {
146 T Get_T (double d, T t);
147 T Get_T2 (double d, T t);
150 class Foo4<T> : IFaceFoo4<T> {
151 public T Get_T (double d, T t) {
152 return Foo2<T>.Get_T (d, t);
154 public T Get_T2 (double d, T t) {
155 return Foo2<T>.Get_T2 (d, 1, 2, 3, 4, 5, 6, 7, 8, t);
159 struct VTypeByRefStruct {
160 public long o1, o2, o3;
163 [Category ("GSHAREDVT")]
164 public static int test_0_arm64_gsharedvt_out_vtypebyref () {
165 /* gsharedvt out trampoline with vtypebyref argument */
166 var s = new VTypeByRefStruct () { o1 = 1, o2 = 2, o3 = 3 };
168 // Call Foo2.Get_T directly, so its gets an instance
169 Foo2<VTypeByRefStruct>.Get_T (1.0f, s);
170 var o = (IFaceFoo4<VTypeByRefStruct>)Activator.CreateInstance (typeof (Foo4<>).MakeGenericType (new Type [] { typeof (VTypeByRefStruct) }));
171 // Call Foo4.Get_T, this will call the gsharedvt instance, which will call the non-gsharedvt instance
172 var s_res = o.Get_T (1.0f, s);
173 if (s_res.o1 != 1 || s_res.o2 != 2 || s_res.o3 != 3)
175 // Same with the byref argument passed on the stack
176 s_res = o.Get_T2 (1.0f, s);
177 if (s_res.o1 != 1 || s_res.o2 != 2 || s_res.o3 != 3)
183 public static T Get_T (object o) {
188 [Category ("DYNCALL")]
189 static int test_0_arm64_dyncall_vtypebyref_ret () {
190 var s = new VTypeByRefStruct () { o1 = 1, o2 = 2, o3 = 3 };
191 Type t = typeof (Foo5<>).MakeGenericType (new Type [] { typeof (VTypeByRefStruct) });
192 var o = Activator.CreateInstance (t);
194 var s_res = (VTypeByRefStruct)t.GetMethod ("Get_T").Invoke (o, new object [] { s });
195 if (s_res.o1 != 1 || s_res.o2 != 2 || s_res.o3 != 3)
197 } catch (TargetInvocationException) {
203 static int test_0_partial_sharing_regress_30204 () {
204 var t = typeof (System.Collections.Generic.Comparer<System.Collections.Generic.KeyValuePair<string, string>>);
205 var d = new SortedDictionary<string, string> ();
206 d.Add ("key1", "banana");
207 return d ["key1"] == "banana" ? 0 : 1;
210 class NullableMethods {
211 [MethodImplAttribute (MethodImplOptions.NoInlining)]
212 public static bool GetHasValue<T>(Nullable<T> value) where T : struct {
213 return value.HasValue;
216 [MethodImplAttribute (MethodImplOptions.NoInlining)]
217 public static T GetValue<T>(Nullable<T> value) where T : struct {
222 [Category ("DYNCALL")]
223 public static int test_0_dyncall_nullable () {
227 NullableMethods.GetHasValue (v);
228 bool b = (bool)typeof (NullableMethods).GetMethod ("GetHasValue").MakeGenericMethod (new Type [] { typeof (int) }).Invoke (null, new object [] { v });
232 b = (bool)typeof (NullableMethods).GetMethod ("GetHasValue").MakeGenericMethod (new Type [] { typeof (int) }).Invoke (null, new object [] { v });
237 NullableMethods.GetValue (v);
238 var res = (int)typeof (NullableMethods).GetMethod ("GetValue").MakeGenericMethod (new Type [] { typeof (int) }).Invoke (null, new object [] { v });