From 72cfa85a6021ce9747ca8759a0cf8825857be591 Mon Sep 17 00:00:00 2001 From: Mark Probst Date: Thu, 10 Apr 2008 14:25:33 +0000 Subject: [PATCH] 2008-04-10 Mark Probst * generic-box.2.cs, generic-boxing.2.il, generic-delegate.2.cs, generic-ldobj.2.il, generic-ldtoken.2.il, generic-ldtoken-field.2.il, generic-ldtoken-method.2.il, generic-mkrefany.2.il, generic-sizeof.2.cs, generic-tailcall.2.il, generic-unbox.2.cs, generic-unboxing.2.il, generic-virtual.2.cs, generics-sharing.2.cs: New test cases for generic sharing. * Makefile.am: Added tests. svn path=/trunk/mono/; revision=100326 --- mono/tests/ChangeLog | 11 ++ mono/tests/Makefile.am | 54 ++++++-- mono/tests/generic-box.2.cs | 12 ++ mono/tests/generic-boxing.2.il | 55 ++++++++ mono/tests/generic-delegate.2.cs | 58 +++++++++ mono/tests/generic-ldobj.2.il | 164 ++++++++++++++++++++++++ mono/tests/generic-ldtoken-field.2.il | 100 +++++++++++++++ mono/tests/generic-ldtoken-method.2.il | 99 +++++++++++++++ mono/tests/generic-ldtoken.2.il | 129 +++++++++++++++++++ mono/tests/generic-mkrefany.2.il | 168 +++++++++++++++++++++++++ mono/tests/generic-sizeof.2.cs | 26 ++++ mono/tests/generic-tailcall.2.il | 133 ++++++++++++++++++++ mono/tests/generic-unbox.2.cs | 20 +++ mono/tests/generic-unboxing.2.il | 74 +++++++++++ mono/tests/generic-virtual.2.cs | 62 +++++++++ mono/tests/generics-sharing.2.cs | 149 ++++++++++++++++++---- 16 files changed, 1284 insertions(+), 30 deletions(-) create mode 100644 mono/tests/generic-boxing.2.il create mode 100644 mono/tests/generic-delegate.2.cs create mode 100644 mono/tests/generic-ldobj.2.il create mode 100644 mono/tests/generic-ldtoken-field.2.il create mode 100644 mono/tests/generic-ldtoken-method.2.il create mode 100644 mono/tests/generic-ldtoken.2.il create mode 100644 mono/tests/generic-mkrefany.2.il create mode 100644 mono/tests/generic-sizeof.2.cs create mode 100644 mono/tests/generic-tailcall.2.il create mode 100644 mono/tests/generic-unbox.2.cs create mode 100644 mono/tests/generic-unboxing.2.il create mode 100644 mono/tests/generic-virtual.2.cs diff --git a/mono/tests/ChangeLog b/mono/tests/ChangeLog index 187118f50b5..51621c512fb 100644 --- a/mono/tests/ChangeLog +++ b/mono/tests/ChangeLog @@ -1,3 +1,14 @@ +2008-04-10 Mark Probst + + * generic-box.2.cs, generic-boxing.2.il, generic-delegate.2.cs, + generic-ldobj.2.il, generic-ldtoken.2.il, + generic-ldtoken-field.2.il, generic-ldtoken-method.2.il, + generic-mkrefany.2.il, generic-sizeof.2.cs, generic-tailcall.2.il, + generic-unbox.2.cs, generic-unboxing.2.il, generic-virtual.2.cs, + generics-sharing.2.cs: New test cases for generic sharing. + + * Makefile.am: Added tests. + 2008-03-31 Mark Probst * Makefile.am: Re-enabled CoreCLR security tests. Fixes #362626. diff --git a/mono/tests/Makefile.am b/mono/tests/Makefile.am index 6c1d479ecf8..6a05cd77624 100644 --- a/mono/tests/Makefile.am +++ b/mono/tests/Makefile.am @@ -257,7 +257,9 @@ BASE_TEST_CS_SRC= \ shared-generic-synchronized.2.cs \ generic-inlining.2.cs \ generic-initobj.2.cs \ - generic-box.2.cs \ + generic-delegate.2.cs \ + generic-sizeof.2.cs \ + generic-virtual.2.cs \ recursive-generics.2.cs \ bug-80392.2.cs \ dynamic-method-access.2.cs \ @@ -348,7 +350,14 @@ TEST_IL_SRC= \ resolve_method_bug.2.il \ resolve_field_bug.2.il \ resolve_type_bug.2.il \ - generics-sharing-other-exc.2.il + generics-sharing-other-exc.2.il \ + generic-sizeof.2.il \ + generic-ldobj.2.il \ + generic-mkrefany.2.il \ + generic-ldtoken.2.il \ + generic-ldtoken-method.2.il \ + generic-ldtoken-field.2.il \ + generic-tailcall.2.il # bug-318677.il @@ -640,15 +649,42 @@ test-coreclr-security : coreclr-security.exe $(RUNTIME21) --security=core-clr-test coreclr-security.exe endif +generic-unboxing.2.dll : generic-unboxing.2.il + $(ILASM) /dll /output:generic-unboxing.2.dll $(srcdir)/generic-unboxing.2.il + +generic-boxing.2.dll : generic-boxing.2.il generic-unboxing.2.dll + $(ILASM) /dll /output:generic-boxing.2.dll $(srcdir)/generic-boxing.2.il + +generic-unbox.2.exe : generic-unbox.2.cs generic-unboxing.2.dll + $(MCS) -r:generic-unboxing.2.dll $(srcdir)/generic-unbox.2.cs + +generic-box.2.exe : generic-box.2.cs generic-unboxing.2.dll generic-boxing.2.dll + $(MCS) -r:generic-unboxing.2.dll,generic-boxing.2.dll $(srcdir)/generic-box.2.cs + test-generic-sharing : generics-sharing.2.exe shared-generic-methods.2.exe \ shared-generic-synchronized.2.exe generic-initobj.2.exe \ - generics-sharing-other-exc.2.exe generic-box.2.exe - $(RUNTIME) -O=gshared generics-sharing.2.exe - $(RUNTIME) -O=gshared,-inline shared-generic-methods.2.exe - $(RUNTIME) -O=gshared shared-generic-synchronized.2.exe - $(RUNTIME) -O=gshared,-inline generic-initobj.2.exe - $(RUNTIME) -O=gshared,-inline generic-box.2.exe - $(RUNTIME) -O=gshared,-inline generics-sharing-other-exc.2.exe + generics-sharing-other-exc.2.exe generic-box.2.exe \ + generic-unbox.2.exe generic-delegate.2.exe generic-sizeof.2.exe \ + generic-ldobj.2.exe generic-mkrefany.2.exe \ + generic-ldtoken.2.exe \ + generic-ldtoken-method.2.exe generic-ldtoken-field.2.exe \ + generic-virtual.2.exe generic-tailcall.2.exe + $(RUNTIME) -O=gshared,-inline generics-sharing.2.exe + $(RUNTIME) -O=gshared,-inline shared-generic-methods.2.exe + $(RUNTIME) -O=gshared,-inline shared-generic-synchronized.2.exe + $(RUNTIME) -O=gshared,-inline generic-initobj.2.exe + $(RUNTIME) -O=gshared,-inline generic-box.2.exe + $(RUNTIME) -O=gshared,-inline generics-sharing-other-exc.2.exe + $(RUNTIME) -O=gshared,-inline generic-unbox.2.exe + $(RUNTIME) -O=gshared,-inline generic-delegate.2.exe + $(RUNTIME) -O=gshared,-inline generic-sizeof.2.exe + $(RUNTIME) -O=gshared,-inline generic-ldobj.2.exe + $(RUNTIME) -O=gshared,-inline generic-mkrefany.2.exe + $(RUNTIME) -O=gshared,-inline generic-ldtoken.2.exe + $(RUNTIME) -O=gshared,-inline generic-ldtoken-method.2.exe + $(RUNTIME) -O=gshared,-inline generic-ldtoken-field.2.exe + $(RUNTIME) -O=gshared,-inline generic-virtual.2.exe + $(RUNTIME) -O=gshared,-inline generic-tailcall.2.exe EXTRA_DIST += async-exceptions.cs async-exceptions.exe : async-exceptions.cs diff --git a/mono/tests/generic-box.2.cs b/mono/tests/generic-box.2.cs index c6ccafc6bf1..0bea4ab1cf8 100644 --- a/mono/tests/generic-box.2.cs +++ b/mono/tests/generic-box.2.cs @@ -1,4 +1,6 @@ using System.Collections.Generic; +using UnboxTest; +using BoxTest; public class ClassA {} @@ -56,6 +58,16 @@ public class main { return 1; */ + UnboxerStruct us; + Boxer b = new Boxer (); + + us.field = 123; + + if (((UnboxerStruct?)b.boxNullable (us)).Value.field != 123) + return 1; + if (b.boxNullable (null) != null) + return 1; + return 0; } } diff --git a/mono/tests/generic-boxing.2.il b/mono/tests/generic-boxing.2.il new file mode 100644 index 00000000000..f19f8b89cb7 --- /dev/null +++ b/mono/tests/generic-boxing.2.il @@ -0,0 +1,55 @@ +.assembly extern mscorlib +{ + .ver 2:0:0:0 + .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. +} +.assembly extern 'generic-unboxing.2' +{ + .ver 0:0:0:0 +} +.assembly 'generic-boxing.2' +{ + .custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::'.ctor'() = ( + 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx + 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows. + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module 'generic-boxing.2.dll' // GUID = {9C29868F-7AD1-40CC-BBDC-DF985AB656FC} + + +.namespace BoxTest +{ + .class public auto ansi beforefieldinit Boxer`1 + extends [mscorlib]System.Object + { + + // method line 1 + .method public hidebysig specialname rtspecialname + instance default void '.ctor' () cil managed + { + // Method begins at RVA 0x20ec + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void object::'.ctor'() + IL_0006: ret + } // end of method Boxer`1::.ctor + + // method line 2 + .method public hidebysig + instance default object boxNullable (valuetype [mscorlib]System.Nullable`1> us) cil managed + { + // Method begins at RVA 0x20f4 + // Code size 15 (0xf) + .maxstack 8 + IL_0000: ldarg.1 + // IL_0004: call instance !0 valuetype [mscorlib]System.Nullable`1>::get_Value() + IL_0009: box valuetype [mscorlib]System.Nullable`1> + IL_000e: ret + } // end of method Boxer`1::boxNullable + + } // end of class BoxTest.Boxer`1 +} + diff --git a/mono/tests/generic-delegate.2.cs b/mono/tests/generic-delegate.2.cs new file mode 100644 index 00000000000..125088b5676 --- /dev/null +++ b/mono/tests/generic-delegate.2.cs @@ -0,0 +1,58 @@ +public class ClassA {} + +public delegate int IntDelegate (int x); +public delegate T[] TDelegate (); + +public class Gen { + public int intFunction (int x) { + return x + 1; + } + + public IntDelegate getIntDelegate () { + return intFunction; + } + + public virtual int virtIntFunction (int x) { + return x + 2; + } + + public IntDelegate getVirtIntDelegate () { + return virtIntFunction; + } + + public T[] tFunction () { + return new T[3]; + } + + public TDelegate getTDelegate () { + return tFunction; + } + + public static T[] staticTFunction () { + return new T[3]; + } + + public TDelegate getStaticTDelegate () { + return staticTFunction; + } +} + +public class main { + public static int Main () { + Gen ga = new Gen (); + IntDelegate id = ga.getIntDelegate (); + TDelegate tda = ga.getTDelegate (); + IntDelegate vid = ga.getVirtIntDelegate (); + TDelegate stda = ga.getStaticTDelegate (); + + if (id (123) != 124) + return 1; + if (tda ().GetType () != typeof (ClassA[])) + return 1; + if (vid (123) != 125) + return 1; + if (stda ().GetType () != typeof (ClassA[])) + return 1; + return 0; + } +} diff --git a/mono/tests/generic-ldobj.2.il b/mono/tests/generic-ldobj.2.il new file mode 100644 index 00000000000..2aab47f80a9 --- /dev/null +++ b/mono/tests/generic-ldobj.2.il @@ -0,0 +1,164 @@ +.assembly extern mscorlib +{ + .ver 2:0:0:0 + .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. +} +.assembly 'generic-mkrefany.2' +{ + .custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::'.ctor'() = ( + 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx + 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows. + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module 'generic-mkrefany.2.exe' // GUID = {51FFBB77-6AFB-435E-B206-16DB5C8A3730} + + + .class public auto ansi beforefieldinit ClassA + extends [mscorlib]System.Object + { + + // method line 1 + .method public hidebysig specialname rtspecialname + instance default void '.ctor' () cil managed + { + // Method begins at RVA 0x20ec + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void object::'.ctor'() + IL_0006: ret + } // end of method ClassA::.ctor + + } // end of class ClassA + + .class public sequential ansi sealed beforefieldinit GenStruct`1 + extends [mscorlib]System.ValueType + { + .field public int32 field1 + .field public !0 field2 + + } // end of class GenStruct`1 + + .class public auto ansi beforefieldinit Gen`1 + extends [mscorlib]System.Object + { + + // method line 2 + .method public hidebysig specialname rtspecialname + instance default void '.ctor' () cil managed + { + // Method begins at RVA 0x20f4 + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void object::'.ctor'() + IL_0006: ret + } // end of method Gen`1::.ctor + + // method line 3 + .method public hidebysig + instance default !T ident (!T t) cil managed + { + // Method begins at RVA 0x20fc + // Code size 4 (0x4) + .maxstack 1 + .locals init ( + !T V_0) + IL_0000: ldarg.1 + IL_0001: stloc.0 + ldloca 0 + ldobj !0 + IL_0003: ret + } // end of method Gen`1::ident + + // method line 4 + .method public hidebysig + instance default valuetype GenStruct`1 structIdent (valuetype GenStruct`1 gst) cil managed + { + // Method begins at RVA 0x210c + // Code size 4 (0x4) + .maxstack 1 + .locals init ( + valuetype GenStruct`1 V_0) + IL_0000: ldarg.1 + IL_0001: stloc.0 + ldloca 0 + ldobj valuetype GenStruct`1 + IL_0003: ret + } // end of method Gen`1::structIdent + + } // end of class Gen`1 + + .class public auto ansi beforefieldinit main + extends [mscorlib]System.Object + { + + // method line 5 + .method public hidebysig specialname rtspecialname + instance default void '.ctor' () cil managed + { + // Method begins at RVA 0x211c + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void object::'.ctor'() + IL_0006: ret + } // end of method main::.ctor + + // method line 6 + .method public static hidebysig + default int32 Main () cil managed + { + // Method begins at RVA 0x2124 + .entrypoint + // Code size 94 (0x5e) + .maxstack 8 + .locals init ( + class ClassA V_0, + valuetype GenStruct`1 V_1, + class Gen`1 V_2, + valuetype GenStruct`1 V_3) + IL_0000: newobj instance void class ClassA::'.ctor'() + IL_0005: stloc.0 + IL_0006: ldloca.s 1 + IL_0008: ldc.i4.s 0x7b + IL_000a: stfld int32 valuetype GenStruct`1::field1 + IL_000f: ldloca.s 1 + IL_0011: ldloc.0 + IL_0012: stfld !0 valuetype GenStruct`1::field2 + IL_0017: newobj instance void class Gen`1::'.ctor'() + IL_001c: stloc.2 + IL_001d: ldloc.2 + IL_001e: ldloc.0 + IL_001f: callvirt instance !0 class Gen`1::ident(!0) + IL_0024: ldloc.0 + IL_0025: beq IL_002c + + IL_002a: ldc.i4.1 + IL_002b: ret + IL_002c: ldloc.2 + IL_002d: ldloc.1 + IL_002e: callvirt instance valuetype GenStruct`1 class Gen`1::structIdent(valuetype GenStruct`1) + IL_0033: stloc.3 + IL_0034: ldloca.s 3 + IL_0036: ldfld int32 valuetype GenStruct`1::field1 + IL_003b: ldloca.s 1 + IL_003d: ldfld int32 valuetype GenStruct`1::field1 + IL_0042: bne.un IL_005a + + IL_0047: ldloca.s 3 + IL_0049: ldfld !0 valuetype GenStruct`1::field2 + IL_004e: ldloca.s 1 + IL_0050: ldfld !0 valuetype GenStruct`1::field2 + IL_0055: beq IL_005c + + IL_005a: ldc.i4.1 + IL_005b: ret + IL_005c: ldc.i4.0 + IL_005d: ret + } // end of method main::Main + + } // end of class main + diff --git a/mono/tests/generic-ldtoken-field.2.il b/mono/tests/generic-ldtoken-field.2.il new file mode 100644 index 00000000000..df062f41593 --- /dev/null +++ b/mono/tests/generic-ldtoken-field.2.il @@ -0,0 +1,100 @@ +.assembly extern mscorlib +{ + .ver 2:0:0:0 + .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. +} +.assembly 'generic-ldtoken.2' +{ + .custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::'.ctor'() = ( + 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx + 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows. + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module 'generic-ldtoken.2.exe' // GUID = {816E886F-1485-43E8-AC46-501D301BC67A} + + + .class public auto ansi beforefieldinit ClassA + extends [mscorlib]System.Object + { + + // method line 1 + .method public hidebysig specialname rtspecialname + instance default void '.ctor' () cil managed + { + // Method begins at RVA 0x20ec + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void object::'.ctor'() + IL_0006: ret + } // end of method ClassA::.ctor + + } // end of class ClassA + + .class public auto ansi beforefieldinit Gen`1 + extends [mscorlib]System.Object + { + + .field public static int32 myField + + // method line 2 + .method public hidebysig specialname rtspecialname + instance default void '.ctor' () cil managed + { + // Method begins at RVA 0x20f4 + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void object::'.ctor'() + IL_0006: ret + } // end of method Gen`1::.ctor + + .method public hidebysig instance default int32 checkEqual () cil managed + { + ldtoken field int32 class Gen`1::myField + call [mscorlib]System.Reflection.FieldInfo [mscorlib]System.Reflection.FieldInfo::GetFieldFromHandle ([mscorlib]System.RuntimeFieldHandle) + ldtoken field int32 class Gen`1::myField + call [mscorlib]System.Reflection.FieldInfo [mscorlib]System.Reflection.FieldInfo::GetFieldFromHandle ([mscorlib]System.RuntimeFieldHandle) + ceq + ret + } + + } // end of class Gen`1 + + .class public auto ansi beforefieldinit main + extends [mscorlib]System.Object + { + + // method line 5 + .method public hidebysig specialname rtspecialname + instance default void '.ctor' () cil managed + { + // Method begins at RVA 0x2114 + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void object::'.ctor'() + IL_0006: ret + } // end of method main::.ctor + + // method line 6 + .method public static hidebysig + default int32 Main () cil managed + { + // Method begins at RVA 0x211c + .entrypoint + // Code size 54 (0x36) + .maxstack 9 + .locals init ( + class Gen`1 V_0) + ldc.i4.1 + IL_0000: newobj instance void class Gen`1::'.ctor'() + callvirt instance int32 class Gen`1::checkEqual() + sub + IL_0035: ret + } // end of method main::Main + + } // end of class main + diff --git a/mono/tests/generic-ldtoken-method.2.il b/mono/tests/generic-ldtoken-method.2.il new file mode 100644 index 00000000000..f56193850b6 --- /dev/null +++ b/mono/tests/generic-ldtoken-method.2.il @@ -0,0 +1,99 @@ +.assembly extern mscorlib +{ + .ver 2:0:0:0 + .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. +} +.assembly 'generic-ldtoken.2' +{ + .custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::'.ctor'() = ( + 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx + 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows. + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module 'generic-ldtoken.2.exe' // GUID = {816E886F-1485-43E8-AC46-501D301BC67A} + + + .class public auto ansi beforefieldinit ClassA + extends [mscorlib]System.Object + { + + // method line 1 + .method public hidebysig specialname rtspecialname + instance default void '.ctor' () cil managed + { + // Method begins at RVA 0x20ec + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void object::'.ctor'() + IL_0006: ret + } // end of method ClassA::.ctor + + } // end of class ClassA + + .class public auto ansi beforefieldinit Gen`1 + extends [mscorlib]System.Object + { + + // method line 2 + .method public hidebysig specialname rtspecialname + instance default void '.ctor' () cil managed + { + // Method begins at RVA 0x20f4 + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void object::'.ctor'() + IL_0006: ret + } // end of method Gen`1::.ctor + + .method public hidebysig instance default int32 checkEqual () cil managed + { + ldtoken method instance int32 class Gen`1::checkEqual() + call [mscorlib]System.Reflection.MethodBase [mscorlib]System.Reflection.MethodBase::GetMethodFromHandle ([mscorlib]System.RuntimeMethodHandle) + ldtoken method instance int32 class Gen`1::checkEqual () + call [mscorlib]System.Reflection.MethodBase [mscorlib]System.Reflection.MethodBase::GetMethodFromHandle ([mscorlib]System.RuntimeMethodHandle) + // call instance int32 [mscorlib]System.RuntimeMethodHandle::Equals ([mscorlib]System.RuntimeMethodHandle) + ceq + ret + } + + } // end of class Gen`1 + + .class public auto ansi beforefieldinit main + extends [mscorlib]System.Object + { + + // method line 5 + .method public hidebysig specialname rtspecialname + instance default void '.ctor' () cil managed + { + // Method begins at RVA 0x2114 + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void object::'.ctor'() + IL_0006: ret + } // end of method main::.ctor + + // method line 6 + .method public static hidebysig + default int32 Main () cil managed + { + // Method begins at RVA 0x211c + .entrypoint + // Code size 54 (0x36) + .maxstack 9 + .locals init ( + class Gen`1 V_0) + ldc.i4.1 + IL_0000: newobj instance void class Gen`1::'.ctor'() + callvirt instance int32 class Gen`1::checkEqual() + sub + IL_0035: ret + } // end of method main::Main + + } // end of class main + diff --git a/mono/tests/generic-ldtoken.2.il b/mono/tests/generic-ldtoken.2.il new file mode 100644 index 00000000000..432978aec87 --- /dev/null +++ b/mono/tests/generic-ldtoken.2.il @@ -0,0 +1,129 @@ +.assembly extern mscorlib +{ + .ver 2:0:0:0 + .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. +} +.assembly 'generic-ldtoken.2' +{ + .custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::'.ctor'() = ( + 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx + 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows. + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module 'generic-ldtoken.2.exe' // GUID = {816E886F-1485-43E8-AC46-501D301BC67A} + + + .class public auto ansi beforefieldinit ClassA + extends [mscorlib]System.Object + { + + // method line 1 + .method public hidebysig specialname rtspecialname + instance default void '.ctor' () cil managed + { + // Method begins at RVA 0x20ec + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void object::'.ctor'() + IL_0006: ret + } // end of method ClassA::.ctor + + } // end of class ClassA + + .class public auto ansi beforefieldinit Gen`1 + extends [mscorlib]System.Object + { + + // method line 2 + .method public hidebysig specialname rtspecialname + instance default void '.ctor' () cil managed + { + // Method begins at RVA 0x20f4 + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void object::'.ctor'() + IL_0006: ret + } // end of method Gen`1::.ctor + + // method line 3 + .method public hidebysig + instance default class [mscorlib]System.Type typeOfT () cil managed + { + // Method begins at RVA 0x20fc + // Code size 11 (0xb) + .maxstack 8 + IL_0000: ldtoken !T + nop + IL_0005: call class [mscorlib]System.Type class [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) + IL_000a: ret + } // end of method Gen`1::typeOfT + + // method line 4 + .method public hidebysig + instance default class [mscorlib]System.Type typeOfGenT () cil managed + { + // Method begins at RVA 0x2108 + // Code size 11 (0xb) + .maxstack 8 + IL_0000: ldtoken class Gen`1 + nop + IL_0005: call class [mscorlib]System.Type class [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) + IL_000a: ret + } // end of method Gen`1::typeOfGenT + + } // end of class Gen`1 + + .class public auto ansi beforefieldinit main + extends [mscorlib]System.Object + { + + // method line 5 + .method public hidebysig specialname rtspecialname + instance default void '.ctor' () cil managed + { + // Method begins at RVA 0x2114 + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void object::'.ctor'() + IL_0006: ret + } // end of method main::.ctor + + // method line 6 + .method public static hidebysig + default int32 Main () cil managed + { + // Method begins at RVA 0x211c + .entrypoint + // Code size 54 (0x36) + .maxstack 9 + .locals init ( + class Gen`1 V_0) + IL_0000: newobj instance void class Gen`1::'.ctor'() + IL_0005: stloc.0 + IL_0006: ldloc.0 + IL_0007: callvirt instance class [mscorlib]System.Type class Gen`1::typeOfT() + IL_000c: ldtoken ClassA + IL_0011: call class [mscorlib]System.Type class [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) + IL_0016: beq IL_001d + + IL_001b: ldc.i4.1 + IL_001c: ret + IL_001d: ldloc.0 + IL_001e: callvirt instance class [mscorlib]System.Type class Gen`1::typeOfGenT() + IL_0023: ldtoken class Gen`1 + IL_0028: call class [mscorlib]System.Type class [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) + IL_002d: beq IL_0034 + + IL_0032: ldc.i4.1 + IL_0033: ret + IL_0034: ldc.i4.0 + IL_0035: ret + } // end of method main::Main + + } // end of class main + diff --git a/mono/tests/generic-mkrefany.2.il b/mono/tests/generic-mkrefany.2.il new file mode 100644 index 00000000000..1d522b61545 --- /dev/null +++ b/mono/tests/generic-mkrefany.2.il @@ -0,0 +1,168 @@ +.assembly extern mscorlib +{ + .ver 2:0:0:0 + .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. +} +.assembly 'generic-mkrefany.2' +{ + .custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::'.ctor'() = ( + 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx + 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows. + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module 'generic-mkrefany.2.exe' // GUID = {51FFBB77-6AFB-435E-B206-16DB5C8A3730} + + + .class public auto ansi beforefieldinit ClassA + extends [mscorlib]System.Object + { + + // method line 1 + .method public hidebysig specialname rtspecialname + instance default void '.ctor' () cil managed + { + // Method begins at RVA 0x20ec + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void object::'.ctor'() + IL_0006: ret + } // end of method ClassA::.ctor + + } // end of class ClassA + + .class public sequential ansi sealed beforefieldinit GenStruct`1 + extends [mscorlib]System.ValueType + { + .field public int32 field1 + .field public !0 field2 + + } // end of class GenStruct`1 + + .class public auto ansi beforefieldinit Gen`1 + extends [mscorlib]System.Object + { + + // method line 2 + .method public hidebysig specialname rtspecialname + instance default void '.ctor' () cil managed + { + // Method begins at RVA 0x20f4 + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void object::'.ctor'() + IL_0006: ret + } // end of method Gen`1::.ctor + + // method line 3 + .method public hidebysig + instance default !T ident (!T t) cil managed + { + // Method begins at RVA 0x20fc + // Code size 4 (0x4) + .maxstack 1 + .locals init ( + !T V_0) + IL_0000: ldarg.1 + IL_0001: stloc.0 + ldloca 0 + mkrefany !0 + refanyval ClassA + ldobj ClassA + IL_0003: ret + } // end of method Gen`1::ident + + // method line 4 + .method public hidebysig + instance default valuetype GenStruct`1 structIdent (valuetype GenStruct`1 gst) cil managed + { + // Method begins at RVA 0x210c + // Code size 4 (0x4) + .maxstack 1 + .locals init ( + valuetype GenStruct`1 V_0) + IL_0000: ldarg.1 + IL_0001: stloc.0 + ldloca 0 + mkrefany valuetype GenStruct`1 + refanyval valuetype GenStruct`1 + ldobj valuetype GenStruct`1 + IL_0003: ret + } // end of method Gen`1::structIdent + + } // end of class Gen`1 + + .class public auto ansi beforefieldinit main + extends [mscorlib]System.Object + { + + // method line 5 + .method public hidebysig specialname rtspecialname + instance default void '.ctor' () cil managed + { + // Method begins at RVA 0x211c + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void object::'.ctor'() + IL_0006: ret + } // end of method main::.ctor + + // method line 6 + .method public static hidebysig + default int32 Main () cil managed + { + // Method begins at RVA 0x2124 + .entrypoint + // Code size 94 (0x5e) + .maxstack 8 + .locals init ( + class ClassA V_0, + valuetype GenStruct`1 V_1, + class Gen`1 V_2, + valuetype GenStruct`1 V_3) + IL_0000: newobj instance void class ClassA::'.ctor'() + IL_0005: stloc.0 + IL_0006: ldloca.s 1 + IL_0008: ldc.i4.s 0x7b + IL_000a: stfld int32 valuetype GenStruct`1::field1 + IL_000f: ldloca.s 1 + IL_0011: ldloc.0 + IL_0012: stfld !0 valuetype GenStruct`1::field2 + IL_0017: newobj instance void class Gen`1::'.ctor'() + IL_001c: stloc.2 + IL_001d: ldloc.2 + IL_001e: ldloc.0 + IL_001f: callvirt instance !0 class Gen`1::ident(!0) + IL_0024: ldloc.0 + IL_0025: beq IL_002c + + IL_002a: ldc.i4.1 + IL_002b: ret + IL_002c: ldloc.2 + IL_002d: ldloc.1 + IL_002e: callvirt instance valuetype GenStruct`1 class Gen`1::structIdent(valuetype GenStruct`1) + IL_0033: stloc.3 + IL_0034: ldloca.s 3 + IL_0036: ldfld int32 valuetype GenStruct`1::field1 + IL_003b: ldloca.s 1 + IL_003d: ldfld int32 valuetype GenStruct`1::field1 + IL_0042: bne.un IL_005a + + IL_0047: ldloca.s 3 + IL_0049: ldfld !0 valuetype GenStruct`1::field2 + IL_004e: ldloca.s 1 + IL_0050: ldfld !0 valuetype GenStruct`1::field2 + IL_0055: beq IL_005c + + IL_005a: ldc.i4.1 + IL_005b: ret + IL_005c: ldc.i4.0 + IL_005d: ret + } // end of method main::Main + + } // end of class main + diff --git a/mono/tests/generic-sizeof.2.cs b/mono/tests/generic-sizeof.2.cs new file mode 100644 index 00000000000..7db2227c333 --- /dev/null +++ b/mono/tests/generic-sizeof.2.cs @@ -0,0 +1,26 @@ +public class ClassA {} +public struct GenStruct { + int field1; + long field2; + T field3; +} +public struct Struct { + int field1; + long field2; + byte field3; +} + +public class Gen { + public unsafe int sizeofGenStructT () { return sizeof (Struct); } +} + +public class main { + public static unsafe int Main () { + Gen ga = new Gen (); + + if (ga.sizeofGenStructT () != sizeof (Struct)) + return 1; + + return 0; + } +} diff --git a/mono/tests/generic-tailcall.2.il b/mono/tests/generic-tailcall.2.il new file mode 100644 index 00000000000..9bf9bac5e20 --- /dev/null +++ b/mono/tests/generic-tailcall.2.il @@ -0,0 +1,133 @@ +.assembly extern mscorlib +{ + .ver 2:0:0:0 + .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. +} +.assembly 'generic-tailcall.2' +{ + .custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::'.ctor'() = ( + 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx + 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows. + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module 'generic-tailcall.2.exe' // GUID = {06726C6C-6C85-4737-B731-8585E31F7647} + + + .class public auto ansi beforefieldinit ClassA + extends [mscorlib]System.Object + { + + // method line 1 + .method public hidebysig specialname rtspecialname + instance default void '.ctor' () cil managed + { + // Method begins at RVA 0x20ec + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void object::'.ctor'() + IL_0006: ret + } // end of method ClassA::.ctor + + } // end of class ClassA + + .class public auto ansi beforefieldinit Gen`1 + extends [mscorlib]System.Object + { + + // method line 2 + .method public hidebysig specialname rtspecialname + instance default void '.ctor' () cil managed + { + // Method begins at RVA 0x20f4 + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void object::'.ctor'() + IL_0006: ret + } // end of method Gen`1::.ctor + + // method line 3 + .method public hidebysig + instance default !T[] caller (int32 x) cil managed + { + // Method begins at RVA 0x20fc + // Code size 10 (0xa) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: ldc.i4.1 + IL_0003: add + IL_0004: tail. call instance !0[] class Gen`1::callee(int32) + IL_0009: ret + } // end of method Gen`1::caller + + // method line 4 + .method public hidebysig + instance default !T[] callee (int32 x) cil managed + { + // Method begins at RVA 0x2108 + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: newarr !0 + IL_0006: ret + } // end of method Gen`1::callee + + } // end of class Gen`1 + + .class public auto ansi beforefieldinit main + extends [mscorlib]System.Object + { + + // method line 5 + .method public hidebysig specialname rtspecialname + instance default void '.ctor' () cil managed + { + // Method begins at RVA 0x2110 + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void object::'.ctor'() + IL_0006: ret + } // end of method main::.ctor + + // method line 6 + .method public static hidebysig + default int32 Main () cil managed + { + // Method begins at RVA 0x2118 + .entrypoint + // Code size 48 (0x30) + .maxstack 7 + .locals init ( + class Gen`1 V_0, + class ClassA[] V_1) + IL_0000: newobj instance void class Gen`1::'.ctor'() + IL_0005: stloc.0 + IL_0006: ldloc.0 + IL_0007: ldc.i4.3 + IL_0008: callvirt instance !0[] class Gen`1::caller(int32) + IL_000d: stloc.1 + IL_000e: ldloc.1 + IL_000f: callvirt instance class [mscorlib]System.Type object::GetType() + IL_0014: ldtoken class ClassA[] + IL_0019: call class [mscorlib]System.Type class [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) + IL_001e: bne.un IL_002c + + IL_0023: ldloc.1 + IL_0024: ldlen + IL_0025: conv.i4 + IL_0026: ldc.i4.4 + IL_0027: beq IL_002e + + IL_002c: ldc.i4.1 + IL_002d: ret + IL_002e: ldc.i4.0 + IL_002f: ret + } // end of method main::Main + + } // end of class main + diff --git a/mono/tests/generic-unbox.2.cs b/mono/tests/generic-unbox.2.cs new file mode 100644 index 00000000000..71c789ca108 --- /dev/null +++ b/mono/tests/generic-unbox.2.cs @@ -0,0 +1,20 @@ +using UnboxTest; + +public class ClassA {}; + +public class main { + public static int Main () { + UnboxerStruct us; + Unboxer u = new Unboxer (); + + us.field = 123; + + if (u.unbox ((object)us).field != 123) + return 1; + if (u.unboxNullable ((object)us).Value.field != 123) + return 1; + if (u.unboxNullable (null) != null) + return 1; + return 0; + } +} diff --git a/mono/tests/generic-unboxing.2.il b/mono/tests/generic-unboxing.2.il new file mode 100644 index 00000000000..c12cfa59a16 --- /dev/null +++ b/mono/tests/generic-unboxing.2.il @@ -0,0 +1,74 @@ +.assembly extern mscorlib +{ + .ver 2:0:0:0 + .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. +} +.assembly 'generic-unboxing.2' +{ + .custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::'.ctor'() = ( + 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx + 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows. + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module 'generic-unboxing.2.dll' // GUID = {0285A5AB-E59B-4ED1-848C-3BB9C270CB7D} + +.namespace UnboxTest +{ + .class public sequential ansi sealed beforefieldinit UnboxerStruct`1 + extends [mscorlib]System.ValueType + { + .field public int32 'field' + + } // end of class UnboxTest.UnboxerStruct`1 +} + +.namespace UnboxTest +{ + .class public auto ansi beforefieldinit Unboxer`1 + extends [mscorlib]System.Object + { + + // method line 1 + .method public hidebysig specialname rtspecialname + instance default void '.ctor' () cil managed + { + // Method begins at RVA 0x20ec + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void object::'.ctor'() + IL_0006: ret + } // end of method Unboxer`1::.ctor + + // method line 2 + .method public hidebysig + instance default valuetype [mscorlib]System.Nullable`1> 'unboxNullable' (object obj) cil managed + { + // Method begins at RVA 0x20f4 + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.1 + // IL_0001: unbox.any valuetype [mscorlib]System.Nullable`1> + IL_0001: unbox valuetype [mscorlib]System.Nullable`1> + IL_0002: ldobj valuetype [mscorlib]System.Nullable`1> + IL_0006: ret + } // end of method Unboxer`1::unboxNullable + + // method line 2 + .method public hidebysig + instance default valuetype UnboxTest.UnboxerStruct`1 'unbox' (object obj) cil managed + { + // Method begins at RVA 0x20f4 + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: unbox valuetype UnboxTest.UnboxerStruct`1 + IL_0002: ldobj valuetype UnboxTest.UnboxerStruct`1 + IL_0006: ret + } // end of method Unboxer`1::unbox + + } // end of class Unboxer`1 + +} diff --git a/mono/tests/generic-virtual.2.cs b/mono/tests/generic-virtual.2.cs new file mode 100644 index 00000000000..d20c72ba650 --- /dev/null +++ b/mono/tests/generic-virtual.2.cs @@ -0,0 +1,62 @@ +using System; + +public class ClassA {} +public class ClassB {} + +public class Gen { + static bool checkArr (Array arr, int length) { + if (arr.GetType () != typeof (S[])) + return false; + if (arr.Length != length) + return false; + return true; + } + + public bool test () { + return checkArr (newArr (), myLength ()); + } + + public virtual int myLength () { + return 3; + } + + public virtual S[] newArr () { + return new S[3]; + } +} + +public class GenSub : Gen { + public override int myLength () { + return 4; + } + + public override S[] newArr () { + return new S[4]; + } +} + +public class GenSubSub : GenSub { + public override int myLength () { + return 5; + } + + public override S[] newArr () { + return new S[5]; + } +} + +public class main { + public static int Main () { + Gen ga = new Gen (); + Gen gsa = new GenSub (); + Gen gss = new GenSubSub (); + + if (!ga.test ()) + return 1; + if (!gsa.test ()) + return 1; + if (!gss.test ()) + return 1; + return 0; + } +} diff --git a/mono/tests/generics-sharing.2.cs b/mono/tests/generics-sharing.2.cs index 5f0118e25dd..1ea6f5572fa 100644 --- a/mono/tests/generics-sharing.2.cs +++ b/mono/tests/generics-sharing.2.cs @@ -46,6 +46,8 @@ public class GenBi { } public struct GenStruct { + public static int staticField; + public int field; public int dummy1; public int dummy2; @@ -69,6 +71,30 @@ public interface IGen { GenStruct valueIMethod (int x); } +public class IGenImpl : IGen { + public int field; + + public T[] iMethod () { + return new T[3]; + } + + public void voidIMethod (int x) { + field = x; + } + + public long longIMethod (long x) { + return x + 1; + } + + public float floatIMethod () { + return 1.0f; + } + + public GenStruct valueIMethod (int x) { + return new GenStruct (x); + } +} + public class GenA { public static T[] arr; @@ -94,6 +120,10 @@ public class GenA { return NonGen.field; } + public int getGenStructStaticField () { + return GenStruct.staticField; + } + public T[] getArr () { return arr; } @@ -127,6 +157,10 @@ public class GenA { return (T)obj; } + public GenStruct structCast (Object obj) { + return (GenStruct)obj; + } + public Type ldtokenT () { return typeof (T); } @@ -143,6 +177,14 @@ public class GenA { return typeof (GenB<>); } + public GenStruct? makeNullable (Object obj) { + return (GenStruct?)obj; + } + + public object unmakeNullable (GenStruct? obj) { + return (object)obj; + } + public void except () { try { NonGen.doThrow (); @@ -212,6 +254,32 @@ public class GenA { public static long staticBiLongCaller (long x) { return GenBi.staticLongMethod (x); } + + public int structCaller (int x) { + GenStruct> gs = new GenStruct> (123); + + return gs.method (x); + } + + public T[] callInterface (IGen ig) { + return ig.iMethod (); + } + + public void callVoidInterface (IGen ig, int x) { + ig.voidIMethod (x); + } + + public long callLongInterface (IGen ig, long x) { + return ig.longIMethod (x); + } + + public float callFloatInterface (IGen ig) { + return ig.floatIMethod (); + } + + public GenStruct callValueInterface (IGen ig, int x) { + return ig.valueIMethod (x); + } } public class GenB { @@ -347,22 +415,36 @@ public class RGCTXTestSubASubSub : RGCTXTestSubASub { } public class main { + delegate void ActionDelegate (); + static bool haveError = false; - public static void error (string message) { + static void error (string message) { haveError = true; Console.WriteLine (message); } - public static void typeCheck (String method, Object obj, Type t) { + static void typeCheck (String method, Object obj, Type t) { if (obj.GetType () != t) error ("object from " + method + " should have type " + t.ToString () + " but has type " + obj.GetType ().ToString ()); } - public static int callStaticMethod () { + static int callStaticMethod () { return GenA.staticMethod (); } + static void checkException (String method, ActionDelegate action) where T : Exception { + try { + try { + action (); + } catch (T) { + return; + } + } catch (Exception exc) { + error ("method " + method + " should have thrown " + typeof (T).ToString () + " but did throw " + exc); + } + } + public static void work (T obj, bool mustCatch) { EqualityComparer comp = EqualityComparer.Default; @@ -382,6 +464,11 @@ public class main { if (ga.getNonGenField () != 123) error ("getNonGenField"); + GenStruct.staticField = 321; + if (ga.getGenStructStaticField () != 321) + error ("getGenStructStaticField"); + GenStruct.staticField = -1; + ga.hash (obj); if (!comp.Equals (ga.ident (obj), obj)) @@ -389,6 +476,22 @@ public class main { if (!comp.Equals (ga.cast (obj), obj)) error ("cast"); + if (typeof (T).IsValueType) { + checkException ("cast null value", delegate { ga.cast (null); }); + } else { + if (ga.cast (null) != null) + error ("cast null"); + } + + GenStruct genstructt = new GenStruct (453); + if (ga.structCast ((object)genstructt).field != 453) + error ("structCast"); + checkException ("structCast null", delegate { ga.structCast (null); }); + + if (ga.makeNullable ((object)genstructt).Value.field != 453) + error ("makeNullable"); + if (ga.makeNullable (null) != null) + error ("makeNullable null"); if (ga.ldtokenT () != typeof (T)) error ("ldtokenT"); @@ -443,28 +546,28 @@ public class main { if (GenA.staticFloatMethod () != 1.0) error ("staticFloatMethod"); - new GenADeriv (); + if (ga.structCaller (234) != 357) + error ("structCaller"); - if (mustCatch) { - bool didCatch = false; + IGenImpl igi = new IGenImpl (); - try { - ga.except (); - } catch (GenExc) { - didCatch = true; - } - if (!didCatch) - error ("except"); + typeCheck ("callInterface", ga.callInterface (igi), typeof (T[])); + if (ga.callLongInterface (igi, 345) != 346) + error ("callLongInterface"); + GenStruct gst = ga.callValueInterface (igi, 543); + if (gst.field != 543) + error ("callValueInterface"); + ga.callVoidInterface (igi, 654); + if (igi.field != 654) + error ("callVoidInterface"); + if (ga.callFloatInterface (igi) != 1.0f) + error ("callFloatInterface"); - didCatch = false; + new GenADeriv (); - try { - GenA.staticExcept (); - } catch (GenExc) { - didCatch = true; - } - if (!didCatch) - error ("staticExcept"); + if (mustCatch) { + checkException> ("except", delegate { ga.except (); }); + checkException> ("staticExcept", delegate { GenA.staticExcept (); }); } else { ga.except (); GenA.staticExcept (); @@ -529,10 +632,14 @@ public class main { { work (new ClassA (), false); work (new ClassB (), true); + work (new ClassB (), true); work (new ClassC (), true); work> (new GenA (), true); work (new int[3], true); work (123, true); + work (123, true); + work?> (new GenStruct (123), true); + work?> (null, true); StaticTest sa = new StaticTest (1234); StaticTest sb = new StaticTest (2345); -- 2.25.1