2 using System.Collections.Generic;
4 using System.Runtime.CompilerServices;
5 using System.Threading;
6 using System.Threading.Tasks;
18 public TestStruct (int i, int j) {
25 public static int Main (string[] args) {
26 return TestDriver.RunTests (typeof (Tests), args);
30 public static int test_1_no_nullable_unbox ()
32 return Unbox<int> (1);
35 public static int test_1_nullable_unbox_null ()
37 return Unbox<int?> (null).HasValue ? 0 : 1;
40 public static int test_1_nullable_box ()
42 return (int) Box<int?> (1);
45 public static int test_1_nullable_box_null ()
47 return Box<int?> (null) == null ? 1 : 0;
50 public static int test_1_isinst_nullable ()
53 return (o is int?) ? 1 : 0;
56 public static int test_1_nullable_unbox_vtype ()
58 return Unbox<TestStruct?> (new TestStruct (1, 2)).Value.i;
62 public static int test_1_nullable_unbox_null_vtype ()
64 return Unbox<TestStruct?> (null).HasValue ? 0 : 1;
67 public static int test_1_nullable_box_vtype ()
69 return ((TestStruct)(Box<TestStruct?> (new TestStruct (1, 2)))).i;
72 public static int test_1_nullable_box_null_vtype ()
74 return Box<TestStruct?> (null) == null ? 1 : 0;
77 public static int test_1_isinst_nullable_vtype ()
79 object o = new TestStruct (1, 2);
80 return (o is TestStruct?) ? 1 : 0;
83 public static int test_0_nullable_normal_unbox ()
88 // This uses unbox instead of unbox_any
97 public static void stelem_any<T> (T[] arr, T elem) {
101 public static T ldelem_any<T> (T[] arr) {
105 public static int test_1_ldelem_stelem_any_int () {
106 int[] arr = new int [3];
109 return ldelem_any (arr);
112 public static T return_ref<T> (ref T t) {
116 public static T ldelema_any<T> (T[] arr) {
117 return return_ref<T> (ref arr [0]);
120 public static int test_0_ldelema () {
121 string[] arr = new string [1];
125 if (ldelema_any <string> (arr) == "Hello")
131 public static T[,] newarr_multi<T> () {
135 public static int test_0_newarr_multi_dim () {
136 return newarr_multi<string> ().GetType () == typeof (string[,]) ? 0 : 1;
139 static object Box<T> (T t)
144 static T Unbox <T> (object o) {