2007-11-12 Rodrigo Kumpera <rkumpera@novell.com>
authorRodrigo Kumpera <kumpera@gmail.com>
Mon, 12 Nov 2007 19:51:47 +0000 (19:51 -0000)
committerRodrigo Kumpera <kumpera@gmail.com>
Mon, 12 Nov 2007 19:51:47 +0000 (19:51 -0000)
* 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

mono/tests/ChangeLog
mono/tests/Makefile.am
mono/tests/bug-322722_dyn_method_throw.2.cs [new file with mode: 0644]
mono/tests/bug-322722_patch_bx.2.cs [new file with mode: 0644]

index aa4c799cab9cc992411437f502df3aeec13ca913..1dc4467d5621b0e87565c5f6863ea07b61b4de22 100644 (file)
@@ -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.
index d3f607742903b1e4db0d728cc80b8e5647a8d75b..1100e9d9b4cc3a2e202e8328a37fd62a731f223c 100644 (file)
@@ -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  \
diff --git a/mono/tests/bug-322722_dyn_method_throw.2.cs b/mono/tests/bug-322722_dyn_method_throw.2.cs
new file mode 100644 (file)
index 0000000..c9e0cf3
--- /dev/null
@@ -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;
+       }
+}
diff --git a/mono/tests/bug-322722_patch_bx.2.cs b/mono/tests/bug-322722_patch_bx.2.cs
new file mode 100644 (file)
index 0000000..510affa
--- /dev/null
@@ -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;
+       }
+}