diff options
author | Rodrigo Kumpera <kumpera@gmail.com> | 2009-08-07 23:28:02 +0400 |
---|---|---|
committer | Rodrigo Kumpera <kumpera@gmail.com> | 2009-08-07 23:28:02 +0400 |
commit | e138e70adc81b46f49289ae5a63ba4290f49b8f7 (patch) | |
tree | 9e9f5574d5d63134b23a3a076ba313ba3f57cff9 /mcs/class | |
parent | 8306598e5d2a7c383fc935d7584b928a35c0a6fc (diff) |
2009-08-07 Rodrigo Kumpera <rkumpera@novell.com>
* DynamicMethodTest.cs: Add regression test for bug #529238.
svn path=/trunk/mcs/; revision=139585
Diffstat (limited to 'mcs/class')
-rw-r--r-- | mcs/class/corlib/Test/System.Reflection.Emit/ChangeLog | 4 | ||||
-rw-r--r-- | mcs/class/corlib/Test/System.Reflection.Emit/DynamicMethodTest.cs | 27 |
2 files changed, 30 insertions, 1 deletions
diff --git a/mcs/class/corlib/Test/System.Reflection.Emit/ChangeLog b/mcs/class/corlib/Test/System.Reflection.Emit/ChangeLog index cc043f6eae9..b18719bb067 100644 --- a/mcs/class/corlib/Test/System.Reflection.Emit/ChangeLog +++ b/mcs/class/corlib/Test/System.Reflection.Emit/ChangeLog @@ -1,3 +1,7 @@ +2009-08-07 Rodrigo Kumpera <rkumpera@novell.com> + + * DynamicMethodTest.cs: Add regression test for bug #529238. + 2009-08-06 Rodrigo Kumpera <rkumpera@novell.com> * MethodOnTypeBuilderInstTest.cs: Add tests for diff --git a/mcs/class/corlib/Test/System.Reflection.Emit/DynamicMethodTest.cs b/mcs/class/corlib/Test/System.Reflection.Emit/DynamicMethodTest.cs index cf9f2f84223..b7ed32904c4 100644 --- a/mcs/class/corlib/Test/System.Reflection.Emit/DynamicMethodTest.cs +++ b/mcs/class/corlib/Test/System.Reflection.Emit/DynamicMethodTest.cs @@ -331,7 +331,32 @@ namespace MonoTests.System.Reflection.Emit object[] invokeArgs = { "Hello, World!" }; object objRet = hello.Invoke (null, invokeArgs); Assert.AreEqual (2, objRet); - } + } + + public delegate int IntInvoker(); + + public class Foo<T> { + public virtual int Test () { return 99; } + } + + [Test] + public void ConstrainedPrexixDoesntCrash () //bug #529238 + { + Type foo = typeof (Foo<int>); + + DynamicMethod dm = new DynamicMethod ("Hello", typeof (int), null); + ILGenerator ilgen = dm.GetILGenerator (); + ilgen.DeclareLocal (foo); + ilgen.Emit (OpCodes.Newobj, foo.GetConstructor (new Type [0])); + ilgen.Emit (OpCodes.Stloc_0); + ilgen.Emit (OpCodes.Ldloca_S, 0); + ilgen.Emit (OpCodes.Constrained, foo); + ilgen.Emit (OpCodes.Callvirt, foo.GetMethod ("Test")); + ilgen.Emit (OpCodes.Ret); + + IntInvoker hi = (IntInvoker) dm.CreateDelegate (typeof (IntInvoker)); + Assert.AreEqual (99, hi (), "#1"); + } } } |