[test] DynamicMethod isn't available on iOS.
[mono.git] / mcs / class / System.Core / Test / System.Linq.Expressions / ExpressionTest_Call.cs
index 976b50109d0c0b4deba28eb9ff0d7e29016a876b..03060f93c5ba069b0ea57273ad78ed73669db90e 100644 (file)
@@ -29,6 +29,7 @@
 
 using System;
 using System.Reflection;
+using System.Reflection.Emit;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq.Expressions;
@@ -223,7 +224,6 @@ namespace MonoTests.System.Linq.Expressions {
                }
 
                [Test]
-               [Category ("NotWorkingInterpreter")]
                public void CallMethodOnStruct ()
                {
                        var param = Expression.Parameter (typeof (EineStrukt), "s");
@@ -271,7 +271,6 @@ namespace MonoTests.System.Linq.Expressions {
                }
 
                [Test]
-               [Category ("NotWorkingInterpreter")]
                public void CallStaticMethodWithRefParameter ()
                {
                        var p = Expression.Parameter (typeof (int), "i");
@@ -283,7 +282,6 @@ namespace MonoTests.System.Linq.Expressions {
                }
 
                [Test]
-               [Category ("NotWorkingInterpreter")]
                public void CallStaticMethodWithRefParameterAndOtherParameter ()
                {
                        var i = Expression.Parameter (typeof (int), "i");
@@ -295,6 +293,38 @@ namespace MonoTests.System.Linq.Expressions {
                        Assert.AreEqual ("foo42", lamda (42, "foo"));
                }
 
+#if !MONOTOUCH
+               [Test]
+               public void CallDynamicMethod_ToString ()
+               {
+                       // Regression test for #49686
+                       var m = new DynamicMethod ("intIntId", typeof (int), new Type [] { typeof (int) });
+                       var ilg = m.GetILGenerator ();
+                       ilg.Emit (OpCodes.Ldarg_0);
+                       ilg.Emit (OpCodes.Ret);
+
+                       var i = Expression.Parameter (typeof (int), "i");
+                       var e = Expression.Call (m, i);
+
+                       Assert.IsNotNull (e.ToString ());
+               }
+
+               [Test]
+               public void CallDynamicMethod_CompileInvoke ()
+               {
+                       var m = new DynamicMethod ("intIntId", typeof (int), new Type [] { typeof (int) });
+                       var ilg = m.GetILGenerator ();
+                       ilg.Emit (OpCodes.Ldarg_0);
+                       ilg.Emit (OpCodes.Ret);
+
+                       var i = Expression.Parameter (typeof (int), "i");
+                       var e = Expression.Call (m, i);
+
+                       var lambda = Expression.Lambda<Func<int, int>> (e, i).Compile ();
+                       Assert.AreEqual (42, lambda (42));
+               }
+#endif
+
                public static int Bang (Expression i)
                {
                        return (int) (i as ConstantExpression).Value;
@@ -308,7 +338,6 @@ namespace MonoTests.System.Linq.Expressions {
                }
 
                [Test]
-               [Category ("NotWorkingInterpreter")]
                public void Connect282729 ()
                {
                        // test from https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=282729
@@ -335,8 +364,6 @@ namespace MonoTests.System.Linq.Expressions {
                }
 
                [Test]
-               [Category ("NotWorking")]
-               [Category ("NotWorkingInterpreter")]
                public void Connect290278 ()
                {
                        // test from https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=290278
@@ -359,7 +386,6 @@ namespace MonoTests.System.Linq.Expressions {
                }
 
                [Test]
-               [Category ("NotWorkingInterpreter")]
                public void Connect297597 ()
                {
                        // test from https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=297597
@@ -377,6 +403,7 @@ namespace MonoTests.System.Linq.Expressions {
 
                [Test]
                [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=319190
+               [Category ("NotWorkingInterpreter")]
                public void Connect319190 ()
                {
                        var lambda = Expression.Lambda<Func<bool>> (
@@ -482,7 +509,6 @@ namespace MonoTests.System.Linq.Expressions {
                }
 
                [Test]
-               [Category ("NotWorkingInterpreter")]
                public void CallNullableGetValueOrDefault () // #568989
                {
                        var value = Expression.Parameter (typeof (int?), "value");