using System; class Tests { struct TestStruct { public int i; public TestStruct (int i) { this.i = i; } } static int Main () { return TestDriver.RunTests (typeof (Tests)); } public static int test_1_nullable_unbox () { return Unbox (1).Value; } public static int test_1_nullable_unbox_null () { return Unbox (null).HasValue ? 0 : 1; } public static int test_1_nullable_box () { return (int) Box (1); } public static int test_1_nullable_box_null () { return Box (null) == null ? 1 : 0; } public static int test_1_isinst_nullable () { object o = 1; return (o is int?) ? 1 : 0; } /* FIXME: This doesn't work yet public static int test_1_nullable_unbox_vtype () { return Unbox (new TestStruct (1)).Value.i; } public static int test_1_nullable_unbox_null_vtype () { return Unbox (null).HasValue ? 0 : 1; } public static int test_1_nullable_box_vtype () { return ((TestStruct)(Box (new TestStruct (1)))).i; } public static int test_1_nullable_box_null_vtype () { return Box (null) == null ? 1 : 0; } public static int test_1_isinst_nullable_vtype () { object o = new TestStruct (1); return (o is TestStruct?) ? 1 : 0; } */ static object Box (T t) { return t; } static T Unbox (object o) { return (T) o; } }