Skip to content
Browse files

2008-06-26 Mark Probst <mark.probst@gmail.com>

	* generic-valuetype-interface.2.cs: Test for generic valuetypes
	which implement interfaces.

	* generic-valuetype-newobj.2.il, generic-valuetype-newobj2.2.il:
	Test for newobj with generic valuetypes.

	* Makefile.am: Tests added.

svn path=/trunk/mono/; revision=106634
  • Loading branch information...
1 parent 62ba7e0 commit 65121e7c9bde38db3a1ebb9bcb423ef01bb9ea1f @schani schani committed Jun 26, 2008
View
10 mono/tests/ChangeLog
@@ -1,3 +1,13 @@
+2008-06-26 Mark Probst <mark.probst@gmail.com>
+
+ * generic-valuetype-interface.2.cs: Test for generic valuetypes
+ which implement interfaces.
+
+ * generic-valuetype-newobj.2.il, generic-valuetype-newobj2.2.il:
+ Test for newobj with generic valuetypes.
+
+ * Makefile.am: Tests added.
+
2008-06-25 Rodrigo Kumpera <rkumpera@novell.com>
* generic-ldtoken-method.2.il: Don't use GetMethodHandle/1
View
8 mono/tests/Makefile.am
@@ -276,6 +276,7 @@ BASE_TEST_CS_SRC= \
generic-special.2.cs \
generic-exceptions.2.cs \
generic-virtual2.2.cs \
+ generic-valuetype-interface.2.cs \
recursive-generics.2.cs \
bug-80392.2.cs \
dynamic-method-access.2.cs \
@@ -382,7 +383,9 @@ TEST_IL_SRC= \
generic-ldtoken-field.2.il \
generic-tailcall.2.il \
generic-tailcall2.2.il \
- generic-array-exc.2.il
+ generic-array-exc.2.il \
+ generic-valuetype-newobj2.2.il \
+ generic-valuetype-newobj.2.il
# bug-318677.il
@@ -711,7 +714,8 @@ test-generic-sharing : generics-sharing.2.exe shared-generic-methods.2.exe \
generic-null-call.2.exe generic-tailcall2.2.exe \
generic-array-exc.2.exe generic-special.2.exe \
generic-exceptions.2.exe \
- generic-virtual2.2.exe
+ generic-virtual2.2.exe generic-valuetype-interface.2.exe \
+ generic-valuetype-newobj.2.exe generic-valuetype-newobj2.2.exe
for fn in $+ ; do \
echo "Testing $$fn ..."; \
MONO_GENERIC_SHARING=all $(RUNTIME) -O=gshared $$fn || exit 1; \
View
86 mono/tests/generic-valuetype-interface.2.cs
@@ -0,0 +1,86 @@
+using System;
+using System.Collections.Generic;
+
+public struct GenStruct<T> {
+ public int inc (int i) {
+ return i + 1;
+ }
+
+ public T[] newArr () {
+ return new T [3];
+ }
+}
+
+public class Bla {
+ public bool work (IList<string> l) {
+ foreach (string s in l) {
+ if (s.Length != 1)
+ return false;
+ }
+ return true;
+ }
+}
+
+public interface GenInterface<T> {
+ T[] newArr ();
+}
+
+public struct GenIntStruct<T> : GenInterface<T> {
+ public T[] newArr () {
+ return new T [3];
+ }
+}
+
+public interface GenFactory<T> {
+ GenInterface<T> makeInterface ();
+}
+
+public class Gen<T> : GenFactory<T> {
+ public GenInterface<T> makeInterface () {
+ return new GenIntStruct<T> ();
+ }
+}
+
+public class NonGen : GenFactory<string> {
+ public GenInterface<string> makeInterface () {
+ return new GenIntStruct<string> ();
+ }
+}
+
+public class main {
+ public static bool testInterface (GenFactory<string> gf) {
+ GenInterface<string> gi = gf.makeInterface ();
+ if (gi.newArr ().GetType () != typeof (string []))
+ return false;
+ return true;
+ }
+
+ public static int Main () {
+ GenStruct<object> gso = new GenStruct<object> ();
+ GenStruct<string> gss = new GenStruct<string> ();
+
+ if (gso.inc (1) != 2)
+ return 1;
+ if (gss.inc (2) != 3)
+ return 1;
+
+ if (gso.newArr ().GetType () != typeof (object []))
+ return 1;
+ if (gss.newArr ().GetType () != typeof (string []))
+ return 1;
+
+ Gen<string> g = new Gen<string> ();
+ testInterface (g);
+
+ NonGen ng = new NonGen ();
+ testInterface (ng);
+
+ Bla bla = new Bla ();
+ string [] arr = { "a", "b", "c" };
+
+ if (!bla.work (arr))
+ return 1;
+
+ return 0;
+ }
+}
View
93 mono/tests/generic-valuetype-newobj.2.il
@@ -0,0 +1,93 @@
+.assembly extern mscorlib
+{
+ .ver 2:0:0:0
+ .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
+}
+.assembly 'generic-valuetype-newobj.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-valuetype-newobj.2.exe' // GUID = {F6750CB7-6941-4C99-83C6-C591622CA936}
+
+
+ .class public sequential ansi sealed beforefieldinit Gen`1<S>
+ extends [mscorlib]System.ValueType
+ {
+ .field public !0[] arr
+
+ // method line 1
+ .method public hidebysig specialname rtspecialname
+ instance default void '.ctor' (int32 i) cil managed
+ {
+ // Method begins at RVA 0x20ec
+ // Code size 13 (0xd)
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: ldarg.1
+ IL_0002: newarr !0
+ IL_0007: stfld !0[] valuetype Gen`1<!0>::arr
+ IL_000c: ret
+ } // end of method Gen`1::.ctor
+
+ } // end of class Gen`1
+
+ .class public auto ansi beforefieldinit main
+ extends [mscorlib]System.Object
+ {
+
+ // method line 2
+ .method public hidebysig specialname rtspecialname
+ instance default void '.ctor' () cil managed
+ {
+ // Method begins at RVA 0x20fc
+ // 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 3
+ .method public static hidebysig
+ default valuetype Gen`1<string> newGen () cil managed
+ {
+ // Method begins at RVA 0x2104
+ // Code size 10 (0xa)
+ .maxstack 3
+ IL_0002: ldc.i4.3
+ newobj instance void valuetype Gen`1<string>::'.ctor'(int32)
+ IL_0009: ret
+ } // end of method main::newGen
+
+ // method line 4
+ .method public static hidebysig
+ default int32 Main () cil managed
+ {
+ // Method begins at RVA 0x211c
+ .entrypoint
+ // Code size 37 (0x25)
+ .maxstack 6
+ .locals init (
+ valuetype Gen`1<string> V_0)
+ IL_0000: call valuetype Gen`1<string> class main::newGen()
+ IL_0005: stloc.0
+ IL_0006: ldloca.s 0
+ IL_0008: ldfld !0[] valuetype Gen`1<string>::arr
+ IL_000d: callvirt instance class [mscorlib]System.Type object::GetType()
+ IL_0012: ldtoken string[]
+ IL_0017: call class [mscorlib]System.Type class [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
+ IL_001c: beq IL_0023
+
+ IL_0021: ldc.i4.1
+ IL_0022: ret
+ IL_0023: ldc.i4.0
+ IL_0024: ret
+ } // end of method main::Main
+
+ } // end of class main
+
View
93 mono/tests/generic-valuetype-newobj2.2.il
@@ -0,0 +1,93 @@
+.assembly extern mscorlib
+{
+ .ver 2:0:0:0
+ .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
+}
+.assembly 'generic-valuetype-newobj2.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-valuetype-newobj2.2.exe' // GUID = {E84A2C06-0CD3-4155-9334-02045F2698FF}
+
+
+ .class public sequential ansi sealed beforefieldinit Gen
+ extends [mscorlib]System.ValueType
+ {
+ .field public object arr
+
+ // method line 1
+ .method public hidebysig specialname rtspecialname
+ instance default void '.ctor'<T> (int32 i) cil managed
+ {
+ // Method begins at RVA 0x20ec
+ // Code size 8 (0x8)
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: ldarg.1
+ IL_0002: newarr !!0
+ IL_0007: stfld object Gen::arr
+ IL_000c: ret
+ } // end of method Gen::.ctor
+
+ } // end of class Gen
+
+ .class public auto ansi beforefieldinit main
+ extends [mscorlib]System.Object
+ {
+
+ // method line 3
+ .method public hidebysig specialname rtspecialname
+ instance default void '.ctor' () cil managed
+ {
+ // Method begins at RVA 0x2108
+ // 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 4
+ .method public static hidebysig
+ default valuetype Gen newGen () cil managed
+ {
+ // Method begins at RVA 0x2110
+ // Code size 10 (0xa)
+ .maxstack 3
+ IL_0002: ldc.i4.3
+ newobj instance void valuetype Gen::'.ctor'<string>(int32)
+ IL_0009: ret
+ } // end of method main::newGen
+
+ // method line 5
+ .method public static hidebysig
+ default int32 Main () cil managed
+ {
+ // Method begins at RVA 0x2128
+ .entrypoint
+ // Code size 37 (0x25)
+ .maxstack 6
+ .locals init (
+ valuetype Gen V_0)
+ IL_0000: call valuetype Gen class main::newGen()
+ IL_0005: stloc.0
+ IL_0006: ldloca.s 0
+ IL_0008: ldfld object Gen::arr
+ IL_000d: callvirt instance class [mscorlib]System.Type object::GetType()
+ IL_0012: ldtoken string[]
+ IL_0017: call class [mscorlib]System.Type class [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
+ IL_001c: beq IL_0023
+
+ IL_0021: ldc.i4.1
+ IL_0022: ret
+ IL_0023: ldc.i4.0
+ IL_0024: ret
+ } // end of method main::Main
+
+ } // end of class main
+

0 comments on commit 65121e7

Please sign in to comment.
Something went wrong with that request. Please try again.