Răsfoiți Sursa

Add test files

svn path=/trunk/mcs/; revision=84021
Miguel de Icaza 18 ani în urmă
părinte
comite
ae48cdbece

+ 100 - 0
mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_Add.cs

@@ -0,0 +1,100 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+//
+// Authors:
+//        Federico Di Gregorio <[email protected]>
+
+using System;
+using System.Reflection;
+using System.Linq;
+using System.Linq.Expressions;
+using NUnit.Framework;
+
+namespace MonoTests.System.Linq.Expressions
+{    
+    [TestFixture]
+    public class ExpressionTest_Add
+    {
+        [Test]
+        [ExpectedException (typeof (ArgumentNullException))]
+        public void Arg1Null ()
+        {
+            Expression.Add (null, Expression.Constant (1));
+        }
+
+        [Test]
+        [ExpectedException (typeof (ArgumentNullException))]
+        public void Arg2Null ()
+        {
+            Expression.Add (Expression.Constant (1), null);
+        }
+
+        [Test]
+        [ExpectedException (typeof (InvalidOperationException))]
+        public void ArgTypesDifferent ()
+        {
+            Expression.Add (Expression.Constant (1), Expression.Constant (2.0));
+        }
+
+        [Test]
+        [ExpectedException (typeof (InvalidOperationException))]
+        public void NoOperatorClass ()
+        {
+            Expression.Add (Expression.Constant (new NoOpClass ()), Expression.Constant (new NoOpClass ()));
+        }
+
+        [Test]
+        public void Numeric ()
+        {
+            BinaryExpression expr = Expression.Add (Expression.Constant (1), Expression.Constant (2));
+            Assert.AreEqual (ExpressionType.Add, expr.NodeType, "Add#01");
+            Assert.AreEqual (typeof (int), expr.Type, "Add#02");
+            Assert.IsNull (expr.Method, "Add#03");
+            Assert.AreEqual ("(1 + 2)", expr.ToString(), "Add#04");
+        }
+
+        [Test]
+        public void Nullable ()
+        {
+            int? a = 1;
+            int? b = 2;
+            
+            BinaryExpression expr = Expression.Add (Expression.Constant (a), Expression.Constant (b));
+            Assert.AreEqual (ExpressionType.Add, expr.NodeType, "Add#05");
+            Assert.AreEqual (typeof (int), expr.Type, "Add#06");
+            Assert.IsNull (expr.Method, "Add#07");
+            Assert.AreEqual ("(1 + 2)", expr.ToString(), "Add#08");
+        }
+
+        [Test]
+        public void UserDefinedClass ()
+        {
+            // We can use the simplest version of GetMethod because we already know only one
+            // exists in the very simple class we're using for the tests.
+            MethodInfo mi = typeof (OpClass).GetMethod ("op_Addition");
+            
+            BinaryExpression expr = Expression.Add (Expression.Constant (new OpClass ()), Expression.Constant (new OpClass ()));
+            Assert.AreEqual (ExpressionType.Add, expr.NodeType, "Add#09");
+            Assert.AreEqual (typeof (OpClass), expr.Type, "Add#10");
+            Assert.AreEqual (mi, expr.Method, "Add#11");
+            Assert.AreEqual ("op_Addition", expr.Method.Name, "Add#12");
+            Assert.AreEqual ("(value(MonoTests.System.Linq.Expressions.OpClass) + value(MonoTests.System.Linq.Expressions.OpClass))",
+                expr.ToString(), "Add#13");
+        }
+    }
+}

+ 117 - 0
mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_AddChecked.cs

@@ -0,0 +1,117 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+//
+// Authors:
+//        Federico Di Gregorio <[email protected]>
+
+using System;
+using System.Reflection;
+using System.Linq;
+using System.Linq.Expressions;
+using NUnit.Framework;
+
+namespace MonoTests.System.Linq.Expressions
+{    
+    [TestFixture]
+    public class ExpressionTest_AddChecked
+    {
+        [Test]
+        [ExpectedException (typeof (ArgumentNullException))]
+        public void Arg1Null ()
+        {
+            Expression.AddChecked (null, Expression.Constant(1));
+        }
+
+        [Test]
+        [ExpectedException (typeof (ArgumentNullException))]
+        public void Arg2Null ()
+        {
+            Expression.AddChecked (Expression.Constant (1), null);
+        }
+
+        [Test]
+        [ExpectedException (typeof (InvalidOperationException))]
+        public void ArgTypesDifferent ()
+        {
+            Expression.AndAlso (Expression.Constant (1), Expression.Constant (2.0));
+        }
+
+        [Test]
+        [ExpectedException (typeof (InvalidOperationException))]
+        public void NoOperatorClass ()
+        {
+            Expression.AddChecked (Expression.Constant (new NoOpClass ()), Expression.Constant (new NoOpClass ()));
+        }
+
+        [Test]
+        public void Numeric ()
+        {
+            BinaryExpression expr = Expression.AddChecked (Expression.Constant (1), Expression.Constant (2));
+            Assert.AreEqual (ExpressionType.AddChecked, expr.NodeType, "AddChecked#01");
+            Assert.AreEqual (typeof (int), expr.Type, "AddChecked#02");
+            Assert.IsNull (expr.Method, "AddChecked#03");
+            Assert.AreEqual ("(1 + 2)", expr.ToString(), "AddChecked#15");
+        }
+
+        [Test]
+        public void Nullable ()
+        {
+            int? a = 1;
+            int? b = 2;
+            
+            BinaryExpression expr = Expression.AddChecked (Expression.Constant (a), Expression.Constant (b));
+            Assert.AreEqual (ExpressionType.AddChecked, expr.NodeType, "AddChecked#04");
+            Assert.AreEqual (typeof (int), expr.Type, "AddChecked#05");
+            Assert.IsNull (expr.Method, null, "AddChecked#06");
+            Assert.AreEqual ("(1 + 2)", expr.ToString(), "AddChecked#16");
+        }
+
+        [Test]
+        public void UserDefinedClass ()
+        {
+            // We can use the simplest version of GetMethod because we already know only one
+            // exists in the very simple class we're using for the tests.
+            MethodInfo mi = typeof (OpClass).GetMethod ("op_Addition");
+            
+            BinaryExpression expr = Expression.AddChecked (Expression.Constant (new OpClass ()), Expression.Constant (new OpClass ()));
+            Assert.AreEqual (ExpressionType.AddChecked, expr.NodeType, "AddChecked#07");
+            Assert.AreEqual (typeof (OpClass), expr.Type, "AddChecked#08");
+            Assert.AreEqual (mi, expr.Method, "AddChecked#09");
+            Assert.AreEqual ("op_Addition", expr.Method.Name, "AddChecked#10");
+            Assert.AreEqual ("(value(MonoTests.System.Linq.Expressions.OpClass) + value(MonoTests.System.Linq.Expressions.OpClass))",
+                expr.ToString(), "AddChecked#17");
+        }
+
+        [Test]
+        public void UserDefinedStruct ()
+        {
+            // We can use the simplest version of GetMethod because we already know only one
+            // exists in the very simple class we're using for the tests.
+            MethodInfo mi = typeof (OpStruct).GetMethod ("op_Addition");
+            
+            BinaryExpression expr = Expression.AddChecked (Expression.Constant (new OpStruct ()), Expression.Constant (new OpStruct ()));
+            Assert.AreEqual (ExpressionType.AddChecked, expr.NodeType, "AddChecked#11");
+            Assert.AreEqual (typeof (OpStruct), expr.Type, "AddChecked#12");
+            Assert.AreEqual (mi, expr.Method, "AddChecked#13");
+            Assert.AreEqual ("op_Addition", expr.Method.Name, "AddChecked#14");
+            Assert.AreEqual ("(value(MonoTests.System.Linq.Expressions.OpStruct) + value(MonoTests.System.Linq.Expressions.OpStruct))",
+                expr.ToString(), "AddChecked#18");
+        }
+
+    }
+}

+ 104 - 0
mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_And.cs

@@ -0,0 +1,104 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+//
+// Authors:
+//        Federico Di Gregorio <[email protected]>
+
+using System;
+using System.Reflection;
+using System.Linq;
+using System.Linq.Expressions;
+using NUnit.Framework;
+
+namespace MonoTests.System.Linq.Expressions
+{    
+    [TestFixture]
+    public class ExpressionTest_And
+    {
+        [Test]
+        [ExpectedException (typeof (ArgumentNullException))]
+        public void Arg1Null ()
+        {
+            Expression.And (null, Expression.Constant (1));
+        }
+
+        [Test]
+        [ExpectedException (typeof (ArgumentNullException))]
+        public void Arg2Null ()
+        {
+            Expression.And (Expression.Constant (1), null);
+        }
+
+        [Test]
+        [ExpectedException (typeof (InvalidOperationException))]
+        public void NoOperatorClass ()
+        {
+            Expression.And (Expression.Constant (new NoOpClass ()), Expression.Constant (new NoOpClass ()));
+        }
+
+        [Test]
+        [ExpectedException (typeof (InvalidOperationException))]
+        public void ArgTypesDifferent ()
+        {
+            Expression.AndAlso (Expression.Constant (1), Expression.Constant (true));
+        }
+
+        [Test]
+        [ExpectedException (typeof (InvalidOperationException))]
+        public void Double ()
+        {
+            Expression.And (Expression.Constant (1.0), Expression.Constant (2.0));
+        }
+
+        [Test]
+        public void Integer ()
+        {
+            BinaryExpression expr = Expression.And (Expression.Constant (1), Expression.Constant (2));
+            Assert.AreEqual (ExpressionType.And, expr.NodeType, "And#01");
+            Assert.AreEqual (typeof (int), expr.Type, "And#02");
+            Assert.IsNull (expr.Method, "And#03");
+            Assert.AreEqual ("(1 & 2)", expr.ToString(), "And#04");
+        }
+
+        [Test]
+        public void Boolean ()
+        {
+            BinaryExpression expr = Expression.And (Expression.Constant (true), Expression.Constant (false));
+            Assert.AreEqual (ExpressionType.And, expr.NodeType, "And#05");
+            Assert.AreEqual (typeof (bool), expr.Type, "And#06");
+            Assert.IsNull (expr.Method, "And#07");
+            Assert.AreEqual ("(True And False)", expr.ToString(), "And#08");
+        }
+
+        [Test]
+        public void UserDefinedClass ()
+        {
+            // We can use the simplest version of GetMethod because we already know only one
+            // exists in the very simple class we're using for the tests.
+            MethodInfo mi = typeof (OpClass).GetMethod ("op_BitwiseAnd");
+            
+            BinaryExpression expr = Expression.And (Expression.Constant (new OpClass ()), Expression.Constant (new OpClass ()));
+            Assert.AreEqual (ExpressionType.And, expr.NodeType, "And#09");
+            Assert.AreEqual (typeof (OpClass), expr.Type, "And#10");
+            Assert.AreEqual (mi, expr.Method, "And#11");
+            Assert.AreEqual ("op_BitwiseAnd", expr.Method.Name, "And#12");
+            Assert.AreEqual ("(value(MonoTests.System.Linq.Expressions.OpClass) & value(MonoTests.System.Linq.Expressions.OpClass))",
+                expr.ToString(), "And#13");
+        }
+    }
+}

+ 101 - 0
mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_AndAlso.cs

@@ -0,0 +1,101 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+//
+// Authors:
+//        Federico Di Gregorio <[email protected]>
+
+using System;
+using System.Reflection;
+using System.Linq;
+using System.Linq.Expressions;
+using NUnit.Framework;
+
+namespace MonoTests.System.Linq.Expressions
+{    
+    [TestFixture]
+    public class ExpressionTest_AndAlso
+    {
+        [Test]
+        [ExpectedException (typeof (ArgumentNullException))]
+        public void Arg1Null ()
+        {
+            Expression.AndAlso (null, Expression.Constant (1));
+        }
+
+        [Test]
+        [ExpectedException (typeof (ArgumentNullException))]
+        public void Arg2Null ()
+        {
+            Expression.AndAlso (Expression.Constant (1), null);
+        }
+
+        [Test]
+        [ExpectedException (typeof (InvalidOperationException))]
+        public void NoOperatorClass ()
+        {
+            Expression.AndAlso (Expression.Constant (new NoOpClass ()), Expression.Constant (new NoOpClass ()));
+        }
+
+        [Test]
+        [ExpectedException (typeof (InvalidOperationException))]
+        public void Double ()
+        {
+            Expression.AndAlso (Expression.Constant (1.0), Expression.Constant (2.0));
+        }
+
+        [Test]
+        [ExpectedException (typeof (InvalidOperationException))]
+        public void Integer ()
+        {
+            Expression.AndAlso (Expression.Constant (1), Expression.Constant (2));
+        }
+
+        [Test]
+        [ExpectedException (typeof (InvalidOperationException))]
+        public void MismatchedTypes ()
+        {
+            Expression.AndAlso (Expression.Constant (new OpClass ()), Expression.Constant (true));
+        }
+
+        [Test]
+        public void Boolean ()
+        {
+            BinaryExpression expr = Expression.AndAlso (Expression.Constant (true), Expression.Constant (false));
+            Assert.AreEqual (ExpressionType.AndAlso, expr.NodeType, "AndAlso#01");
+            Assert.AreEqual (typeof (bool), expr.Type, "AndAlso#02");
+            Assert.IsNull (expr.Method, "AndAlso#03");
+            Assert.AreEqual ("(True && False)", expr.ToString(), "AndAlso#04");
+        }
+
+        [Test]
+        public void UserDefinedClass ()
+        {
+            // We can use the simplest version of GetMethod because we already know only one
+            // exists in the very simple class we're using for the tests.
+            MethodInfo mi = typeof (OpClass).GetMethod ("op_BitwiseAnd");
+
+            BinaryExpression expr = Expression.AndAlso (Expression.Constant (new OpClass ()), Expression.Constant (new OpClass ()));
+            Assert.AreEqual (ExpressionType.AndAlso, expr.NodeType, "AndAlso#05");
+            Assert.AreEqual (typeof (OpClass), expr.Type, "AndAlso#06");
+            Assert.AreEqual (mi, expr.Method, "AndAlso#07");
+            Assert.AreEqual ("op_BitwiseAnd", expr.Method.Name, "AndAlso#08");
+            Assert.AreEqual ("(value(MonoTests.System.Linq.Expressions.OpClass) && value(MonoTests.System.Linq.Expressions.OpClass))",
+                expr.ToString(), "AndAlso#09");
+        }
+    }
+}

+ 127 - 0
mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_Constant.cs

@@ -0,0 +1,127 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+//
+// Authors:
+//        Federico Di Gregorio <[email protected]>
+
+using System;
+using System.Linq;
+using System.Linq.Expressions;
+using NUnit.Framework;
+
+namespace MonoTests.System.Linq.Expressions
+{
+    [TestFixture]
+    public class ExpressionTest_Constant
+    {
+        [Test]
+        [ExpectedException (typeof (ArgumentException))]
+        public void Arg2NotNullable ()
+        {
+            Expression.Constant(null, typeof(int));
+        }
+
+        [Test]
+        [ExpectedException (typeof (ArgumentNullException))]
+        public void Arg2Null ()
+        {
+            Expression.Constant (1, null);
+        }
+
+        [Test]
+        public void NullValue ()
+        {
+            ConstantExpression expr = Expression.Constant (null);
+            Assert.AreEqual (ExpressionType.Constant, expr.NodeType, "Constant#01");
+            Assert.IsNull (expr.Value, "Constant#02");
+            Assert.AreEqual (typeof (object), expr.Type, "Constant#03");
+            Assert.AreEqual ("null", expr.ToString(), "Constant#04");
+        }
+
+        [Test]
+        public void NullableValue1 ()
+        {
+            ConstantExpression expr = Expression.Constant (null, typeof(int?));
+            Assert.AreEqual (ExpressionType.Constant, expr.NodeType, "Constant#05");
+            Assert.IsNull (expr.Value, "Constant#06");
+            Assert.AreEqual (typeof (int?), expr.Type, "Constant#07");
+            Assert.AreEqual ("null", expr.ToString(), "Constant#08");
+        }
+
+        [Test]
+        public void NullableValue2 ()
+        {
+            ConstantExpression expr = Expression.Constant (1, typeof (int?));
+            Assert.AreEqual (ExpressionType.Constant, expr.NodeType, "Constant#09");
+            Assert.AreEqual (1, expr.Value, "Constant#10");
+            Assert.AreEqual (typeof (int?), expr.Type, "Constant#11");
+            Assert.AreEqual ("1", expr.ToString(), "Constant#12");
+        }
+
+        [Test]
+        public void NullableValue3 ()
+        {
+            ConstantExpression expr = Expression.Constant ((int?)1);
+            Assert.AreEqual (ExpressionType.Constant, expr.NodeType, "Constant#13");
+            Assert.AreEqual (1, expr.Value, "Constant#14");
+            Assert.AreEqual (typeof (int), expr.Type, "Constant#15");
+            Assert.AreEqual ("1", expr.ToString(), "Constant#16");
+        }
+
+        [Test]
+        public void IntegerValue ()
+        {
+            ConstantExpression expr = Expression.Constant (0);
+            Assert.AreEqual (ExpressionType.Constant, expr.NodeType, "Constant#17");
+            Assert.AreEqual (0, expr.Value, "Constant#18");
+            Assert.AreEqual (typeof (int), expr.Type, "Constant#19");
+            Assert.AreEqual ("0", expr.ToString(), "Constant#20");
+        }
+
+        [Test]
+        public void StringValue ()
+        {
+            ConstantExpression expr = Expression.Constant ("a string");
+            Assert.AreEqual (ExpressionType.Constant, expr.NodeType, "Constant#21");
+            Assert.AreEqual ("a string", expr.Value, "Constant#22");
+            Assert.AreEqual (typeof (string), expr.Type, "Constant#23");
+            Assert.AreEqual ("\"a string\"", expr.ToString(), "Constant#24");
+        }
+
+        [Test]
+        public void DateTimeValue ()
+        {
+            ConstantExpression expr = Expression.Constant (new DateTime(1971, 10, 19));
+            Assert.AreEqual (ExpressionType.Constant, expr.NodeType, "Constant#25");
+            Assert.AreEqual (new DateTime(1971, 10, 19), expr.Value, "Constant#26");
+            Assert.AreEqual (typeof (DateTime), expr.Type, "Constant#27");
+            Assert.AreEqual (new DateTime(1971, 10, 19).ToString(), expr.ToString(), "Constant#28");
+        }
+
+        [Test]
+        public void UserClassValue ()
+        {
+            OpClass oc = new OpClass ();
+            ConstantExpression expr = Expression.Constant (oc);
+            Assert.AreEqual (ExpressionType.Constant, expr.NodeType, "Constant#29");
+            Assert.AreEqual (oc, expr.Value, "Constant#30");
+            Assert.AreEqual (typeof (OpClass), expr.Type, "Constant#31");
+            Assert.AreEqual ("value(MonoTests.System.Linq.Expressions.OpClass)", expr.ToString(), "Constant#32");
+        }
+    }
+}

+ 70 - 0
mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_Utils.cs

@@ -0,0 +1,70 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+//
+// Authors:
+//        Federico Di Gregorio <[email protected]>
+
+using System;
+using System.Reflection;
+using System.Linq;
+using System.Linq.Expressions;
+using NUnit.Framework;
+
+namespace MonoTests.System.Linq.Expressions
+{ 
+    public class OpClass
+    {
+        public static OpClass operator + (OpClass a, OpClass b)
+        {
+            return a;
+        }
+
+        public static OpClass operator & (OpClass a, OpClass b)
+        {
+            return a;
+        }
+        
+        public static bool operator true (OpClass a)
+        {
+            return false;
+        }
+
+        public static bool operator false (OpClass a)
+        {
+            return false;
+        }
+    }
+
+    public class NoOpClass
+    {
+        // No user-defined operators here (we use this class to test for exceptions.)
+    }
+
+    public struct OpStruct
+    {
+        public static OpStruct operator + (OpStruct a, OpStruct b)
+        {
+            return a;
+        }
+
+        public static OpStruct operator & (OpStruct a, OpStruct b)
+        {
+            return a;
+        }
+    }
+}