/IronPython_Main/Runtime/Tests/ETScenariosCSLinq/CSLinq/ExpressionTreeNodes/Not.cs
C# | 13447 lines | 11483 code | 1922 blank | 42 comment | 4914 complexity | 666008fde201bf2127369f0fca935e49 MD5 | raw file
Possible License(s): GPL-2.0, MPL-2.0-no-copyleft-exception, CPL-1.0, CC-BY-SA-3.0, BSD-3-Clause, ISC, AGPL-3.0, LGPL-2.1, Apache-2.0
Large files files are truncated, but you can click here to view the full file
- #if !CLR2
- using System.Linq.Expressions;
- #else
- using Microsoft.Scripting.Ast;
- using Microsoft.Scripting.Utils;
- #endif
-
- using System.Reflection;
- using System.Collections;
- using System.Text;
- using System.Collections.Generic;
- using System;
- namespace ExpressionTreeNodes
- {
-
-
- //-------- Scenario 782
- namespace Scenario782
- {
-
- namespace Not
- {
- public class Test
- {
- // expression = null
- public static int Test1()
- {
- ConstantExpression ce = Expression.Constant(10);
-
- try
- {
- ce = null;
- UnaryExpression result = Expression.Not(ce);
- return 1;
- }
- catch (ArgumentNullException ane)
- {
- if (ane.CompareParamName("expression")) return 0;
- return 1;
- }
- }
-
-
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "Not1__", new string[] { "positive", "cslinq", "FullTrustOnly", "Pri1" })]
- public static Expression Not1__()
- {
- if (Main() != 0)
- {
- throw new Exception();
- }
- else
- {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- return Test1();
- }
- }
- }
-
-
-
- public static class Extension
- {
- public static bool CompareParamName(this ArgumentException ex, string expected)
- {
- #if SILVERLIGHT
- #if SLRESOURCES
- return ex.Message.Substring(ex.Message.LastIndexOf(": ") + 2) == expected;
- #else
- return true;
- #endif
- #else
- return ex.ParamName == expected;
- #endif
- }
-
- public static bool CompareParamName(this ArgumentNullException ex, string expected)
- {
- #if SILVERLIGHT
- #if SLRESOURCES
- return ex.Message.Substring(ex.Message.LastIndexOf(": ") + 2) == expected;
- #else
- return true;
- #endif
- #else
- return ex.ParamName == expected;
- #endif
- }
- }
-
- public static class Verification
- {
- public static int VerifyConstParms(ConstantExpression result, ExpressionType et, Type type, object val, string str)
- {
- if (!(result.NodeType == et))
- {
- Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
- return 1;
- }
- if (!(result.Type == type))
- {
- Console.WriteLine("Unexpected result type: " + result.Type.ToString());
- return 1;
- }
- if (val == null)
- {
- if (result.Value != null) return 1;
- }
- else
- {
- if (!(result.Value.Equals(val))) return 1;
- }
- if (!(result.ToString() == str)) return 1;
- return 0;
- }
-
- public static int VerifyUnaryParms(UnaryExpression result, ExpressionType et, Type type, Expression operand, string str, MethodInfo mi, bool islifted, bool isliftedtonull)
- {
- if (!(result.NodeType == et))
- {
- Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
- return 1;
- }
- if (!(result.Type == type))
- {
- Console.WriteLine("Unexpected result type: " + result.Type.ToString());
- return 1;
- }
- if (operand == null)
- {
- if (result.Operand != null) return 1;
- }
- else
- {
- if (!(result.Operand.Equals(operand))) return 1;
- }
- if (!(result.ToString() == str))
- {
- Console.WriteLine("Expected: " + str + " Actual: " + result.ToString());
- return 1;
- }
-
- if (result.Method != mi) return 1;
- if (result.IsLifted != islifted) return 1;
- if (result.IsLiftedToNull != isliftedtonull) return 1;
-
- return 0;
- }
-
- public static int VerifyBinaryParms(BinaryExpression result, ExpressionType et, Type type, Expression left, Expression right, string str, MethodInfo mi, bool islifted, bool isliftedtonull)
- {
- if (!(result.NodeType == et))
- {
- Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
- return 1;
- }
- if (!(result.Type == type))
- {
- Console.WriteLine("Unexpected result type: " + result.Type.ToString());
- return 1;
- }
-
- if (left == null)
- {
- if (result.Left != null)
- {
- Console.WriteLine("left was null");
- return 1;
- }
- }
- else
- {
- if (!(result.Left.Equals(left)))
- {
- Console.WriteLine("left was different");
- return 1;
- }
- }
-
- if (right == null)
- {
- if (result.Right != null) return 1;
- }
- else
- {
- if (!(result.Right.Equals(right))) return 1;
- }
-
- if (!(result.ToString() == str))
- {
- Console.WriteLine("Expected: " + str + " Actual: " + result.ToString());
- return 1;
- }
-
- if (result.Method != mi) return 1;
- if (result.IsLifted != islifted) return 1;
- if (result.IsLiftedToNull != isliftedtonull) return 1;
-
- if (result.Conversion != null) return 1;
-
- return 0;
- }
-
- public static int VerifyBinaryParms(BinaryExpression result, ExpressionType et, Type type, Expression left, Expression right, string str, MethodInfo mi, LambdaExpression conv_expr, bool islifted, bool isliftedtonull)
- {
- if (!(result.NodeType == et))
- {
- Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
- return 1;
- }
- if (!(result.Type == type))
- {
- Console.WriteLine("Unexpected result type: " + result.Type.ToString());
- return 1;
- }
-
- if (left == null)
- {
- if (result.Left != null) return 1;
- }
- else
- {
- if (!(result.Left.Equals(left))) return 1;
- }
-
- if (right == null)
- {
- if (result.Right != null) return 1;
- }
- else
- {
- if (!(result.Right.Equals(right))) return 1;
- }
-
- if (!(result.ToString() == str)) return 1;
-
- if (result.Method != mi) return 1;
- if (result.IsLifted != islifted) return 1;
- if (result.IsLiftedToNull != isliftedtonull) return 1;
-
- if (result.Conversion.ToString() != conv_expr.ToString()) return 1;
-
- return 0;
- }
-
- public static int VerifyMethodCallParms(MethodCallExpression result, ExpressionType et, Type type, MethodInfo method, Expression obj, string str, params Expression[] arguments)
- {
- if (!(result.NodeType == et))
- {
- Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
- return 1;
- }
- if (!(result.Type == type))
- {
- Console.WriteLine("Unexpected result type: " + result.Type.ToString());
- return 1;
- }
-
- if (!(result.Method == method)) return 1;
-
- if (obj == null)
- {
- if (result.Object != null)
- {
- Console.WriteLine("Expected object to be null.");
- return 1;
- }
- }
- else
- {
- if (!(result.Object.Equals(obj)))
- {
- Console.WriteLine("Object on which call is made is different from the result.");
- return 1;
- }
- }
-
- if (!(result.ToString() == str))
- {
- Console.WriteLine("Expected: " + str + " Actual: " + result.ToString());
- return 1;
- }
-
- if (result.Arguments.Count != arguments.Length) return 1;
-
- for (int i = 0; i < arguments.Length; i++)
- {
- if (result.Arguments[i] != arguments[i]) return 1;
- }
-
- return 0;
- }
-
- public static int VerifyTypeBinaryParms(TypeBinaryExpression result, ExpressionType et, Type type, Expression expr, Type typeop, string str)
- {
- if (!(result.NodeType == et))
- {
- Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
- return 1;
- }
- if (!(result.Type == type))
- {
- Console.WriteLine("Unexpected result type: " + result.Type.ToString());
- return 1;
- }
-
- if (expr == null)
- {
- Console.WriteLine("expr was null.");
- if (result.Expression != null) return 1;
- }
- else
- {
- if (!(result.Expression.Equals(expr)))
- {
- return 1;
- }
- }
-
- if (!(result.TypeOperand == typeop)) return 1;
-
- if (!(result.ToString() == str))
- {
- Console.WriteLine("Expected: " + str + " Actual: " + result.ToString());
- return 1;
- }
-
- return 0;
- }
-
- public static int VerifyConditionalParms(ConditionalExpression result, ExpressionType et, Type type, Expression test, Expression ifTrue, Expression ifFalse, string str)
- {
- if (!(result.NodeType == et))
- {
- Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
- return 1;
- }
- if (!(result.Type == type))
- {
- Console.WriteLine("Unexpected result type: " + result.Type.ToString());
- return 1;
- }
-
- if (test == null)
- {
- if (result.Test != null) return 1;
- }
- else
- {
- if (!(result.Test.Equals(test))) return 1;
- }
-
- if (ifTrue == null)
- {
- if (result.IfTrue != null) return 1;
- }
- else
- {
- if (!(result.IfTrue.Equals(ifTrue))) return 1;
- }
-
- if (ifFalse == null)
- {
- if (result.IfFalse != null) return 1;
- }
- else
- {
- if (!(result.IfFalse.Equals(ifFalse))) return 1;
- }
-
- if (!(result.ToString() == str)) return 1;
-
- return 0;
- }
-
- public static int VerifyMemberParms(MemberExpression result, ExpressionType et, Type type, Expression exp_expr, MemberInfo exp_member, string str)
- {
- if (!(result.NodeType == et))
- {
- Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
- return 1;
- }
- if (!(result.Type == type))
- {
- Console.WriteLine("Unexpected result type: " + result.Type.ToString());
- return 1;
- }
-
- if (exp_expr == null)
- {
- if (result.Expression != null)
- {
- Console.WriteLine("Expression is not null: " + result.Expression.ToString());
- return 1;
- }
- }
- else
- {
- if (!(result.Expression.Equals(exp_expr)))
- {
- Console.WriteLine("Unexpected Expression: " + result.Expression.ToString());
- return 1;
- }
- }
-
- if (!(result.Member == exp_member))
- {
- Console.WriteLine("Unexpected result member: " + result.Member.ToString());
- return 1;
- }
-
- if (!(result.ToString() == str))
- {
- Console.WriteLine("Unexpected result: " + result.ToString() + " - Expected: " + str);
- return 1;
- }
-
- return 0;
- }
-
- public static int VerifyNewParms(NewExpression result, ExpressionType et, Type type, ConstructorInfo constructor, string str, Expression[] arguments, params MemberInfo[] members)
- {
- if (!(result.NodeType == et))
- {
- Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
- return 1;
- }
- if (!(result.Type == type))
- {
- Console.WriteLine("Unexpected result type: " + result.Type.ToString());
- return 1;
- }
-
- if (!(result.Constructor == constructor))
- {
- Console.WriteLine("Unexpected constructor");
- return 1;
- }
-
- if (!(result.ToString() == str))
- {
- Console.WriteLine("Unexpected result: " + result.ToString() + " - Expected: " + str);
- return 1;
- }
-
- if (arguments == null)
- {
- if (result.Arguments.Count != 0)
- {
- Console.WriteLine("More than one argument supplied: " + result.Arguments.Count);
- return 1;
- }
- }
- else
- {
- if (result.Arguments.Count != arguments.Length)
- {
- Console.WriteLine("Different number of arguments obtained: " + result.Arguments.Count);
- return 1;
- }
- for (int i = 0; i < arguments.Length; i++)
- {
- if (result.Arguments[i] != arguments[i])
- {
- Console.WriteLine("Argument " + i.ToString() + " is different than expected: Expected " + arguments[i].ToString() + " and got " + result.Arguments[i].ToString());
- return 1;
- }
- }
- }
-
- if (result.Members == null)
- {
- Console.WriteLine("result.Members was null");
- return 1;
- }
-
- if (members == null)
- {
- if (result.Members.Count != 0)
- {
- Console.WriteLine("Got more than zero members");
- return 1;
- }
- }
- else
- {
- if (result.Members.Count != members.Length)
- {
- Console.WriteLine("Got an unexpected number of members: " + result.Members.Count);
- return 1;
- }
-
- for (int i = 0; i < members.Length; i++)
- {
- if (result.Members[i] != members[i])
- {
- Console.WriteLine("Member " + i.ToString() + " is different than expected: Expected " + members[i].ToString() + " and got " + result.Members[i].ToString());
- return 1;
- }
- }
- }
-
- return 0;
- }
-
- public static int VerifyNewParms(NewExpression result, ExpressionType et, Type type, ConstructorInfo constructor, string str, Expression[] arguments)
- {
- if (!(result.NodeType == et))
- {
- Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
- return 1;
- }
- if (!(result.Type == type))
- {
- Console.WriteLine("Unexpected result type: " + result.Type.ToString());
- return 1;
- }
-
- if (!(result.Constructor == constructor))
- {
- Console.WriteLine("Constructor is different from expected.");
- return 1;
- }
-
- if (!(result.ToString() == str))
- {
- Console.WriteLine("Unexpected result: " + result.ToString() + " - Expected: " + str);
- return 1;
- }
-
- if (result.Arguments.Count != arguments.Length)
- {
- Console.WriteLine("Different number of arguments: " + result.Arguments.Count);
- return 1;
- }
-
- for (int i = 0; i < arguments.Length; i++)
- {
- if (result.Arguments[i] != arguments[i])
- {
- Console.WriteLine("Argument " + i.ToString() + " is different than expected: Expected " + arguments[i].ToString() + " and got " + result.Arguments[i].ToString());
- return 1;
- }
- }
-
- if (result.Members != null)
- {
- Console.WriteLine("result.Members isn't null");
- return 1;
- }
-
- return 0;
- }
-
- public static int VerifyListInitParms(ListInitExpression result, ExpressionType et, Type type, NewExpression newExpression, string str, params ElementInit[] initializers)
- {
- if (!(result.NodeType == et))
- {
- Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
- return 1;
- }
- if (!(result.Type == type))
- {
- Console.WriteLine("Unexpected result type: " + result.Type.ToString());
- return 1;
- }
-
- if (!(result.NewExpression == newExpression)) return 1;
-
- if (!(result.ToString() == str))
- {
- Console.WriteLine("Unexpected result: " + result.ToString() + " - Expected: " + str);
- return 1;
- }
-
- if (result.Initializers.Count != initializers.Length) return 1;
-
- for (int i = 0; i < initializers.Length; i++)
- {
- if (result.Initializers[i].AddMethod != initializers[i].AddMethod) return 1;
-
- if (result.Initializers[i].Arguments.Count != initializers[i].Arguments.Count) return 1;
-
- for (int j = 0; j < result.Initializers[i].Arguments.Count; j++)
- {
- if (result.Initializers[i].Arguments[j] != initializers[i].Arguments[j]) return 1;
- }
- }
-
- return 0;
- }
-
- public static int VerifyElementInitParms(ElementInit result, MethodInfo exp_mi, string str, params Expression[] args)
- {
- if (result.AddMethod != exp_mi) return 1;
- if (!(result.ToString() == str))
- {
- Console.WriteLine("Unexpected result: " + result.ToString() + " - Expected: " + str);
- return 1;
- }
-
- if (result.Arguments.Count != args.Length) return 1;
-
- for (int i = 0; i < args.Length; i++)
- {
- if (result.Arguments[i] != args[i]) return 1;
- }
-
- return 0;
- }
-
- public static int VerifyMemberAssignmentParms(MemberAssignment result, MemberBindingType bt, Expression expr, MemberInfo member, string str)
- {
- if (!(result.BindingType == bt)) return 1;
- if (!(result.Expression == expr)) return 1;
- if (!(result.Member.Equals(member))) return 1;
- if (!(result.ToString() == str))
- {
- Console.WriteLine("Unexpected result: " + result.ToString() + " - Expected: " + str);
- return 1;
- }
-
- return 0;
- }
-
- public static int VerifyMemberListBindParms(MemberListBinding result, MemberBindingType bt, ElementInit[] initializers, MemberInfo member, string str)
- {
- if (!(result.BindingType == bt)) return 1;
-
- if (!(result.Member.Equals(member))) return 1;
- if (!(result.ToString() == str))
- {
- Console.WriteLine("Unexpected result: " + result.ToString() + " - Expected: " + str);
- return 1;
- }
-
- if (result.Initializers.Count != initializers.Length) return 1;
-
- for (int i = 0; i < initializers.Length; i++)
- {
- if (result.Initializers[i].AddMethod != initializers[i].AddMethod) return 1;
-
- if (result.Initializers[i].Arguments.Count != initializers[i].Arguments.Count) return 1;
-
- for (int j = 0; j < result.Initializers[i].Arguments.Count; j++)
- {
- if (result.Initializers[i].Arguments[j] != initializers[i].Arguments[j]) return 1;
- }
- }
-
-
- return 0;
- }
-
- public static int VerifyMemberMemberBindParms(MemberMemberBinding result, MemberBindingType bt, MemberBinding[] bindings, MemberInfo member, string str)
- {
- if (!(result.BindingType == bt)) return 1;
-
- if (!(result.Member.Equals(member))) return 1;
- if (!(result.ToString() == str))
- {
- Console.WriteLine("Unexpected result: " + result.ToString() + " - Expected: " + str);
- return 1;
- }
-
- if (result.Bindings.Count != bindings.Length) return 1;
-
- for (int i = 0; i < bindings.Length; i++)
- {
- if (!(result.Bindings[i].Equals(bindings[i]))) return 1;
- }
-
- return 0;
- }
-
- public static int VerifyMemberInitParms(MemberInitExpression result, ExpressionType et, Type type, NewExpression newExpr, MemberBinding[] bindings, string str)
- {
- if (!(result.NodeType == et))
- {
- Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
- return 1;
- }
- if (!(result.Type == type))
- {
- Console.WriteLine("Unexpected result type: " + result.Type.ToString());
- return 1;
- }
- if (!(result.NewExpression.Equals(newExpr))) return 1;
- if (!(result.ToString() == str)) return 1;
-
- if (result.Bindings.Count != bindings.Length) return 1;
-
- for (int i = 0; i < bindings.Length; i++)
- {
- if (!(result.Bindings[i].Equals(bindings[i]))) return 1;
- }
-
- return 0;
- }
-
- public static int VerifyNewArrayParms(NewArrayExpression result, ExpressionType et, Type type, Expression[] expr, string str)
- {
- if (!(result.NodeType == et))
- {
- Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
- return 1;
- }
- if (!(result.Type == type))
- {
- Console.WriteLine("Unexpected result type: " + result.Type.ToString());
- return 1;
- }
-
- if (result.Expressions.Count != expr.Length) return 1;
-
- for (int i = 0; i < expr.Length; i++)
- {
- if (!(result.Expressions[i].Equals(expr[i]))) return 1;
- }
- if (!(result.ToString() == str))
- {
- Console.WriteLine("Unexpected result: " + result.ToString() + " - Expected: " + str);
- return 1;
- }
-
- return 0;
- }
-
- public static int VerifyParameterParms(ParameterExpression result, ExpressionType et, Type type, string name, string str)
- {
- if (!(result.NodeType == et))
- {
- Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
- return 1;
- }
- if (!(result.Type == type))
- {
- Console.WriteLine("Unexpected result type: " + result.Type.ToString());
- return 1;
- }
- if (!(result.Name == name)) return 1;
-
- if (!(result.ToString() == str))
- {
- Console.WriteLine("Unexpected result: " + result.ToString() + " - Expected: " + str);
- return 1;
- }
-
- return 0;
- }
-
- public static int VerifyLambdaParms(LambdaExpression result, ExpressionType et, Type type, Expression expr, ParameterExpression[] parms, string str)
- {
- if (!(result.NodeType == et))
- {
- Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
- return 1;
- }
- if (!(result.Type == type))
- {
- Console.WriteLine("Unexpected result type: " + result.Type.ToString());
- return 1;
- }
-
- if (expr == null)
- {
- if (result.Body != null) return 1;
- }
- else
- {
- if (!(result.Body.Equals(expr))) return 1;
- }
-
- if (result.Parameters.Count != parms.Length) return 1;
-
- for (int i = 0; i < parms.Length; i++)
- {
- if (!(result.Parameters[i].Equals(parms[i]))) return 1;
- }
-
- if (!(result.ToString() == str))
- {
- Console.WriteLine("Unexpected result: " + result.ToString() + " - Expected: " + str);
- return 1;
- }
-
- return 0;
- }
-
- public static int VerifyInvokeParms(InvocationExpression result, ExpressionType et, Type type, Expression expr, Expression[] args, string str)
- {
- if (!(result.NodeType == et))
- {
- Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
- return 1;
- }
- if (!(result.Type == type))
- {
- Console.WriteLine("Unexpected result type: " + result.Type.ToString());
- return 1;
- }
-
- if (expr == null)
- {
- if (result.Expression != null) return 1;
- }
- else
- {
- if (!(result.Expression.Equals(expr))) return 1;
- }
-
- if (result.Arguments.Count != args.Length) return 1;
-
- for (int i = 0; i < args.Length; i++)
- {
- if (!(result.Arguments[i].Equals(args[i])))
- {
- return 1;
- }
- }
-
- if (result.ToString() != str)
- {
- Console.WriteLine("Expected: " + str + " Actual: " + result.ToString());
- return 1;
- }
-
- return 0;
- }
- }
-
-
- }
-
- //-------- Scenario 783
- namespace Scenario783
- {
-
- namespace Not
- {
- public class Test
- {
- // Test for functionality: Argument is of type integer
- public static int Test2()
- {
- ConstantExpression ce = Expression.Constant(10);
- Type exp_type = ce.Type;
- ExpressionType exp_et = ExpressionType.Not;
- string exp_str = "Not(" + ce.ToString() + ")";
- Expression exp_operand = ce;
-
- UnaryExpression result = Expression.Not(ce);
-
- return Verification.VerifyUnaryParms(result, exp_et, exp_type, exp_operand, exp_str, null, false, false);
- }
-
-
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "Not2__", new string[] { "positive", "cslinq", "FullTrustOnly", "Pri1" })]
- public static Expression Not2__()
- {
- if (Main() != 0)
- {
- throw new Exception();
- }
- else
- {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- return Test2();
- }
- }
- }
-
-
- public static class Extension
- {
- public static bool CompareParamName(this ArgumentException ex, string expected)
- {
- #if SILVERLIGHT
- #if SLRESOURCES
- return ex.Message.Substring(ex.Message.LastIndexOf(": ") + 2) == expected;
- #else
- return true;
- #endif
- #else
- return ex.ParamName == expected;
- #endif
- }
-
- public static bool CompareParamName(this ArgumentNullException ex, string expected)
- {
- #if SILVERLIGHT
- #if SLRESOURCES
- return ex.Message.Substring(ex.Message.LastIndexOf(": ") + 2) == expected;
- #else
- return true;
- #endif
- #else
- return ex.ParamName == expected;
- #endif
- }
- }
-
- public static class Verification
- {
- public static int VerifyConstParms(ConstantExpression result, ExpressionType et, Type type, object val, string str)
- {
- if (!(result.NodeType == et))
- {
- Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
- return 1;
- }
- if (!(result.Type == type))
- {
- Console.WriteLine("Unexpected result type: " + result.Type.ToString());
- return 1;
- }
- if (val == null)
- {
- if (result.Value != null) return 1;
- }
- else
- {
- if (!(result.Value.Equals(val))) return 1;
- }
- if (!(result.ToString() == str)) return 1;
- return 0;
- }
-
- public static int VerifyUnaryParms(UnaryExpression result, ExpressionType et, Type type, Expression operand, string str, MethodInfo mi, bool islifted, bool isliftedtonull)
- {
- if (!(result.NodeType == et))
- {
- Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
- return 1;
- }
- if (!(result.Type == type))
- {
- Console.WriteLine("Unexpected result type: " + result.Type.ToString());
- return 1;
- }
- if (operand == null)
- {
- if (result.Operand != null) return 1;
- }
- else
- {
- if (!(result.Operand.Equals(operand))) return 1;
- }
- if (!(result.ToString() == str))
- {
- Console.WriteLine("Expected: " + str + " Actual: " + result.ToString());
- return 1;
- }
-
- if (result.Method != mi) return 1;
- if (result.IsLifted != islifted) return 1;
- if (result.IsLiftedToNull != isliftedtonull) return 1;
-
- return 0;
- }
-
- public static int VerifyBinaryParms(BinaryExpression result, ExpressionType et, Type type, Expression left, Expression right, string str, MethodInfo mi, bool islifted, bool isliftedtonull)
- {
- if (!(result.NodeType == et))
- {
- Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
- return 1;
- }
- if (!(result.Type == type))
- {
- Console.WriteLine("Unexpected result type: " + result.Type.ToString());
- return 1;
- }
-
- if (left == null)
- {
- if (result.Left != null)
- {
- Console.WriteLine("left was null");
- return 1;
- }
- }
- else
- {
- if (!(result.Left.Equals(left)))
- {
- Console.WriteLine("left was different");
- return 1;
- }
- }
-
- if (right == null)
- {
- if (result.Right != null) return 1;
- }
- else
- {
- if (!(result.Right.Equals(right))) return 1;
- }
-
- if (!(result.ToString() == str))
- {
- Console.WriteLine("Expected: " + str + " Actual: " + result.ToString());
- return 1;
- }
-
- if (result.Method != mi) return 1;
- if (result.IsLifted != islifted) return 1;
- if (result.IsLiftedToNull != isliftedtonull) return 1;
-
- if (result.Conversion != null) return 1;
-
- return 0;
- }
-
- public static int VerifyBinaryParms(BinaryExpression result, ExpressionType et, Type type, Expression left, Expression right, string str, MethodInfo mi, LambdaExpression conv_expr, bool islifted, bool isliftedtonull)
- {
- if (!(result.NodeType == et))
- {
- Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
- return 1;
- }
- if (!(result.Type == type))
- {
- Console.WriteLine("Unexpected result type: " + result.Type.ToString());
- return 1;
- }
-
- if (left == null)
- {
- if (result.Left != null) return 1;
- }
- else
- {
- if (!(result.Left.Equals(left))) return 1;
- }
-
- if (right == null)
- {
- if (result.Right != null) return 1;
- }
- else
- {
- if (!(result.Right.Equals(right))) return 1;
- }
-
- if (!(result.ToString() == str)) return 1;
-
- if (result.Method != mi) return 1;
- if (result.IsLifted != islifted) return 1;
- if (result.IsLiftedToNull != isliftedtonull) return 1;
-
- if (result.Conversion.ToString() != conv_expr.ToString()) return 1;
-
- return 0;
- }
-
- public static int VerifyMethodCallParms(MethodCallExpression result, ExpressionType et, Type type, MethodInfo method, Expression obj, string str, params Expression[] arguments)
- {
- if (!(result.NodeType == et))
- {
- Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
- return 1;
- }
- if (!(result.Type == type))
- {
- Console.WriteLine("Unexpected result type: " + result.Type.ToString());
- return 1;
- }
-
- if (!(result.Method == method)) return 1;
-
- if (obj == null)
- {
- if (result.Object != null)
- {
- Console.WriteLine("Expected object to be null.");
- return 1;
- }
- }
- else
- {
- if (!(result.Object.Equals(obj)))
- {
- Console.WriteLine("Object on which call is made is different from the result.");
- return 1;
- }
- }
-
- if (!(result.ToString() == str))
- {
- Console.WriteLine("Expected: " + str + " Actual: " + result.ToString());
- return 1;
- }
-
- if (result.Arguments.Count != arguments.Length) return 1;
-
- for (int i = 0; i < arguments.Length; i++)
- {
- if (result.Arguments[i] != arguments[i]) return 1;
- }
-
- return 0;
- }
-
- public static int VerifyTypeBinaryParms(TypeBinaryExpression result, ExpressionType et, Type type, Expression expr, Type typeop, string str)
- {
- if (!(result.NodeType == et))
- {
- Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
- return 1;
- }
- if (!(result.Type == type))
- {
- Console.WriteLine("Unexpected result type: " + result.Type.ToString());
- return 1;
- }
-
- if (expr == null)
- {
- Console.WriteLine("expr was null.");
- if (result.Expression != null) return 1;
- }
- else
- {
- if (!(result.Expression.Equals(expr)))
- {
- return 1;
- }
- }
-
- if (!(result.TypeOperand == typeop)) return 1;
-
- if (!(result.ToString() == str))
- {
- Console.WriteLine("Expected: " + str + " Actual: " + result.ToString());
- return 1;
- }
-
- return 0;
- }
-
- public static int VerifyConditionalParms(ConditionalExpression result, ExpressionType et, Type type, Expression test, Expression ifTrue, Expression ifFalse, string str)
- {
- if (!(result.NodeType == et))
- {
- Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
- return 1;
- }
- if (!(result.Type == type))
- {
- Console.WriteLine("Unexpected result type: " + result.Type.ToString());
- return 1;
- }
-
- if (test == null)
- {
- if (result.Test != null) return 1;
- }
- else
- {
- if (!(result.Test.Equals(test))) return 1;
- }
-
- if (ifTrue == null)
- {
- if (result.IfTrue != null) return 1;
- }
- else
- {
- if (!(result.IfTrue.Equals(ifTrue))) return 1;
- }
-
- if (ifFalse == null)
- {
- if (result.IfFalse != null) return 1;
- }
- else
- {
- if (!(result.IfFalse.Equals(ifFalse))) return 1;
- }
-
- if (!(result.ToString() == str)) return 1;
-
- return 0;
- }
-
- public static int VerifyMemberParms(MemberExpression result, ExpressionType et, Type type, Expression exp_expr, MemberInfo exp_member, string str)
- {
- if (!(result.NodeType == et))
- {
- Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
- return 1;
- }
- if (!(result.Type == type))
- {
- Console.WriteLine("Unexpected result type: " + result.Type.ToString());
- return 1;
- }
-
- if (exp_expr == null)
- {
- if (result.Expression != null)
- {
- Console.WriteLine("Expression is not null: " + result.Expression.ToString());
- return 1;
- }
- }
- else
- {
- if (!(result.Expression.Equals(exp_expr)))
- {
- Console.WriteLine("Unexpected Expression: " + result.Expression.ToString());
- return 1;
- }
- }
-
- if (!(result.Member == exp_member))
- {
- Console.WriteLine("Unexpected result member: " + result.Member.ToString());
- return 1;
- }
-
- if (!(result.ToString() == str))
- {
- Console.WriteLine("Unexpected result: " + result.ToString() + " - Expected: " + str);
- return 1;
- }
-
- return 0;
- }
-
- public static int VerifyNewParms(NewExpression result, ExpressionType et, Type type, ConstructorInfo constructor, string str, Expression[] arguments, params MemberInfo[] members)
- {
- if (!(result.NodeType == et))
- {
- Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
- return 1;
- }
- if (!(result.Type == type))
- {
- Console.WriteLine("Unexpected result type: " + result.Type.ToString());
- return 1;
- }
-
- if (!(result.Constructor == constructor))
- {
- Console.WriteLine("Unexpected constructor");
- return 1;
- }
-
- if (!(result.ToString() == str))
- {
- Console.WriteLine("Unexpected result: " + result.ToString() + " - Expected: " + str);
- return 1;
- }
-
- if (arguments == null)
- {
- if (result.Arguments.Count != 0)
- {
- Console.WriteLine("More than one argument supplied: " + result.Arguments.Count);
- return 1;
- }
- }
- else
- {
- if (result.Arguments.Count != arguments.Length)
- {
- Console.WriteLine("Different number of arguments obtained: " + result.Arguments.Count);
- return 1;
- }
- for (int i = 0; i < arguments.Length; i++)
- {
- if (result.Arguments[i] != arguments[i])
- {
- Console.WriteLine("Argument " + i.ToString() + " is different than expected: Expected " + arguments[i].ToString() + " and got " + result.Arguments[i].ToString());
- return 1;
- }
- }
- }
-
- if (result.Members == null)
- {
- Console.WriteLine("result.Members was null");
- return 1;
- }
-
- if (members == null)
- {
- if (result.Members.Count != 0)
- {
- Console.WriteLine("Got more than zero members");
- return 1;
- }
- }
- else
- {
- if (result.Members.Count != members.Length)
- {
- Console.WriteLine("Got an unexpected number of members: " + result.Members.Count);
- return 1;
- }
-
- for (int i = 0; i < members.Length; i++)
- {
- if (result.Members[i] != members[i])
- {
- Console.WriteLine("Member " + i.ToString() + " is different than expected: Expected " + members[i].ToString() + " and got " + result.Members[i].ToString());
- return 1;
- }
- }
- }
-
- return 0;
- }
-
- public static int VerifyNewParms(NewExpression result, ExpressionType et, Type type, ConstructorInfo constructor, string str, Expression[] arguments)
- {
- if (!(result.NodeType == et))
- {
- Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
- return 1;
- }
- if (!(result.Type == type))
- {
- Console.WriteLine("Unexpected result type: " + result.Type.ToString());
- return 1;
- }
-
- if (!(result.Constructor == constructor))
- {
- Console.WriteLine("Constructor is different from expected.");
- return 1;
- }
-
- if (!(result.ToString() == str))
- {
- Console.WriteLine("Unexpected result: " + result.ToString() + " - Expected: " + str);
- return 1;
- }
-
- if (result.Arguments.Count != arguments.Length)
- {
- Console.WriteLine("Different number of arguments: " + result.Arguments.Count);
- return 1;
- }
-
- for (int i = 0; i < arguments.Length; i++)
- {
- …
Large files files are truncated, but you can click here to view the full file