[runtime] Transition the trampoline code to use memory managers for memory allocation...
[mono-project.git] / mono / mini / aot-tests.cs
bloba468d005635f92f94788f41d920c657a539ec6f2
1 using System;
2 using System.Text;
3 using System.Linq;
4 using System.Reflection;
5 using System.Runtime.InteropServices;
6 using System.Runtime.CompilerServices;
7 using System.Collections;
8 using System.Collections.Generic;
9 using System.Collections.ObjectModel;
12 * Regression tests for the AOT/FULL-AOT code.
15 #if __MOBILE__
16 class AotTests
17 #else
18 class Tests
19 #endif
21 #if !__MOBILE__
22 static int Main (String[] args) {
23 return TestDriver.RunTests (typeof (Tests), args);
25 #endif
27 public delegate void ArrayDelegate (int[,] arr);
29 [Category ("!WASM")] //Requires a working threadpool
30 static int test_0_array_delegate_full_aot () {
31 ArrayDelegate d = delegate (int[,] arr) {
33 int[,] a = new int[5, 6];
34 d.BeginInvoke (a, null, null);
35 return 0;
38 struct Struct1 {
39 public double a, b;
42 struct Struct2 {
43 public float a, b;
46 class Foo<T> {
47 /* The 'd' argument is used to shift the register indexes so 't' doesn't start at the first reg */
48 public static T Get_T (double d, T t) {
49 return t;
53 class Foo2<T> {
54 public static T Get_T (double d, T t) {
55 return t;
57 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) {
58 return t;
60 public static T Get_T3 (double d, int i, T t) {
61 return t;
63 public static T Get_T4 (int i, double d, T t)
65 return t;
69 class Foo3<T> {
70 public static T Get_T (double d, T t) {
71 return Foo2<T>.Get_T (d, t);
75 [Category ("DYNCALL")]
76 static int test_0_arm64_dyncall_double () {
77 double arg1 = 1.0f;
78 double s = 2.0f;
79 var res = (double)typeof (Foo<double>).GetMethod ("Get_T").Invoke (null, new object [] { arg1, s });
80 if (res != 2.0f)
81 return 1;
82 return 0;
85 [Category ("DYNCALL")]
86 static int test_0_arm64_dyncall_float () {
87 double arg1 = 1.0f;
88 float s = 2.0f;
89 var res = (float)typeof (Foo<float>).GetMethod ("Get_T").Invoke (null, new object [] { arg1, s });
90 if (res != 2.0f)
91 return 1;
92 return 0;
95 [Category ("DYNCALL")]
96 static int test_0_amd64_dyncall_double_int_double ()
98 double arg1 = 1.0f;
99 int arg2 = 1;
100 double s = 2.0f;
101 var res = (double)typeof (Foo2<double>).GetMethod ("Get_T3").Invoke (null, new object [] { arg1, arg2, s });
102 if (res != 2.0f)
103 return 1;
104 return 0;
107 [Category ("DYNCALL")]
108 static int test_0_amd64_dyncall_double_int_float ()
110 double arg1 = 1.0f;
111 int arg2 = 1;
112 float s = 2.0f;
113 var res = (float)typeof (Foo2<float>).GetMethod ("Get_T3").Invoke (null, new object [] { arg1, arg2, s });
114 if (res != 2.0f)
115 return 1;
116 return 0;
119 [Category ("DYNCALL")]
120 static int test_0_amd64_dyncall_int_double_int ()
122 int arg1 = 1;
123 double arg2 = 1.0f;
124 int s = 2;
125 var res = (int)typeof (Foo2<int>).GetMethod ("Get_T4").Invoke (null, new object [] { arg1, arg2, s });
126 if (res != 2)
127 return 1;
128 return 0;
131 [Category ("DYNCALL")]
132 static int test_0_amd64_dyncall_int_double_ref ()
134 int arg1 = 1;
135 double arg2 = 1.0f;
136 object s = new object ();
137 var res = (object)typeof (Foo2<object>).GetMethod ("Get_T4").Invoke (null, new object [] { arg1, arg2, s });
138 if (res != s)
139 return 1;
140 return 0;
143 [Category ("DYNCALL")]
144 static int test_0_arm64_dyncall_hfa_double () {
145 double arg1 = 1.0f;
146 // HFA with double members
147 var s = new Struct1 ();
148 s.a = 1.0f;
149 s.b = 2.0f;
150 var s_res = (Struct1)typeof (Foo<Struct1>).GetMethod ("Get_T").Invoke (null, new object [] { arg1, s });
151 if (s_res.a != 1.0f || s_res.b != 2.0f)
152 return 1;
153 return 0;
156 [Category ("DYNCALL")]
157 static int test_0_arm64_dyncall_hfa_float () {
158 double arg1 = 1.0f;
159 var s = new Struct2 ();
160 s.a = 1.0f;
161 s.b = 2.0f;
162 var s_res = (Struct2)typeof (Foo<Struct2>).GetMethod ("Get_T").Invoke (null, new object [] { arg1, s });
163 if (s_res.a != 1.0f || s_res.b != 2.0f)
164 return 1;
165 return 0;
168 [Category ("DYNCALL")]
169 static int test_0_amd64_dyncall_use_stack_float ()
171 float s = 10.0f;
172 var res = (float)typeof (Foo2<float>).GetMethod ("Get_T2").Invoke (null, new object [] { 1.0f, 2, 3, 4, 5, 6, 7, 8, 9, s });
173 if (res != s)
174 return 1;
175 return 0;
178 [Category ("DYNCALL")]
179 static int test_0_amd64_dyncall_use_stack_double ()
181 double s = 10.0f;
182 var res = (double)typeof (Foo2<double>).GetMethod ("Get_T2").Invoke (null, new object [] { 1.0f, 2, 3, 4, 5, 6, 7, 8, 9, s });
183 if (res != s)
184 return 1;
185 return 0;
188 [Category ("DYNCALL")]
189 static int test_0_amd64_dyncall_use_stack_int ()
191 int s = 10;
192 var res = (int)typeof (Foo2<int>).GetMethod ("Get_T2").Invoke (null, new object [] { 1.0f, 2, 3, 4, 5, 6, 7, 8, 9, s });
193 if (res != s)
194 return 1;
195 return 0;
198 [Category ("DYNCALL")]
199 static int test_0_amd64_dyncall_use_stack_ref ()
201 object s = new object ();
202 var res = (object)typeof (Foo2<object>).GetMethod ("Get_T2").Invoke (null, new object [] { 1.0f, 2, 3, 4, 5, 6, 7, 8, 9, s });
203 if (res != s)
204 return 1;
205 return 0;
208 [Category ("DYNCALL")]
209 static int test_0_amd64_dyncall_use_stack_struct ()
211 Struct1 s = new Struct1 ();
212 s.a = 10.0f;
213 s.b = 11.0f;
214 var res = (Struct1)typeof (Foo2<Struct1>).GetMethod ("Get_T2").Invoke (null, new object [] { 1.0f, 2, 3, 4, 5, 6, 7, 8, 9, s });
215 if (res.a != s.a || res.b != s.b)
216 return 1;
217 return 0;
220 [Category ("DYNCALL")]
221 [Category ("GSHAREDVT")]
222 static int test_0_arm64_dyncall_gsharedvt_out_hfa_double () {
223 /* gsharedvt out trampoline with double hfa argument */
224 double arg1 = 1.0f;
226 var s = new Struct1 ();
227 s.a = 1.0f;
228 s.b = 2.0f;
229 // Call Foo2.Get_T directly, so its gets an instance
230 Foo2<Struct1>.Get_T (arg1, s);
231 Type t = typeof (Foo3<>).MakeGenericType (new Type [] { typeof (Struct1) });
232 // Call Foo3.Get_T, this will call the gsharedvt instance, which will call the non-gsharedvt instance
233 var s_res = (Struct1)t.GetMethod ("Get_T").Invoke (null, new object [] { arg1, s });
234 if (s_res.a != 1.0f || s_res.b != 2.0f)
235 return 1;
236 return 0;
239 [Category ("DYNCALL")]
240 [Category ("GSHAREDVT")]
241 static int test_0_arm64_dyncall_gsharedvt_out_hfa_float () {
242 /* gsharedvt out trampoline with double hfa argument */
243 double arg1 = 1.0f;
245 var s = new Struct2 ();
246 s.a = 1.0f;
247 s.b = 2.0f;
248 // Call Foo2.Get_T directly, so its gets an instance
249 Foo2<Struct2>.Get_T (arg1, s);
250 Type t = typeof (Foo3<>).MakeGenericType (new Type [] { typeof (Struct2) });
251 // Call Foo3.Get_T, this will call the gsharedvt instance, which will call the non-gsharedvt instance
252 var s_res = (Struct2)t.GetMethod ("Get_T").Invoke (null, new object [] { arg1, s });
253 if (s_res.a != 1.0f || s_res.b != 2.0f)
254 return 1;
255 return 0;
258 interface IFaceFoo4<T> {
259 T Get_T (double d, T t);
260 T Get_T2 (double d, T t);
263 class Foo4<T> : IFaceFoo4<T> {
264 public T Get_T (double d, T t) {
265 return Foo2<T>.Get_T (d, t);
267 public T Get_T2 (double d, T t) {
268 return Foo2<T>.Get_T2 (d, 1, 2, 3, 4, 5, 6, 7, 8, t);
272 struct VTypeByRefStruct {
273 public long o1, o2, o3;
276 [Category ("GSHAREDVT")]
277 public static int test_0_arm64_gsharedvt_out_vtypebyref () {
278 /* gsharedvt out trampoline with vtypebyref argument */
279 var s = new VTypeByRefStruct () { o1 = 1, o2 = 2, o3 = 3 };
281 // Call Foo2.Get_T directly, so its gets an instance
282 Foo2<VTypeByRefStruct>.Get_T (1.0f, s);
283 var o = (IFaceFoo4<VTypeByRefStruct>)Activator.CreateInstance (typeof (Foo4<>).MakeGenericType (new Type [] { typeof (VTypeByRefStruct) }));
284 // Call Foo4.Get_T, this will call the gsharedvt instance, which will call the non-gsharedvt instance
285 var s_res = o.Get_T (1.0f, s);
286 if (s_res.o1 != 1 || s_res.o2 != 2 || s_res.o3 != 3)
287 return 1;
288 // Same with the byref argument passed on the stack
289 s_res = o.Get_T2 (1.0f, s);
290 if (s_res.o1 != 1 || s_res.o2 != 2 || s_res.o3 != 3)
291 return 2;
292 return 0;
295 class Foo5<T> {
296 public static T Get_T (object o) {
297 return (T)o;
300 public static long vtype_by_val<T1, T2, T3, T4, T5> (T1 t1, T2 t2, T3 t3, T4 t4, long? t5) {
301 return (long)t5;
305 [Category ("DYNCALL")]
306 [Category ("GSHAREDVT")]
307 static int test_0_arm64_dyncall_vtypebyref_ret () {
308 var s = new VTypeByRefStruct () { o1 = 1, o2 = 2, o3 = 3 };
309 Type t = typeof (Foo5<>).MakeGenericType (new Type [] { typeof (VTypeByRefStruct) });
310 var o = Activator.CreateInstance (t);
311 try {
312 var s_res = (VTypeByRefStruct)t.GetMethod ("Get_T").Invoke (o, new object [] { s });
313 if (s_res.o1 != 1 || s_res.o2 != 2 || s_res.o3 != 3)
314 return 1;
315 } catch (TargetInvocationException) {
316 return 2;
318 return 0;
321 [Category ("DYNCALL")]
322 [Category ("GSHAREDVT")]
323 static int test_42_arm64_dyncall_vtypebyval () {
324 var method = typeof (Foo5<string>).GetMethod ("vtype_by_val").MakeGenericMethod (new Type [] { typeof (int), typeof (long?), typeof (long?), typeof (long?), typeof (long?) });
325 long res = (long)method.Invoke (null, new object [] { 1, 2L, 3L, 4L, 42L });
326 return (int)res;
329 struct Struct7 {
330 public string value;
333 class Foo7 {
334 public static string vtypeonstack_align (string s1, string s2, string s3, string s4, string s5, string s6, string s7, string s8, bool b, Struct7 s) {
335 return s.value;
339 [Category ("DYNCALL")]
340 static int test_0_arm64_ios_dyncall_vtypeonstack_align () {
341 var m = typeof (Foo7).GetMethod ("vtypeonstack_align");
343 string s = (string)m.Invoke (null, new object [] { null, null, null, null, null, null, null, null, true, new Struct7 () { value = "ABC" } });
344 return s == "ABC" ? 0 : 1;
347 class Foo6 {
348 public T reg_stack_split_inner<T> (int i, int j, T l) {
349 return l;
353 [Category ("DYNCALL")]
354 [Category ("GSHAREDVT")]
355 static int test_0_arm_dyncall_reg_stack_split () {
356 var m = typeof (Foo6).GetMethod ("reg_stack_split_inner").MakeGenericMethod (new Type[] { typeof (long) });
357 var o = new Foo6 ();
358 if ((long)m.Invoke (o, new object [] { 1, 2, 3 }) != 3)
359 return 1;
360 if ((long)m.Invoke (o, new object [] { 1, 2, Int64.MaxValue }) != Int64.MaxValue)
361 return 2;
362 return 0;
365 static int test_0_partial_sharing_regress_30204 () {
366 var t = typeof (System.Collections.Generic.Comparer<System.Collections.Generic.KeyValuePair<string, string>>);
367 var d = new SortedDictionary<string, string> ();
368 d.Add ("key1", "banana");
369 return d ["key1"] == "banana" ? 0 : 1;
372 class NullableMethods {
373 [MethodImplAttribute (MethodImplOptions.NoInlining)]
374 public static bool GetHasValue<T>(Nullable<T> value) where T : struct {
375 return value.HasValue;
378 [MethodImplAttribute (MethodImplOptions.NoInlining)]
379 public static T GetValue<T>(Nullable<T> value) where T : struct {
380 return value.Value;
383 [MethodImplAttribute (MethodImplOptions.NoInlining)]
384 public static Nullable<T> Get<T>(T t) where T : struct {
385 return t;
388 [MethodImplAttribute (MethodImplOptions.NoInlining)]
389 public static int NullableMany(long? i1, long? i2, long? i3, long? i4, long? i5, long? i6, long? i7, long? i8,
390 long? i11, long? i12, long? i13, long? i14, long? i15, long? i16, long? i17, long? i18,
391 long? i21, long? i22, long? i23, long? i24, long? i25, long? i26, long? i27, long? i28,
392 long? i31, long? i32, long? i33, long? i34, long? i35, long? i36, long? i37, long? i38) {
393 return (int)((i1 + i8 + i11 + i18 + i21 + i28 + i31 + i38).Value);
396 [MethodImplAttribute (MethodImplOptions.NoInlining)]
397 public static Nullable<T> GetNull<T>() where T : struct {
398 return null;
401 [MethodImplAttribute (MethodImplOptions.NoInlining)]
402 public static bool GetHasValueManyArgs<T>(int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, T? value) where T : struct
404 return value.HasValue;
408 [Category ("DYNCALL")]
409 public static int test_0_dyncall_nullable () {
410 int? v;
412 v = 42;
413 NullableMethods.GetHasValue (v);
414 bool b = (bool)typeof (NullableMethods).GetMethod ("GetHasValue").MakeGenericMethod (new Type [] { typeof (int) }).Invoke (null, new object [] { v });
415 if (!b)
416 return 1;
417 v = null;
418 b = (bool)typeof (NullableMethods).GetMethod ("GetHasValue").MakeGenericMethod (new Type [] { typeof (int) }).Invoke (null, new object [] { v });
419 if (b)
420 return 2;
422 v = 42;
423 NullableMethods.GetValue (v);
424 var res = (int)typeof (NullableMethods).GetMethod ("GetValue").MakeGenericMethod (new Type [] { typeof (int) }).Invoke (null, new object [] { v });
425 if (res != 42)
426 return 3;
428 NullableMethods.Get (42);
429 var res2 = (int?)typeof (NullableMethods).GetMethod ("Get").MakeGenericMethod (new Type [] { typeof (int) }).Invoke (null, new object [] { 42 });
430 if (res2 != 42)
431 return 4;
432 res2 = (int?)typeof (NullableMethods).GetMethod ("GetNull").MakeGenericMethod (new Type [] { typeof (int) }).Invoke (null, new object [] { });
433 if (res2.HasValue)
434 return 5;
436 NullableMethods.NullableMany (1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8);
437 res2 = (int?)typeof (NullableMethods).GetMethod ("NullableMany").Invoke (null, new object [] { 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L });
438 if (res2 != 36)
439 return 6;
440 return 0;
443 [Category ("DYNCALL")]
444 public static int test_0_arm64_dyncall_vtypebyrefonstack () {
445 var s = new LargeStruct () { a = 1, b = 2, c = 3, d = 4 };
447 NullableMethods.GetHasValueManyArgs<LargeStruct> (1, 2, 3, 4, 5, 6, 7, 8, s);
449 Type type = typeof (LargeStruct?).GetGenericArguments () [0];
450 var m = typeof(NullableMethods).GetMethod("GetHasValueManyArgs", BindingFlags.Static | BindingFlags.Public);
451 bool b1 = (bool)m.MakeGenericMethod (new Type[] {type}).Invoke (null, new object[] { 1, 2, 3, 4, 5, 6, 7, 8, s });
452 if (!b1)
453 return 1;
454 bool b2 = (bool)m.MakeGenericMethod (new Type[] {type}).Invoke (null, new object[] { 1, 2, 3, 4, 5, 6, 7, 8, null });
455 if (b2)
456 return 2;
457 return 0;
460 enum AnEnum {
461 A = 0,
462 B = 1
465 public static int test_0_enum_eq_comparer () {
466 var c = EqualityComparer<AnEnum>.Default;
467 return (!c.Equals (AnEnum.A, AnEnum.B) && c.Equals (AnEnum.A, AnEnum.A)) ? 0 : 1;
470 public static int test_0_enum_comparer () {
471 var c = Comparer<AnEnum>.Default;
472 return c.Compare (AnEnum.A, AnEnum.A);
475 private static Dictionary<long, TValue> ConvertDictionary<TValue>(Dictionary<long, IList<TValue>> source) {
476 return source.ToDictionary(pair => pair.Key, pair => pair.Value[0]);
479 [Category ("GSHAREDVT")]
480 public static int test_0_gsharedvt_non_variable_arg () {
481 Dictionary<long, IList<int>> data = new Dictionary<long, IList<int>>
483 {123L, new List<int> {2}}
485 Dictionary<long, int> newDict = ConvertDictionary(data);
486 if (newDict.Count != 1)
487 return 1;
488 return 0;
491 enum LongEnum : ulong {
492 A = 1
495 public static int test_0_long_enum_eq_comparer () {
496 var c = EqualityComparer<LongEnum>.Default;
497 c.GetHashCode (LongEnum.A);
498 return 0;
501 enum UInt32Enum : uint {
502 A = 1
505 enum Int32Enum : int {
506 A = 1
509 enum Int16Enum : short {
510 A = 1
513 enum UInt16Enum : ushort {
514 A = 1
517 enum Int8Enum : sbyte {
518 A = 1
521 enum UInt8Enum : byte {
522 A = 1
525 public static int test_0_int_enum_eq_comparer () {
526 var t1 = new Dictionary<Int32Enum, object> ();
527 t1 [Int32Enum.A] = "foo";
529 var t2 = new Dictionary<UInt32Enum, object> ();
530 t2 [UInt32Enum.A] = "foo";
532 var t3 = new Dictionary<UInt16Enum, object> ();
533 t3 [UInt16Enum.A] = "foo";
535 var t4 = new Dictionary<Int16Enum, object> ();
536 t4 [Int16Enum.A] = "foo";
538 var t5 = new Dictionary<Int8Enum, object> ();
539 t5 [Int8Enum.A] = "foo";
541 var t6 = new Dictionary<UInt8Enum, object> ();
542 t6 [UInt8Enum.A] = "foo";
544 return 0;
547 [Category ("DYNCALL")]
548 public static int test_0_array_accessor_runtime_invoke_ref () {
549 var t = typeof (string[]);
550 var arr = Array.CreateInstance (typeof (string), 1);
551 arr.GetType ().GetMethod ("Set").Invoke (arr, new object [] { 0, "A" });
552 var res = (string)arr.GetType ().GetMethod ("Get").Invoke (arr, new object [] { 0 });
553 if (res != "A")
554 return 1;
555 return 0;
558 public static void SetArrayValue_<T> (T[] values) {
559 values.Select (x => x).ToArray ();
562 [Category ("GSHAREDVT")]
563 public static int test_0_delegate_invoke_wrappers_gsharedvt () {
564 var enums = new LongEnum [] { LongEnum.A };
565 SetArrayValue_ (enums);
566 return 0;
569 struct LargeStruct {
570 public int a, b, c, d;
573 [MethodImplAttribute (MethodImplOptions.NoInlining)]
574 public static bool GetHasValue<T>(T? value) where T : struct
576 return value.HasValue;
579 [Category ("DYNCALL")]
580 public static int test_0_large_nullable_invoke () {
581 var s = new LargeStruct () { a = 1, b = 2, c = 3, d = 4 };
583 NullableMethods.GetHasValue<LargeStruct> (s);
585 var m = typeof(NullableMethods).GetMethod("GetHasValue", BindingFlags.Static | BindingFlags.Public);
587 Type type = typeof (LargeStruct?).GetGenericArguments () [0];
588 bool b1 = (bool)m.MakeGenericMethod (new Type[] {type}).Invoke (null, new object[] { s });
589 if (!b1)
590 return 1;
591 bool b2 = (bool)m.MakeGenericMethod (new Type[] {type}).Invoke (null, new object[] { null });
592 if (b2)
593 return 2;
594 return 0;
597 struct FpStruct {
598 public float a, b, c;
601 struct LargeStruct2 {
602 public FpStruct x;
603 public int a, b, c, d, e, f, g, h;
606 [MethodImplAttribute (MethodImplOptions.NoInlining)]
607 static int pass_hfa_on_stack (FpStruct s1, FpStruct s2, FpStruct s3) {
608 return (int)s3.c;
611 public static int test_10_arm64_hfa_on_stack_llvm () {
612 var arr = new LargeStruct2 [10, 10];
613 for (int i = 0; i < 10; ++i)
614 for (int j = 0; j < 10; ++j)
615 arr [i, j].x = new FpStruct ();
617 var s1 = new FpStruct () { a = 1, b = 1, c = 10 };
618 return pass_hfa_on_stack (s1, s1, s1);
621 public static int test_0_get_current_method () {
622 var m = MethodBase.GetCurrentMethod ();
623 #if __MOBILE__
624 var m2 = typeof (AotTests).GetMethod ("test_0_get_current_method");
625 #else
626 var m2 = typeof (Tests).GetMethod ("test_0_get_current_method");
627 #endif
628 return m == m2 ? 0 : 1;
631 class GetCurrentMethodClass<T> {
632 [MethodImplAttribute (MethodImplOptions.NoInlining)]
633 public MethodBase get_current () {
634 return MethodBase.GetCurrentMethod ();
638 public static int test_0_get_current_method_generic () {
639 var c = new GetCurrentMethodClass<string> ();
640 var m = c.get_current ();
641 var m2 = typeof (GetCurrentMethodClass<>).GetMethod ("get_current");
642 return m == m2 ? 0 : 1;
645 public static int test_0_array_wrappers_runtime_invoke () {
646 string[][] arr = new string [10][];
647 IEnumerable<string[]> iface = arr;
648 var m = typeof(IEnumerable<string[]>).GetMethod ("GetEnumerator");
649 m.Invoke (arr, null);
650 return 0;
653 public static int test_0_fault_clauses () {
654 object [] data = { 1, 2, 3 };
655 int [] expected = { 1, 2, 3 };
657 try {
658 Action d = delegate () { data.Cast<IEnumerable> ().GetEnumerator ().MoveNext (); };
659 d ();
660 } catch (Exception) {
662 return 0;
665 public static int test_0_regress_gh_7364 () {
666 var map1 = new Dictionary <Type, IntPtr> (EqualityComparer<Type>.Default);
667 var map2 = new Dictionary <IntPtr, WeakReference> (EqualityComparer<IntPtr>.Default);
668 return 0;
671 public static int test_0_byte_equality_compater_devirt () {
672 var dict = new Dictionary<byte, Struct1>();
673 dict [1] = new Struct1 ();
674 dict [1] = new Struct1 ();
675 return 0;
678 // Requires c# 7.2
679 #if !__MonoCS__
680 public interface GameComponent {
683 public struct Components<T> {
684 public T[] Collection;
685 public int Count;
688 struct AStruct : GameComponent {
691 public class ReadonlyTest<T> where T: GameComponent {
692 private static Components<T> _components;
694 public static T[] GetArray()
696 ref readonly Components<T> components = ref GetComponents();
697 return components.Collection;
700 public static ref readonly Components<T> GetComponents()
702 return ref _components;
706 // gh #8701
707 public static int test_0_readonly_modopt () {
708 typeof (ReadonlyTest<>).MakeGenericType (new Type[] { typeof (AStruct) }).GetMethod ("GetArray").Invoke (null, null);
709 return 0;
711 #endif
713 struct DummyStruct {
716 [MethodImplAttribute (MethodImplOptions.NoInlining)]
717 static void array_ienumerable<T1, T> (T t) where T: IEnumerable<T1> {
718 var e = t.GetEnumerator ();
721 public static int test_0_array_ienumerable_constrained () {
722 array_ienumerable<DummyStruct, DummyStruct[]> (new DummyStruct [0]);
723 return 0;