Author: jbevain
Date: 2008-01-30 15:05:10 -0500 (Wed, 30 Jan 2008)
New Revision: 94414

Modified:
   trunk/mcs/class/System.Core/Test/System.Linq.Expressions/ChangeLog
   
trunk/mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_CallWithExpression.cs
Log:
2008-01-30  Jb Evain  <[EMAIL PROTECTED]>

        * ExpressionTest_CallWithExpression.cs: add tests for very simple calls.



Modified: trunk/mcs/class/System.Core/Test/System.Linq.Expressions/ChangeLog
===================================================================
--- trunk/mcs/class/System.Core/Test/System.Linq.Expressions/ChangeLog  
2008-01-30 20:04:24 UTC (rev 94413)
+++ trunk/mcs/class/System.Core/Test/System.Linq.Expressions/ChangeLog  
2008-01-30 20:05:10 UTC (rev 94414)
@@ -1,5 +1,9 @@
 2008-01-30  Jb Evain  <[EMAIL PROTECTED]>
 
+       * ExpressionTest_CallWithExpression.cs: add tests for very simple calls.
+
+2008-01-30  Jb Evain  <[EMAIL PROTECTED]>
+
        * ExpressionTest_New.cs: add tests for emitting new reference types.
 
 2008-01-27  Jb Evain  <[EMAIL PROTECTED]>

Modified: 
trunk/mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_CallWithExpression.cs
===================================================================
--- 
trunk/mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_CallWithExpression.cs
       2008-01-30 20:04:24 UTC (rev 94413)
+++ 
trunk/mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_CallWithExpression.cs
       2008-01-30 20:05:10 UTC (rev 94414)
@@ -99,5 +99,37 @@
                        var call = Expression.Call (null, typeof 
(string).GetMethod ("IsNullOrEmpty"), Expression.Constant(""));
                        Assert.AreEqual ("IsNullOrEmpty(\"\")", call.ToString 
());
                }
+
+               public static object Identity (object o)
+               {
+                       return o;
+               }
+
+               [Test]
+               public void CompileSimpleStaticCall ()
+               {
+                       var p = Expression.Parameter (typeof (object), "o");
+                       var lambda = Expression.Lambda<Func<object, object>> 
(Expression.Call (GetType ().GetMethod ("Identity"), p), p);
+
+                       var i = lambda.Compile ();
+
+                       Assert.AreEqual (2, i (2));
+                       Assert.AreEqual ("Foo", i ("Foo"));
+               }
+
+               [Test]
+               public void CompileSimpleInstanceCall ()
+               {
+                       var p = Expression.Parameter (typeof (string), "p");
+                       var lambda = Expression.Lambda<Func<string, string>> (
+                               Expression.Call (
+                                       p, typeof (string).GetMethod 
("ToString", Type.EmptyTypes)),
+                               p);
+
+                       var ts = lambda.Compile ();
+
+                       Assert.AreEqual ("foo", ts ("foo"));
+                       Assert.AreEqual ("bar", ts ("bar"));
+               }
        }
 }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to