Add test for bug 665788
authorJb Evain <jbevain@gmail.com>
Thu, 20 Jan 2011 15:36:37 +0000 (16:36 +0100)
committerJb Evain <jbevain@gmail.com>
Thu, 20 Jan 2011 15:36:37 +0000 (16:36 +0100)
mcs/class/corlib/Test/System.Reflection.Emit/DynamicMethodTest.cs

index 5be52cf11c55766d7e72e59ce1e45d004de815cb..0a2e4123cd07fb18e86c5468eade49c25756061f 100644 (file)
@@ -400,6 +400,20 @@ namespace MonoTests.System.Reflection.Emit
                        Assert.IsTrue (function ());
                }
 
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void GetMethodBody ()
+               {
+                       var method = new DynamicMethod ("method", typeof (object), new Type [] { typeof (object) });
+
+                       var il = method.GetILGenerator ();
+                       il.Emit (OpCodes.Ldarg_0);
+                       il.Emit (OpCodes.Ret);
+
+                       var f = (Func<object, object>) method.CreateDelegate (typeof (Func<object, object>));
+                       f.Method.GetMethodBody ();
+               }
+
        public delegate object RetObj();
                [Test] //#640702
                public void GetCurrentMethodWorksWithDynamicMethods ()