Permalink
Browse files

2007-10-29 Rodrigo Kumpera <rkumpera@novell.com>

	* bug-335131.2.cs: Regression test for bug #335131.
	It tests the enconding of methods and constructor from
	a generic types that are called from the same type
	that defines then.

	* Makefile.am: Added the new test to the suite.
	

svn path=/trunk/mono/; revision=88409
  • Loading branch information...
1 parent 995589b commit 144f7b890259a7fd079c966508deb2c5f5f7e77a @kumpera kumpera committed Oct 29, 2007
Showing with 91 additions and 1 deletion.
  1. +10 −0 mono/tests/ChangeLog
  2. +2 −1 mono/tests/Makefile.am
  3. +79 −0 mono/tests/bug-335131.2.cs
View
@@ -1,3 +1,13 @@
+2007-10-29 Rodrigo Kumpera <rkumpera@novell.com>
+
+ * bug-335131.2.cs: Regression test for bug #335131.
+ It tests the enconding of methods and constructor from
+ a generic types that are called from the same type
+ that defines then.
+
+ * Makefile.am: Added the new test to the suite.
+
+
2007-10-29 Rodrigo Kumpera <rkumpera@novell.com>
* make_imt_test.sh: added, this script generates
View
@@ -308,7 +308,8 @@ TEST_CS2_SRC = \
generic_type_definition_encoding.2.cs \
generic_type_definition.2.cs \
bug-333798.2.cs \
- bug-333798-tb.2.cs
+ bug-333798-tb.2.cs \
+ bug-335131.2.cs
TEST_IL2_SRC = find-method.2.il \
bug-79215.2.il \
View
@@ -0,0 +1,79 @@
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+
+
+class Bla<T> {
+ public T t;
+}
+public class Entry
+{
+ public static int Main()
+ {
+ Bla<int> d = new Bla<int>();
+ d.t = 99;
+ Instance();
+
+ AppDomain domain = AppDomain.CreateDomain ("test");
+ try {
+ domain.ExecuteAssembly ("Instance.exe");
+ } catch (Exception e) {
+ Console.WriteLine ("assembly has thrown "+e);
+ return 1;
+ }
+ return 0;
+ }
+
+ public static void Instance()
+ {
+ AssemblyName name = new AssemblyName("Instance");
+ AssemblyBuilder asmbuild = System.Threading.Thread.GetDomain().DefineDynamicAssembly(name, AssemblyBuilderAccess.RunAndSave);
+ ModuleBuilder mod = asmbuild.DefineDynamicModule("Instance.exe");
+
+ TypeBuilder G = mod.DefineType("G", TypeAttributes.Public);
+ Type T = G.DefineGenericParameters("T")[0];
+ Type GObj = G.MakeGenericType(new Type[] { typeof(object) });
+
+ ConstructorBuilder Ctor = G.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, null);
+ {
+ ILGenerator il = Ctor.GetILGenerator();
+ il.Emit(OpCodes.Ldarg_0);
+ il.Emit(OpCodes.Call, typeof(object).GetConstructor(new Type[0]));
+ il.Emit(OpCodes.Ret);
+ }
+
+ MethodBuilder Bar = G.DefineMethod("Bar", MethodAttributes.Public);
+ {
+ ILGenerator il = Bar.GetILGenerator();
+ il.Emit(OpCodes.Ret);
+ }
+
+ MethodBuilder Foo = G.DefineMethod("Foo", MethodAttributes.Public | MethodAttributes.Static );
+ {
+ ILGenerator il = Foo.GetILGenerator();
+ il.Emit(OpCodes.Newobj, Ctor);
+ il.Emit(OpCodes.Call, Bar);
+ il.Emit(OpCodes.Ret);
+ }
+
+ TypeBuilder M = mod.DefineType("M", TypeAttributes.Public);
+
+
+ MethodBuilder main = M.DefineMethod("Main", MethodAttributes.Public | MethodAttributes.Static );
+ {
+ ILGenerator il = main.GetILGenerator();
+ il.Emit(OpCodes.Call, TypeBuilder.GetMethod (GObj, Foo));
+ il.Emit(OpCodes.Ret);
+ }
+
+ asmbuild.SetEntryPoint (main);
+ G.CreateType();
+ M.CreateType();
+
+ asmbuild.Save("Instance.exe");
+
+
+ Console.WriteLine("ok");
+ }
+
+}

0 comments on commit 144f7b8

Please sign in to comment.