Procházet zdrojové kódy

2007-10-17 Mark Probst <[email protected]>

	* bug-331798-tb.2.cs: added for Rodrigo

	* Makefile.am: added bug-331798-tb.2.cs

svn path=/trunk/mono/; revision=87650
Mark Probst před 18 roky
rodič
revize
4a520fc042
3 změnil soubory, kde provedl 72 přidání a 1 odebrání
  1. 6 0
      mono/tests/ChangeLog
  2. 2 1
      mono/tests/Makefile.am
  3. 64 0
      mono/tests/bug-333798-tb.2.cs

+ 6 - 0
mono/tests/ChangeLog

@@ -1,3 +1,9 @@
+2007-10-17  Mark Probst  <[email protected]>
+
+	* bug-331798-tb.2.cs: added for Rodrigo
+
+	* Makefile.am: added bug-331798-tb.2.cs
+
 2007-10-17 Gert Driesen  <[email protected]>
 
 	* bug-331958.cs: added.

+ 2 - 1
mono/tests/Makefile.am

@@ -305,7 +305,8 @@ TEST_CS2_SRC = \
 	ienumerator-interfaces.2.cs	\
 	generic_type_definition_encoding.2.cs \
 	generic_type_definition.2.cs	\
-	bug-333798.2.cs
+	bug-333798.2.cs		\
+	bug-333798-tb.2.cs
 
 TEST_IL2_SRC = find-method.2.il	\
 	bug-79215.2.il	\

+ 64 - 0
mono/tests/bug-333798-tb.2.cs

@@ -0,0 +1,64 @@
+using System;
+using System.Threading;
+using System.Reflection;
+using System.Reflection.Emit;
+using System.IO;
+using System.Security;
+using System.Security.Permissions;
+using System.Runtime.InteropServices;
+using System.Collections.Generic;
+
+public class Gen<T> {
+        public static Gen<T>[] newSelfArr () {
+                return null;
+        }
+}
+
+public class Driver {
+        public static void Test () {
+                Gen<int>.newSelfArr ();
+        }
+}
+
+public class GenericsTests
+{
+	static AssemblyBuilder assembly;
+	static ModuleBuilder module;
+
+	static void SetUp ()
+	{
+		AssemblyName assemblyName = new AssemblyName ();
+		assemblyName.Name = "TestAssembly";
+		assembly = 
+			Thread.GetDomain ().DefineDynamicAssembly (
+				assemblyName, AssemblyBuilderAccess.RunAndSave, ".");
+		module = assembly.DefineDynamicModule ("module1", "TestModuleSS.dll");
+    }
+
+	public static int Main () {
+		SetUp ();
+		TypeBuilder tb = module.DefineType ("Gen", TypeAttributes.Public);
+		Type[] args = tb.DefineGenericParameters ("T");
+		Type oi = tb.MakeGenericType (args);
+
+		MethodBuilder mb = tb.DefineMethod ("Test", MethodAttributes.Public | MethodAttributes.Static, oi.MakeArrayType (), new Type [0]);
+	
+		ILGenerator il = mb.GetILGenerator();
+		il.Emit (OpCodes.Ldnull);
+		il.Emit (OpCodes.Ret);
+		tb.CreateType ();
+
+		TypeBuilder main = module.DefineType ("Driver", TypeAttributes.Public);
+		MethodBuilder mb2 = main.DefineMethod ("Test", MethodAttributes.Public | MethodAttributes.Static);
+
+		il = mb2.GetILGenerator();
+		il.Emit (OpCodes.Call, TypeBuilder.GetMethod (tb.MakeGenericType (typeof (int)), mb));
+		il.Emit (OpCodes.Pop);
+		il.Emit (OpCodes.Ret);
+		Type tt = main.CreateType ();
+
+		tt.GetMethod ("Test").Invoke (null, null);
+		//typeof (Driver).GetMethod ("Test").Invoke (null, null);
+		return 0;
+	}
+}