* mini-ops.h: Add s390_backchain instruction
[mono.git] / mono / mini / generics.2.cs
1 using System;
2
3 class Tests {
4
5         struct TestStruct {
6                 public int i;
7
8                 public TestStruct (int i) {
9                         this.i = i;
10                 }
11         }
12
13         static int Main ()
14         {
15                 return TestDriver.RunTests (typeof (Tests));
16         }
17         
18         public static int test_1_nullable_unbox ()
19         {
20                 return Unbox<int?> (1).Value;
21         }
22
23         public static int test_1_nullable_unbox_null ()
24         {
25                 return Unbox<int?> (null).HasValue ? 0 : 1;
26         }
27
28         public static int test_1_nullable_box ()
29         {
30                 return (int) Box<int?> (1);
31         }
32
33         public static int test_1_nullable_box_null ()
34         {
35                 return Box<int?> (null) == null ? 1 : 0;
36         }
37
38         public static int test_1_isinst_nullable ()
39         {
40                 object o = 1;
41                 return (o is int?) ? 1 : 0;
42         }
43
44         /* FIXME: This doesn't work yet
45
46         public static int test_1_nullable_unbox_vtype ()
47         {
48                 return Unbox<TestStruct?> (new TestStruct (1)).Value.i;
49         }
50
51         public static int test_1_nullable_unbox_null_vtype ()
52         {
53                 return Unbox<TestStruct?> (null).HasValue ? 0 : 1;
54         }
55
56         public static int test_1_nullable_box_vtype ()
57         {
58                 return ((TestStruct)(Box<TestStruct?> (new TestStruct (1)))).i;
59         }
60
61         public static int test_1_nullable_box_null_vtype ()
62         {
63                 return Box<TestStruct?> (null) == null ? 1 : 0;
64         }
65
66         public static int test_1_isinst_nullable_vtype ()
67         {
68                 object o = new TestStruct (1);
69                 return (o is TestStruct?) ? 1 : 0;
70         }
71         */
72
73         static object Box<T> (T t)
74         {
75                 return t;
76         }
77         
78         static T Unbox <T> (object o) {
79                 return (T) o;
80         }
81 }