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 ("DYNCALL")]
110 [Category ("GSHAREDVT")]
111 static int test_0_arm64_dyncall_gsharedvt_out_hfa_double () {
112 /* gsharedvt out trampoline with double hfa argument */
115 var s = new Struct1 ();
118 // Call Foo2.Get_T directly, so its gets an instance
119 Foo2<Struct1>.Get_T (arg1, s);
120 Type t = typeof (Foo3<>).MakeGenericType (new Type [] { typeof (Struct1) });
121 // Call Foo3.Get_T, this will call the gsharedvt instance, which will call the non-gsharedvt instance
122 var s_res = (Struct1)t.GetMethod ("Get_T").Invoke (null, new object [] { arg1, s });
123 if (s_res.a != 1.0f || s_res.b != 2.0f)
128 [Category ("DYNCALL")]
129 [Category ("GSHAREDVT")]
130 static int test_0_arm64_dyncall_gsharedvt_out_hfa_float () {
131 /* gsharedvt out trampoline with double hfa argument */
134 var s = new Struct2 ();
137 // Call Foo2.Get_T directly, so its gets an instance
138 Foo2<Struct2>.Get_T (arg1, s);
139 Type t = typeof (Foo3<>).MakeGenericType (new Type [] { typeof (Struct2) });
140 // Call Foo3.Get_T, this will call the gsharedvt instance, which will call the non-gsharedvt instance
141 var s_res = (Struct2)t.GetMethod ("Get_T").Invoke (null, new object [] { arg1, s });
142 if (s_res.a != 1.0f || s_res.b != 2.0f)
147 interface IFaceFoo4<T> {
148 T Get_T (double d, T t);
149 T Get_T2 (double d, T t);
152 class Foo4<T> : IFaceFoo4<T> {
153 public T Get_T (double d, T t) {
154 return Foo2<T>.Get_T (d, t);
156 public T Get_T2 (double d, T t) {
157 return Foo2<T>.Get_T2 (d, 1, 2, 3, 4, 5, 6, 7, 8, t);
161 struct VTypeByRefStruct {
162 public long o1, o2, o3;
165 [Category ("GSHAREDVT")]
166 public static int test_0_arm64_gsharedvt_out_vtypebyref () {
167 /* gsharedvt out trampoline with vtypebyref argument */
168 var s = new VTypeByRefStruct () { o1 = 1, o2 = 2, o3 = 3 };
170 // Call Foo2.Get_T directly, so its gets an instance
171 Foo2<VTypeByRefStruct>.Get_T (1.0f, s);
172 var o = (IFaceFoo4<VTypeByRefStruct>)Activator.CreateInstance (typeof (Foo4<>).MakeGenericType (new Type [] { typeof (VTypeByRefStruct) }));
173 // Call Foo4.Get_T, this will call the gsharedvt instance, which will call the non-gsharedvt instance
174 var s_res = o.Get_T (1.0f, s);
175 if (s_res.o1 != 1 || s_res.o2 != 2 || s_res.o3 != 3)
177 // Same with the byref argument passed on the stack
178 s_res = o.Get_T2 (1.0f, s);
179 if (s_res.o1 != 1 || s_res.o2 != 2 || s_res.o3 != 3)
185 public static T Get_T (object o) {
190 [Category ("DYNCALL")]
191 static int test_0_arm64_dyncall_vtypebyref_ret () {
192 var s = new VTypeByRefStruct () { o1 = 1, o2 = 2, o3 = 3 };
193 Type t = typeof (Foo5<>).MakeGenericType (new Type [] { typeof (VTypeByRefStruct) });
194 var o = Activator.CreateInstance (t);
196 var s_res = (VTypeByRefStruct)t.GetMethod ("Get_T").Invoke (o, new object [] { s });
197 if (s_res.o1 != 1 || s_res.o2 != 2 || s_res.o3 != 3)
199 } catch (TargetInvocationException) {
205 static int test_0_partial_sharing_regress_30204 () {
206 var t = typeof (System.Collections.Generic.Comparer<System.Collections.Generic.KeyValuePair<string, string>>);
207 var d = new SortedDictionary<string, string> ();
208 d.Add ("key1", "banana");
209 return d ["key1"] == "banana" ? 0 : 1;
212 class NullableMethods {
213 [MethodImplAttribute (MethodImplOptions.NoInlining)]
214 public static bool GetHasValue<T>(Nullable<T> value) where T : struct {
215 return value.HasValue;
218 [MethodImplAttribute (MethodImplOptions.NoInlining)]
219 public static T GetValue<T>(Nullable<T> value) where T : struct {
224 [Category ("DYNCALL")]
225 public static int test_0_dyncall_nullable () {
229 NullableMethods.GetHasValue (v);
230 bool b = (bool)typeof (NullableMethods).GetMethod ("GetHasValue").MakeGenericMethod (new Type [] { typeof (int) }).Invoke (null, new object [] { v });
234 b = (bool)typeof (NullableMethods).GetMethod ("GetHasValue").MakeGenericMethod (new Type [] { typeof (int) }).Invoke (null, new object [] { v });
239 NullableMethods.GetValue (v);
240 var res = (int)typeof (NullableMethods).GetMethod ("GetValue").MakeGenericMethod (new Type [] { typeof (int) }).Invoke (null, new object [] { v });
251 public static int test_0_enum_eq_comparer () {
252 var c = EqualityComparer<AnEnum>.Default;
253 return (!c.Equals (AnEnum.A, AnEnum.B) && c.Equals (AnEnum.A, AnEnum.A)) ? 0 : 1;
256 public static int test_0_enum_comparer () {
257 var c = Comparer<AnEnum>.Default;
258 return c.Compare (AnEnum.A, AnEnum.A);