Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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...
commit 65121e7c9bde38db3a1ebb9bcb423ef01bb9ea1f 1 parent 62ba7e0
Mark Probst schani authored
10 mono/tests/ChangeLog
... ... @@ -1,3 +1,13 @@
  1 +2008-06-26 Mark Probst <mark.probst@gmail.com>
  2 +
  3 + * generic-valuetype-interface.2.cs: Test for generic valuetypes
  4 + which implement interfaces.
  5 +
  6 + * generic-valuetype-newobj.2.il, generic-valuetype-newobj2.2.il:
  7 + Test for newobj with generic valuetypes.
  8 +
  9 + * Makefile.am: Tests added.
  10 +
1 11 2008-06-25 Rodrigo Kumpera <rkumpera@novell.com>
2 12
3 13 * generic-ldtoken-method.2.il: Don't use GetMethodHandle/1
8 mono/tests/Makefile.am
@@ -276,6 +276,7 @@ BASE_TEST_CS_SRC= \
276 276 generic-special.2.cs \
277 277 generic-exceptions.2.cs \
278 278 generic-virtual2.2.cs \
  279 + generic-valuetype-interface.2.cs \
279 280 recursive-generics.2.cs \
280 281 bug-80392.2.cs \
281 282 dynamic-method-access.2.cs \
@@ -382,7 +383,9 @@ TEST_IL_SRC= \
382 383 generic-ldtoken-field.2.il \
383 384 generic-tailcall.2.il \
384 385 generic-tailcall2.2.il \
385   - generic-array-exc.2.il
  386 + generic-array-exc.2.il \
  387 + generic-valuetype-newobj2.2.il \
  388 + generic-valuetype-newobj.2.il
386 389
387 390 # bug-318677.il
388 391
@@ -711,7 +714,8 @@ test-generic-sharing : generics-sharing.2.exe shared-generic-methods.2.exe \
711 714 generic-null-call.2.exe generic-tailcall2.2.exe \
712 715 generic-array-exc.2.exe generic-special.2.exe \
713 716 generic-exceptions.2.exe \
714   - generic-virtual2.2.exe
  717 + generic-virtual2.2.exe generic-valuetype-interface.2.exe \
  718 + generic-valuetype-newobj.2.exe generic-valuetype-newobj2.2.exe
715 719 for fn in $+ ; do \
716 720 echo "Testing $$fn ..."; \
717 721 MONO_GENERIC_SHARING=all $(RUNTIME) -O=gshared $$fn || exit 1; \
86 mono/tests/generic-valuetype-interface.2.cs
... ... @@ -0,0 +1,86 @@
  1 +using System;
  2 +using System.Collections.Generic;
  3 +
  4 +public struct GenStruct<T> {
  5 + public int inc (int i) {
  6 + return i + 1;
  7 + }
  8 +
  9 + public T[] newArr () {
  10 + return new T [3];
  11 + }
  12 +}
  13 +
  14 +public class Bla {
  15 + public bool work (IList<string> l) {
  16 + foreach (string s in l) {
  17 + if (s.Length != 1)
  18 + return false;
  19 + }
  20 + return true;
  21 + }
  22 +}
  23 +
  24 +public interface GenInterface<T> {
  25 + T[] newArr ();
  26 +}
  27 +
  28 +public struct GenIntStruct<T> : GenInterface<T> {
  29 + public T[] newArr () {
  30 + return new T [3];
  31 + }
  32 +}
  33 +
  34 +public interface GenFactory<T> {
  35 + GenInterface<T> makeInterface ();
  36 +}
  37 +
  38 +public class Gen<T> : GenFactory<T> {
  39 + public GenInterface<T> makeInterface () {
  40 + return new GenIntStruct<T> ();
  41 + }
  42 +}
  43 +
  44 +public class NonGen : GenFactory<string> {
  45 + public GenInterface<string> makeInterface () {
  46 + return new GenIntStruct<string> ();
  47 + }
  48 +}
  49 +
  50 +public class main {
  51 + public static bool testInterface (GenFactory<string> gf) {
  52 + GenInterface<string> gi = gf.makeInterface ();
  53 + if (gi.newArr ().GetType () != typeof (string []))
  54 + return false;
  55 + return true;
  56 + }
  57 +
  58 + public static int Main () {
  59 + GenStruct<object> gso = new GenStruct<object> ();
  60 + GenStruct<string> gss = new GenStruct<string> ();
  61 +
  62 + if (gso.inc (1) != 2)
  63 + return 1;
  64 + if (gss.inc (2) != 3)
  65 + return 1;
  66 +
  67 + if (gso.newArr ().GetType () != typeof (object []))
  68 + return 1;
  69 + if (gss.newArr ().GetType () != typeof (string []))
  70 + return 1;
  71 +
  72 + Gen<string> g = new Gen<string> ();
  73 + testInterface (g);
  74 +
  75 + NonGen ng = new NonGen ();
  76 + testInterface (ng);
  77 +
  78 + Bla bla = new Bla ();
  79 + string [] arr = { "a", "b", "c" };
  80 +
  81 + if (!bla.work (arr))
  82 + return 1;
  83 +
  84 + return 0;
  85 + }
  86 +}
93 mono/tests/generic-valuetype-newobj.2.il
... ... @@ -0,0 +1,93 @@
  1 +.assembly extern mscorlib
  2 +{
  3 + .ver 2:0:0:0
  4 + .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
  5 +}
  6 +.assembly 'generic-valuetype-newobj.2'
  7 +{
  8 + .custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::'.ctor'() = (
  9 + 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
  10 + 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
  11 +
  12 + .hash algorithm 0x00008004
  13 + .ver 0:0:0:0
  14 +}
  15 +.module 'generic-valuetype-newobj.2.exe' // GUID = {F6750CB7-6941-4C99-83C6-C591622CA936}
  16 +
  17 +
  18 + .class public sequential ansi sealed beforefieldinit Gen`1<S>
  19 + extends [mscorlib]System.ValueType
  20 + {
  21 + .field public !0[] arr
  22 +
  23 + // method line 1
  24 + .method public hidebysig specialname rtspecialname
  25 + instance default void '.ctor' (int32 i) cil managed
  26 + {
  27 + // Method begins at RVA 0x20ec
  28 + // Code size 13 (0xd)
  29 + .maxstack 8
  30 + IL_0000: ldarg.0
  31 + IL_0001: ldarg.1
  32 + IL_0002: newarr !0
  33 + IL_0007: stfld !0[] valuetype Gen`1<!0>::arr
  34 + IL_000c: ret
  35 + } // end of method Gen`1::.ctor
  36 +
  37 + } // end of class Gen`1
  38 +
  39 + .class public auto ansi beforefieldinit main
  40 + extends [mscorlib]System.Object
  41 + {
  42 +
  43 + // method line 2
  44 + .method public hidebysig specialname rtspecialname
  45 + instance default void '.ctor' () cil managed
  46 + {
  47 + // Method begins at RVA 0x20fc
  48 + // Code size 7 (0x7)
  49 + .maxstack 8
  50 + IL_0000: ldarg.0
  51 + IL_0001: call instance void object::'.ctor'()
  52 + IL_0006: ret
  53 + } // end of method main::.ctor
  54 +
  55 + // method line 3
  56 + .method public static hidebysig
  57 + default valuetype Gen`1<string> newGen () cil managed
  58 + {
  59 + // Method begins at RVA 0x2104
  60 + // Code size 10 (0xa)
  61 + .maxstack 3
  62 + IL_0002: ldc.i4.3
  63 + newobj instance void valuetype Gen`1<string>::'.ctor'(int32)
  64 + IL_0009: ret
  65 + } // end of method main::newGen
  66 +
  67 + // method line 4
  68 + .method public static hidebysig
  69 + default int32 Main () cil managed
  70 + {
  71 + // Method begins at RVA 0x211c
  72 + .entrypoint
  73 + // Code size 37 (0x25)
  74 + .maxstack 6
  75 + .locals init (
  76 + valuetype Gen`1<string> V_0)
  77 + IL_0000: call valuetype Gen`1<string> class main::newGen()
  78 + IL_0005: stloc.0
  79 + IL_0006: ldloca.s 0
  80 + IL_0008: ldfld !0[] valuetype Gen`1<string>::arr
  81 + IL_000d: callvirt instance class [mscorlib]System.Type object::GetType()
  82 + IL_0012: ldtoken string[]
  83 + IL_0017: call class [mscorlib]System.Type class [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
  84 + IL_001c: beq IL_0023
  85 +
  86 + IL_0021: ldc.i4.1
  87 + IL_0022: ret
  88 + IL_0023: ldc.i4.0
  89 + IL_0024: ret
  90 + } // end of method main::Main
  91 +
  92 + } // end of class main
  93 +
93 mono/tests/generic-valuetype-newobj2.2.il
... ... @@ -0,0 +1,93 @@
  1 +.assembly extern mscorlib
  2 +{
  3 + .ver 2:0:0:0
  4 + .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
  5 +}
  6 +.assembly 'generic-valuetype-newobj2.2'
  7 +{
  8 + .custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::'.ctor'() = (
  9 + 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
  10 + 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
  11 +
  12 + .hash algorithm 0x00008004
  13 + .ver 0:0:0:0
  14 +}
  15 +.module 'generic-valuetype-newobj2.2.exe' // GUID = {E84A2C06-0CD3-4155-9334-02045F2698FF}
  16 +
  17 +
  18 + .class public sequential ansi sealed beforefieldinit Gen
  19 + extends [mscorlib]System.ValueType
  20 + {
  21 + .field public object arr
  22 +
  23 + // method line 1
  24 + .method public hidebysig specialname rtspecialname
  25 + instance default void '.ctor'<T> (int32 i) cil managed
  26 + {
  27 + // Method begins at RVA 0x20ec
  28 + // Code size 8 (0x8)
  29 + .maxstack 8
  30 + IL_0000: ldarg.0
  31 + IL_0001: ldarg.1
  32 + IL_0002: newarr !!0
  33 + IL_0007: stfld object Gen::arr
  34 + IL_000c: ret
  35 + } // end of method Gen::.ctor
  36 +
  37 + } // end of class Gen
  38 +
  39 + .class public auto ansi beforefieldinit main
  40 + extends [mscorlib]System.Object
  41 + {
  42 +
  43 + // method line 3
  44 + .method public hidebysig specialname rtspecialname
  45 + instance default void '.ctor' () cil managed
  46 + {
  47 + // Method begins at RVA 0x2108
  48 + // Code size 7 (0x7)
  49 + .maxstack 8
  50 + IL_0000: ldarg.0
  51 + IL_0001: call instance void object::'.ctor'()
  52 + IL_0006: ret
  53 + } // end of method main::.ctor
  54 +
  55 + // method line 4
  56 + .method public static hidebysig
  57 + default valuetype Gen newGen () cil managed
  58 + {
  59 + // Method begins at RVA 0x2110
  60 + // Code size 10 (0xa)
  61 + .maxstack 3
  62 + IL_0002: ldc.i4.3
  63 + newobj instance void valuetype Gen::'.ctor'<string>(int32)
  64 + IL_0009: ret
  65 + } // end of method main::newGen
  66 +
  67 + // method line 5
  68 + .method public static hidebysig
  69 + default int32 Main () cil managed
  70 + {
  71 + // Method begins at RVA 0x2128
  72 + .entrypoint
  73 + // Code size 37 (0x25)
  74 + .maxstack 6
  75 + .locals init (
  76 + valuetype Gen V_0)
  77 + IL_0000: call valuetype Gen class main::newGen()
  78 + IL_0005: stloc.0
  79 + IL_0006: ldloca.s 0
  80 + IL_0008: ldfld object Gen::arr
  81 + IL_000d: callvirt instance class [mscorlib]System.Type object::GetType()
  82 + IL_0012: ldtoken string[]
  83 + IL_0017: call class [mscorlib]System.Type class [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
  84 + IL_001c: beq IL_0023
  85 +
  86 + IL_0021: ldc.i4.1
  87 + IL_0022: ret
  88 + IL_0023: ldc.i4.0
  89 + IL_0024: ret
  90 + } // end of method main::Main
  91 +
  92 + } // end of class main
  93 +

0 comments on commit 65121e7

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