/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
- #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++)
- {
- 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 784
- namespace Scenario784
- {
-
- namespace Not
- {
- public class Test
- {
- // Test for functionality: Argument is of type bool
- public static int Test3()
- {
- ConstantExpression ce = Expression.Constant(true);
- 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, "Not3__", new string[] { "positive", "cslinq", "FullTrustOnly", "Pri1" })]
- public static Expression Not3__()
- {
- if (Main() != 0)
- {
- throw new Exception();
- }
- else
- {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- return Test3();
- }
- }
- }
-
-
- 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 785
- namespace Scenario785
- {
-
- namespace Not
- {
- public class Test
- {
- // Test for functionality: Argument is of type bool?
- public static int Test4()
- {
- ConstantExpression ce = Expression.Constant(null, typeof(bool?));
- Type exp_type = typeof(bool?);
- 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, true, true);
- }
-
-
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "Not4__", new string[] { "positive", "cslinq", "FullTrustOnly", "Pri1" })]
- public static Expression Not4__()
- {
- if (Main() != 0)
- {
- throw new Exception();
- }
- else
- {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- return Test4();
- }
- }
- }
-
-
- 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 786
- namespace Scenario786
- {
-
- namespace Not
- {
- public class Test
- {
- // Test for functionality: Argument is of type long?
- public static int Test5()
- {
- ConstantExpression ce = Expression.Constant(null, typeof(long?));
- 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, true, true);
- }
-
-
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "Not5__", new string[] { "positive", "cslinq", "FullTrustOnly", "Pri1" })]
- public static Expression Not5__()
- {
- if (Main() != 0)
- {
- throw new Exception();
- }
- else
- {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- return Test5();
- }
- }
- }
-
-
- 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 787
- namespace Scenario787
- {
-
- namespace Not
- {
- public class Test
- {
- // Test for functionality: Argument is of type string
- public static int Test6()
- {
- ConstantExpression ce = Expression.Constant("Test");
-
- try
- {
- UnaryExpression result = Expression.Not(ce);
- return 1;
- }
- catch (InvalidOperationException)
- {
- return 0;
- }
- }
-
-
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "Not6__", new string[] { "positive", "cslinq", "FullTrustOnly", "Pri1" })]
- public static Expression Not6__()
- {
- if (Main() != 0)
- {
- throw new Exception();
- }
- else
- {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- return Test6();
- }
- }
- }
-
-
- 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 788
- namespace Scenario788
- {
-
- namespace Not
- {
- public class Test
- {
- // Overload-1: Test for functionality: Argument is of type user-defined type (Logical Not)
- public static int Test7()
- {
- TC1 ctest = new TC1();
- ConstantExpression ce = Expression.Constant(ctest, typeof(TC1));
- Type exp_type = typeof(TC1);
- ExpressionType exp_et = ExpressionType.Not;
- string exp_str = "Not(" + ce.ToString() + ")";
- Expression exp_operand = ce;
- MethodInfo exp_mi = typeof(TC1).GetMethod("op_LogicalNot");
-
- UnaryExpression result = Expression.Not(ce);
-
- return Verification.VerifyUnaryParms(result, exp_et, exp_type, exp_operand, exp_str, exp_mi, false, false);
- }
-
-
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "Not7__", new string[] { "positive", "cslinq", "FullTrustOnly", "Pri1" })]
- public static Expression Not7__()
- {
- if (Main() != 0)
- {
- throw new Exception();
- }
- else
- {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- return Test7();
- }
- }
- }
-
-
- 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;
- }
- }
-
-
-
- namespace Not
- {
- // Declaring user-defined types for testing
- struct TC1
- {
- public static TC1 operator !(TC1 c)
- {
- return new TC1();
- }
-
- public static TC1 operator ~(TC1 c)
- {
- return new TC1();
- }
- }
-
- struct TC2
- {
- public static TC2 operator ~(TC2 c)
- {
- return new TC2();
- }
- }
-
- struct TC3
- {
- public static TC3 Meth1(TC3 c)
- {
- return new TC3();
- }
- }
- }
-
- }
-
- //-------- Scenario 789
- namespace Scenario789
- {
-
- namespace Not
- {
- public class Test
- {
- // Overload-1: Test for functionality: Argument is of type nullable user-defined type (Logical Not)
- public static int Test8()
- {
- TC1? ctest = new TC1?();
- ConstantExpression ce = Expression.Constant(ctest, typeof(TC1?));
- Type exp_type = typeof(TC1?);
- ExpressionType exp_et = ExpressionType.Not;
- string exp_str = "Not(" + ce.ToString() + ")";
- Expression exp_operand = ce;
- MethodInfo exp_mi = typeof(TC1).GetMethod("op_LogicalNot");
-
- UnaryExpression result = Expression.Not(ce);
-
- return Verification.VerifyUnaryParms(result, exp_et, exp_type, exp_operand, exp_str, exp_mi, true, true);
- }
-
-
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "Not8__", new string[] { "positive", "cslinq", "FullTrustOnly", "Pri1" })]
- public static Expression Not8__()
- {
- if (Main() != 0)
- {
- throw new Exception();
- }
- else
- {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- return Test8();
- }
- }
- }
-
-
- 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;
- }
- }
-
-
-
- namespace Not
- {
- // Declaring user-defined types for testing
- struct TC1
- {
- public static TC1 operator !(TC1 c)
- {
- return new TC1();
- }
-
- public static TC1 operator ~(TC1 c)
- {
- return new TC1();
- }
- }
-
- struct TC2
- {
- public static TC2 operator ~(TC2 c)
- {
- return new TC2();
- }
- }
-
- struct TC3
- {
- public static TC3 Meth1(TC3 c)
- {
- return new TC3();
- }
- }
- }
-
- }
-
- //-------- Scenario 790
- namespace Scenario790
- {
-
- namespace Not
- {
- public class Test
- {
- // Overload-1: Test for functionality: Argument is of type user-defined type (Bitwise Complement)
- public static int Test9()
- {
- TC2 ctest = new TC2();
- ConstantExpression ce = Expression.Constant(ctest, typeof(TC2));
- Type exp_type = typeof(TC2);
- ExpressionType exp_et = ExpressionType.Not;
- string exp_str = "Not(" + ce.ToString() + ")";
- Expression exp_operand = ce;
- MethodInfo exp_mi = typeof(TC2).GetMethod("op_OnesComplement");
-
- UnaryExpression result = Expression.Not(ce);
-
- return Verification.VerifyUnaryParms(result, exp_et, exp_type, exp_operand, exp_str, exp_mi, false, false);
- }
-
-
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "Not9__", new string[] { "positive", "cslinq", "FullTrustOnly", "Pri1" })]
- public static Expression Not9__()
- {
- if (Main() != 0)
- {
- throw new Exception();
- }
- else
- {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- return Test9();
- }
- }
- }
-
-
- 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;
- }
- }
-
-
-
- namespace Not
- {
- // Declaring user-defined types for testing
- struct TC1
- {
- public static TC1 operator !(TC1 c)
- {
- return new TC1();
- }
-
- public static TC1 operator ~(TC1 c)
- {
- return new TC1();
- }
- }
-
- struct TC2
- {
- public static TC2 operator ~(TC2 c)
- {
- return new TC2();
- }
- }
-
- struct TC3
- {
- public static TC3 Meth1(TC3 c)
- {
- return new TC3();
- }
- }
- }
-
- }
-
- //-------- Scenario 791
- namespace Scenario791
- {
-
- namespace Not
- {
- public class Test
- {
- // Overload-1: Test for functionality: Argument is of type nullable user-defined type (Logical Not)
- public static int Test10()
- {
- TC2? ctest = new TC2?();
- ConstantExpression ce = Expression.Constant(ctest, typeof(TC2?));
- Type exp_type = typeof(TC2?);
- ExpressionType exp_et = ExpressionType.Not;
- string exp_str = "Not(" + ce.ToString() + ")";
- Expression exp_operand = ce;
- MethodInfo exp_mi = typeof(TC2).GetMethod("op_OnesComplement");
-
- UnaryExpression result = Expression.Not(ce);
-
- return Verification.VerifyUnaryParms(result, exp_et, exp_type, exp_operand, exp_str, exp_mi, true, true);
- }
-
-
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "Not10__", new string[] { "positive", "cslinq", "FullTrustOnly", "Pri1" })]
- public static Expression Not10__()
- {
- if (Main() != 0)
- {
- throw new Exception();
- }
- else
- {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- return Test10();
- }
- }
- }
-
-
- 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;
- }
- }
-
-
-
- namespace Not
- {
- // Declaring user-defined types for testing
- struct TC1
- {
- public static TC1 operator !(TC1 c)
- {
- return new TC1();
- }
-
- public static TC1 operator ~(TC1 c)
- {
- return new TC1();
- }
- }
-
- struct TC2
- {
- public static TC2 operator ~(TC2 c)
- {
- return new TC2();
- }
- }
-
- struct TC3
- {
- public static TC3 Meth1(TC3 c)
- {
- return new TC3();
- }
- }
- }
-
- }
-
- //-------- Scenario 792
- namespace Scenario792
- {
-
- namespace Not
- {
- public class Test
- {
- // Overload-1: User-defined type without operator overloading
- public static int Test11()
- {
- TC3 ctest = new TC3();
- ConstantExpression ce = Expression.Constant(ctest, typeof(TC3));
-
- try
- {
- UnaryExpression result = Expression.Not(ce);
- return 1;
- }
- catch (InvalidOperationException)
- {
- return 0;
- }
- }
-
-
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "Not11__", new string[] { "positive", "cslinq", "FullTrustOnly", "Pri1" })]
- public static Expression Not11__()
- {
- if (Main() != 0)
- {
- throw new Exception();
- }
- else
- {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- return Test11();
- }
- }
- }
-
-
- 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;
- }
- }
-
-
-
- namespace Not
- {
- // Declaring user-defined types for testing
- struct TC1
- {
- public static TC1 operator !(TC1 c)
- {
- return new TC1();
- }
-
- public static TC1 operator ~(TC1 c)
- {
- return new TC1();
- }
- }
-
- struct TC2
- {
- public static TC2 operator ~(TC2 c)
- {
- return new TC2();
- }
- }
-
- struct TC3
- {
- public static TC3 Meth1(TC3 c)
- {
- return new TC3();
- }
- }
- }
-
- }
-
- //-------- Scenario 793
- namespace Scenario793
- {
-
- namespace Not
- {
- public class Test
- {
- // Overload-2: Test for functionality: Passing null methodinfo
- public static int Test12()
- {
- TC2? ctest = new TC2?();
- ConstantExpression ce = Expression.Constant(ctest, typeof(TC2?));
- Type exp_type = typeof(TC2?);
- ExpressionType exp_et = ExpressionType.Not;
- string exp_str = "Not(" + ce.ToString() + ")";
- Expression exp_operand = ce;
- MethodInfo exp_mi = typeof(TC2).GetMethod("op_OnesComplement");
-
- UnaryExpression result = Expression.Not(ce, null);
-
- return Verification.VerifyUnaryParms(result, exp_et, exp_type, exp_operand, exp_str, exp_mi, true, true);
- }
-
-
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "Not12__", new string[] { "positive", "cslinq", "FullTrustOnly", "Pri1" })]
- public static Expression Not12__()
- {
- if (Main() != 0)
- {
- throw new Exception();
- }
- else
- {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- return Test12();
- }
- }
- }
-
-
- 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;
- }
- }
-
-
-
- namespace Not
- {
- // Declaring user-defined types for testing
- struct TC1
- {
- public static TC1 operator !(TC1 c)
- {
- return new TC1();
- }
-
- public static TC1 operator ~(TC1 c)
- {
- return new TC1();
- }
- }
-
- struct TC2
- {
- public static TC2 operator ~(TC2 c)
- {
- return new TC2();
- }
- }
-
- struct TC3
- {
- public static TC3 Meth1(TC3 c)
- {
- return new TC3();
- }
- }
- }
-
- }
-
- //-------- Scenario 794
- namespace Scenario794
- {
-
- namespace Not
- {
- public class Test
- {
- // Overload-2: Passing null methodinfo
- public static int Test13a()
- {
- TC3 ctest = new TC3();
- ConstantExpression ce = Expression.Constant(ctest, typeof(TC3));
-
- try
- {
- UnaryExpression result = Expression.Not(ce, null);
- return 1;
- }
- catch (InvalidOperationException)
- {
- return 0;
- }
- }
-
-
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "Not13a__", new string[] { "positive", "cslinq", "FullTrustOnly", "Pri1" })]
- public static Expression Not13a__()
- {
- if (Main() != 0)
- {
- throw new Exception();
- }
- else
- {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- return Test13a();
- }
- }
- }
-
-
- 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;
- }
- }
-
-
-
- namespace Not
- {
- // Declaring user-defined types for testing
- struct TC1
- {
- public static TC1 operator !(TC1 c)
- {
- return new TC1();
- }
-
- public static TC1 operator ~(TC1 c)
- {
- return new TC1();
- }
- }
-
- struct TC2
- {
- public static TC2 operator ~(TC2 c)
- {
- return new TC2();
- }
- }
-
- struct TC3
- {
- public static TC3 Meth1(TC3 c)
- {
- return new TC3();
- }
- }
- }
-
- }
-
- //-------- Scenario 795
- namespace Scenario795
- {
-
- namespace Not
- {
- public class Test
- {
- // Overload-2: Expression is null and MethodInfo is non-null
- public static int Test13b()
- {
- TC3 ctest = new TC3();
- ConstantExpression ce = Expression.Constant(ctest, typeof(TC3));
- MethodInfo exp_mi = typeof(TC3).GetMethod("Meth1");
-
- try
- {
- ce = null;
- UnaryExpression result = Expression.Not(ce, exp_mi);
- return 1;
- }
- catch (ArgumentNullException ane)
- {
- if (!ane.CompareParamName("expression")) return 1;
- return 0;
- }
- }
-
-
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "Not13b__", new string[] { "positive", "cslinq", "FullTrustOnly", "Pri1" })]
- public static Expression Not13b__()
- {
- if (Main() != 0)
- {
- throw new Exception();
- }
- else
- {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- return Test13b();
- }
- }
- }
-
-
-
- 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;
- }
- }
-
-
-
- namespace Not
- {
- // Declaring user-defined types for testing
- struct TC1
- {
- public static TC1 operator !(TC1 c)
- {
- return new TC1();
- }
-
- public static TC1 operator ~(TC1 c)
- {
- return new TC1();
- }
- }
-
- struct TC2
- {
- public static TC2 operator ~(TC2 c)
- {
- return new TC2();
- }
- }
-
- struct TC3
- {
- public static TC3 Meth1(TC3 c)
- {
- return new TC3();
- }
- }
- }
-
- }
-
- //-------- Scenario 796
- namespace Scenario796
- {
-
- namespace Not
- {
- public class Test
- {
- // Overload-2: Test for functionality: Passing non-null methodinfo without lifting
- public static int Test14()
- {
- TC3 ctest = new TC3();
- ConstantExpression ce = Expression.Constant(ctest, typeof(TC3));
- Type exp_type = typeof(TC3);
- ExpressionType exp_et = ExpressionType.Not;
- string exp_str = "Not(" + ce.ToString() + ")";
- Expression exp_operand = ce;
- MethodInfo exp_mi = typeof(TC3).GetMethod("Meth1");
-
- UnaryExpression result = Expression.Not(ce, exp_mi);
-
- return Verification.VerifyUnaryParms(result, exp_et, exp_type, exp_operand, exp_str, exp_mi, false, false);
- }
-
-
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "Not14__", new string[] { "positive", "cslinq", "FullTrustOnly", "Pri1" })]
- public static Expression Not14__()
- {
- if (Main() != 0)
- {
- throw new Exception();
- }
- else
- {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- return Test14();
- }
- }
- }
-
-
- 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;
- }
- }
-
-
-
- namespace Not
- {
- // Declaring user-defined types for testing
- struct TC1
- {
- public static TC1 operator !(TC1 c)
- {
- return new TC1();
- }
-
- public static TC1 operator ~(TC1 c)
- {
- return new TC1();
- }
- }
-
- struct TC2
- {
- public static TC2 operator ~(TC2 c)
- {
- return new TC2();
- }
- }
-
- struct TC3
- {
- public static TC3 Meth1(TC3 c)
- {
- return new TC3();
- }
- }
- }
-
- }
-
- //-------- Scenario 797
- namespace Scenario797
- {
-
- namespace Not
- {
- public class Test
- {
- // Overload-2: Test for functionality: Passing non-null methodinfo with lifting
- public static int Test15()
- {
- TC3? ctest = new TC3?();
- ConstantExpression ce = Expression.Constant(ctest, typeof(TC3?));
- Type exp_type = typeof(TC3?);
- ExpressionType exp_et = ExpressionType.Not;
- string exp_str = "Not(" + ce.ToString() + ")";
- Expression exp_operand = ce;
- MethodInfo exp_mi = typeof(TC3).GetMethod("Meth1");
-
- UnaryExpression result = Expression.Not(ce, exp_mi);
-
- return Verification.VerifyUnaryParms(result, exp_et, exp_type, exp_operand, exp_str, exp_mi, true, true);
- }
-
-
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "Not15__", new string[] { "positive", "cslinq", "FullTrustOnly", "Pri1" })]
- public static Expression Not15__()
- {
- if (Main() != 0)
- {
- throw new Exception();
- }
- else
- {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- return Test15();
- }
- }
- }
-
-
- 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;
- }
- }
-
-
-
- namespace Not
- {
- // Declaring user-defined types for testing
- struct TC1
- {
- public static TC1 operator !(TC1 c)
- {
- return new TC1();
- }
-
- public static TC1 operator ~(TC1 c)
- {
- return new TC1();
- }
- }
-
- struct TC2
- {
- public static TC2 operator ~(TC2 c)
- {
- return new TC2();
- }
- }
-
- struct TC3
- {
- public static TC3 Meth1(TC3 c)
- {
- return new TC3();
- }
- }
- }
-
- }
-
- }