Assert.AreEqual (ExpressionType.Equal, expr.NodeType);
Assert.AreEqual (typeof (bool), expr.Type);
Assert.IsNull (expr.Method);
-#if !NET_4_0
- Assert.AreEqual ("(1 = 2)", expr.ToString ());
-#endif
+ }
+
+ [Test]
+ public void PrimitiveNonNumeric ()
+ {
+ BinaryExpression expr = Expression.Equal (Expression.Constant ('a'), Expression.Constant ('b'));
+ Assert.AreEqual (ExpressionType.Equal, expr.NodeType);
+ Assert.AreEqual (typeof (bool), expr.Type);
+ Assert.IsNull (expr.Method);
+
+ var eq = Expression.Lambda<Func<bool>> (expr).Compile ();
+ Assert.IsFalse (eq ());
+ }
+
+ [Test]
+ public void StringWithNull ()
+ {
+ BinaryExpression expr = Expression.Equal (Expression.Constant ("a"), Expression.Constant (null));
+ Assert.AreEqual (ExpressionType.Equal, expr.NodeType);
+ Assert.AreEqual (typeof (bool), expr.Type);
+ Assert.IsNull (expr.Method);
+
+ var eq = Expression.Lambda<Func<bool>> (expr).Compile ();
+ Assert.IsFalse (eq ());
}
[Test]
Assert.AreEqual (true, expr.IsLifted);
Assert.AreEqual (false, expr.IsLiftedToNull);
Assert.IsNull (expr.Method);
-#if !NET_4_0
- Assert.AreEqual ("(1 = 2)", expr.ToString ());
-#endif
}
[Test]
Assert.AreEqual (true, expr.IsLifted);
Assert.AreEqual (true, expr.IsLiftedToNull);
Assert.IsNull (expr.Method);
-#if !NET_4_0
- Assert.AreEqual ("(1 = 2)", expr.ToString ());
-#endif
}
[Test]
Assert.AreEqual (typeof (bool), expr.Type);
Assert.AreEqual (mi, expr.Method);
Assert.AreEqual ("op_Equality", expr.Method.Name);
-#if !NET_4_0
- Assert.AreEqual ("(value(MonoTests.System.Linq.Expressions.OpClass) = value(MonoTests.System.Linq.Expressions.OpClass))", expr.ToString ());
-#endif
}
[Test]
}
[Test]
+ [Category ("NotWorkingInterpreter")]
public void UserDefinedEqualLifted ()
{
var l = Expression.Parameter (typeof (Slot?), "l");
}
[Test]
+ [Category ("NotWorkingInterpreter")]
public void UserDefinedEqualLiftedToNull ()
{
var l = Expression.Parameter (typeof (Slot?), "l");
Assert.AreEqual (false, eq (Foo.Bar, null));
Assert.AreEqual (true, eq (null, null));
}
+
+ [Test]
+ [Category ("NotWorkingInterpreter")]
+ public void NullableNullEqual ()
+ {
+ var param = Expression.Parameter (typeof (DateTime?), "x");
+
+ var node = Expression.Equal (param, Expression.Constant (null));
+
+ Assert.IsTrue (node.IsLifted);
+ Assert.IsFalse (node.IsLiftedToNull);
+ Assert.AreEqual (typeof (bool), node.Type);
+ Assert.IsNull (node.Method);
+
+ var eq = Expression.Lambda<Func<DateTime?, bool>> (node, new [] { param }).Compile ();
+
+ Assert.AreEqual (true, eq (null));
+ Assert.AreEqual (false, eq (DateTime.Now));
+ }
}
}