Permalink
Browse files

2007-11-12 Rodrigo Kumpera <rkumpera@novell.com>

	* bug-322722_patch_bx.2.cs : Added test for bug #322722.

	* bug-322722_dyn_method_throw.2.cs: Same.

	* Makefile.am: Added the two tests for bug #322722.


svn path=/trunk/mono/; revision=89488
  • Loading branch information...
1 parent b73ea30 commit 31427b04e13c22d6e4efd3dfd7ed7ab34a9cb981 @kumpera kumpera committed Nov 12, 2007
View
@@ -1,3 +1,11 @@
+2007-11-12 Rodrigo Kumpera <rkumpera@novell.com>
+
+ * bug-322722_patch_bx.2.cs : Added test for bug #322722.
+
+ * bug-322722_dyn_method_throw.2.cs: Same.
+
+ * Makefile.am: Added the two tests for bug #322722.
+
2007-11-07 Zoltan Varga <vargaz@gmail.com>
* Makefile.am: Removed bug-318677 since the corresponding patch was reverted.
View
@@ -313,7 +313,9 @@ TEST_CS2_SRC = \
generic_type_definition.2.cs \
bug-333798.2.cs \
bug-333798-tb.2.cs \
- bug-335131.2.cs
+ bug-335131.2.cs \
+ bug-322722_patch_bx.2.cs \
+ bug-322722_dyn_method_throw.2.cs
TEST_IL2_SRC = find-method.2.il \
bug-79215.2.il \
@@ -0,0 +1,29 @@
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+
+public class MyException : Exception {
+
+}
+
+class Driver {
+ public static int Main()
+ {
+ DynamicMethod method_builder = new DynamicMethod ("ThrowException" , typeof (void), new Type[0], typeof (Driver));
+ ILGenerator ilg = method_builder.GetILGenerator ();
+
+
+ ilg.Emit (OpCodes.Newobj, typeof (MyException).GetConstructor (new Type[0]));
+ ilg.Emit (OpCodes.Throw);
+
+ try {
+ method_builder.Invoke (null, null);
+ return 2;
+ } catch (TargetInvocationException tie) {
+ if(! (tie.InnerException is MyException))
+ return 3;
+ }
+
+ return 0;
+ }
+}
@@ -0,0 +1,30 @@
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+
+
+class Driver {
+ public void AvoidInlining()
+ {
+ }
+
+ public int Foo()
+ {
+ AvoidInlining();
+ return -99;
+ }
+
+ public static int Main()
+ {
+
+ DynamicMethod method_builder = new DynamicMethod ("WriteHello" , typeof (int), new Type[] {typeof (Driver)}, typeof (Driver));
+ ILGenerator ilg = method_builder.GetILGenerator ();
+
+ ilg.Emit (OpCodes.Ldarg_0);
+ ilg.Emit (OpCodes.Call, typeof (Driver).GetMethod ("Foo"));
+ ilg.Emit (OpCodes.Ret);
+
+ int res = (int) method_builder.Invoke (null, new object[] {new Driver()});
+ return res == -99 ? 0 : 1;
+ }
+}

0 comments on commit 31427b0

Please sign in to comment.