PageRenderTime 94ms CodeModel.GetById 24ms app.highlight 45ms RepoModel.GetById 1ms app.codeStats 4ms

/IronPython_Main/Runtime/Tests/ETScenariosCSLinq/CSLinq/ExpressionTreeNodes/Not.cs

#
C# | 13447 lines | 11483 code | 1922 blank | 42 comment | 4914 complexity | 666008fde201bf2127369f0fca935e49 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

   1#if !CLR2
   2using System.Linq.Expressions;
   3#else
   4using Microsoft.Scripting.Ast;
   5using Microsoft.Scripting.Utils;
   6#endif
   7
   8using System.Reflection;
   9using System.Collections;
  10using System.Text;
  11using System.Collections.Generic;
  12using System;
  13namespace ExpressionTreeNodes
  14{
  15
  16
  17    //-------- Scenario 782
  18    namespace Scenario782
  19    {
  20
  21        namespace Not
  22        {
  23            public class Test
  24            {
  25                // expression = null
  26                public static int Test1()
  27                {
  28                    ConstantExpression ce = Expression.Constant(10);
  29
  30                    try
  31                    {
  32                        ce = null;
  33                        UnaryExpression result = Expression.Not(ce);
  34                        return 1;
  35                    }
  36                    catch (ArgumentNullException ane)
  37                    {
  38                        if (ane.CompareParamName("expression")) return 0;
  39                        return 1;
  40                    }
  41                }
  42
  43
  44                [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "Not1__", new string[] { "positive", "cslinq", "FullTrustOnly", "Pri1" })]
  45                public static Expression Not1__()
  46                {
  47                    if (Main() != 0)
  48                    {
  49                        throw new Exception();
  50                    }
  51                    else
  52                    {
  53                        return Expression.Constant(0);
  54                    }
  55                }
  56                public static int Main()
  57                {
  58                    return Test1();
  59                }
  60            }
  61        }
  62
  63
  64
  65        public static class Extension
  66        {
  67            public static bool CompareParamName(this ArgumentException ex, string expected)
  68            {
  69#if SILVERLIGHT
  70#if SLRESOURCES
  71			        return ex.Message.Substring(ex.Message.LastIndexOf(": ") + 2) == expected;
  72#else
  73			        return true;
  74#endif
  75#else
  76                return ex.ParamName == expected;
  77#endif
  78            }
  79
  80            public static bool CompareParamName(this ArgumentNullException ex, string expected)
  81            {
  82#if SILVERLIGHT
  83#if SLRESOURCES
  84			        return ex.Message.Substring(ex.Message.LastIndexOf(": ") + 2) == expected;
  85#else
  86			        return true;
  87#endif
  88#else
  89                return ex.ParamName == expected;
  90#endif
  91            }
  92        }
  93
  94        public static class Verification
  95        {
  96            public static int VerifyConstParms(ConstantExpression result, ExpressionType et, Type type, object val, string str)
  97            {
  98                if (!(result.NodeType == et))
  99                {
 100                    Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
 101                    return 1;
 102                }
 103                if (!(result.Type == type))
 104                {
 105                    Console.WriteLine("Unexpected result type: " + result.Type.ToString());
 106                    return 1;
 107                }
 108                if (val == null)
 109                {
 110                    if (result.Value != null) return 1;
 111                }
 112                else
 113                {
 114                    if (!(result.Value.Equals(val))) return 1;
 115                }
 116                if (!(result.ToString() == str)) return 1;
 117                return 0;
 118            }
 119
 120            public static int VerifyUnaryParms(UnaryExpression result, ExpressionType et, Type type, Expression operand, string str, MethodInfo mi, bool islifted, bool isliftedtonull)
 121            {
 122                if (!(result.NodeType == et))
 123                {
 124                    Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
 125                    return 1;
 126                }
 127                if (!(result.Type == type))
 128                {
 129                    Console.WriteLine("Unexpected result type: " + result.Type.ToString());
 130                    return 1;
 131                }
 132                if (operand == null)
 133                {
 134                    if (result.Operand != null) return 1;
 135                }
 136                else
 137                {
 138                    if (!(result.Operand.Equals(operand))) return 1;
 139                }
 140                if (!(result.ToString() == str))
 141                {
 142                    Console.WriteLine("Expected: " + str + " Actual: " + result.ToString());
 143                    return 1;
 144                }
 145
 146                if (result.Method != mi) return 1;
 147                if (result.IsLifted != islifted) return 1;
 148                if (result.IsLiftedToNull != isliftedtonull) return 1;
 149
 150                return 0;
 151            }
 152
 153            public static int VerifyBinaryParms(BinaryExpression result, ExpressionType et, Type type, Expression left, Expression right, string str, MethodInfo mi, bool islifted, bool isliftedtonull)
 154            {
 155                if (!(result.NodeType == et))
 156                {
 157                    Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
 158                    return 1;
 159                }
 160                if (!(result.Type == type))
 161                {
 162                    Console.WriteLine("Unexpected result type: " + result.Type.ToString());
 163                    return 1;
 164                }
 165
 166                if (left == null)
 167                {
 168                    if (result.Left != null)
 169                    {
 170                        Console.WriteLine("left was null");
 171                        return 1;
 172                    }
 173                }
 174                else
 175                {
 176                    if (!(result.Left.Equals(left)))
 177                    {
 178                        Console.WriteLine("left was different");
 179                        return 1;
 180                    }
 181                }
 182
 183                if (right == null)
 184                {
 185                    if (result.Right != null) return 1;
 186                }
 187                else
 188                {
 189                    if (!(result.Right.Equals(right))) return 1;
 190                }
 191
 192                if (!(result.ToString() == str))
 193                {
 194                    Console.WriteLine("Expected: " + str + " Actual: " + result.ToString());
 195                    return 1;
 196                }
 197
 198                if (result.Method != mi) return 1;
 199                if (result.IsLifted != islifted) return 1;
 200                if (result.IsLiftedToNull != isliftedtonull) return 1;
 201
 202                if (result.Conversion != null) return 1;
 203
 204                return 0;
 205            }
 206
 207            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)
 208            {
 209                if (!(result.NodeType == et))
 210                {
 211                    Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
 212                    return 1;
 213                }
 214                if (!(result.Type == type))
 215                {
 216                    Console.WriteLine("Unexpected result type: " + result.Type.ToString());
 217                    return 1;
 218                }
 219
 220                if (left == null)
 221                {
 222                    if (result.Left != null) return 1;
 223                }
 224                else
 225                {
 226                    if (!(result.Left.Equals(left))) return 1;
 227                }
 228
 229                if (right == null)
 230                {
 231                    if (result.Right != null) return 1;
 232                }
 233                else
 234                {
 235                    if (!(result.Right.Equals(right))) return 1;
 236                }
 237
 238                if (!(result.ToString() == str)) return 1;
 239
 240                if (result.Method != mi) return 1;
 241                if (result.IsLifted != islifted) return 1;
 242                if (result.IsLiftedToNull != isliftedtonull) return 1;
 243
 244                if (result.Conversion.ToString() != conv_expr.ToString()) return 1;
 245
 246                return 0;
 247            }
 248
 249            public static int VerifyMethodCallParms(MethodCallExpression result, ExpressionType et, Type type, MethodInfo method, Expression obj, string str, params Expression[] arguments)
 250            {
 251                if (!(result.NodeType == et))
 252                {
 253                    Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
 254                    return 1;
 255                }
 256                if (!(result.Type == type))
 257                {
 258                    Console.WriteLine("Unexpected result type: " + result.Type.ToString());
 259                    return 1;
 260                }
 261
 262                if (!(result.Method == method)) return 1;
 263
 264                if (obj == null)
 265                {
 266                    if (result.Object != null)
 267                    {
 268                        Console.WriteLine("Expected object to be null.");
 269                        return 1;
 270                    }
 271                }
 272                else
 273                {
 274                    if (!(result.Object.Equals(obj)))
 275                    {
 276                        Console.WriteLine("Object on which call is made is different from the result.");
 277                        return 1;
 278                    }
 279                }
 280
 281                if (!(result.ToString() == str))
 282                {
 283                    Console.WriteLine("Expected: " + str + " Actual: " + result.ToString());
 284                    return 1;
 285                }
 286
 287                if (result.Arguments.Count != arguments.Length) return 1;
 288
 289                for (int i = 0; i < arguments.Length; i++)
 290                {
 291                    if (result.Arguments[i] != arguments[i]) return 1;
 292                }
 293
 294                return 0;
 295            }
 296
 297            public static int VerifyTypeBinaryParms(TypeBinaryExpression result, ExpressionType et, Type type, Expression expr, Type typeop, string str)
 298            {
 299                if (!(result.NodeType == et))
 300                {
 301                    Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
 302                    return 1;
 303                }
 304                if (!(result.Type == type))
 305                {
 306                    Console.WriteLine("Unexpected result type: " + result.Type.ToString());
 307                    return 1;
 308                }
 309
 310                if (expr == null)
 311                {
 312                    Console.WriteLine("expr was null.");
 313                    if (result.Expression != null) return 1;
 314                }
 315                else
 316                {
 317                    if (!(result.Expression.Equals(expr)))
 318                    {
 319                        return 1;
 320                    }
 321                }
 322
 323                if (!(result.TypeOperand == typeop)) return 1;
 324
 325                if (!(result.ToString() == str))
 326                {
 327                    Console.WriteLine("Expected: " + str + " Actual: " + result.ToString());
 328                    return 1;
 329                }
 330
 331                return 0;
 332            }
 333
 334            public static int VerifyConditionalParms(ConditionalExpression result, ExpressionType et, Type type, Expression test, Expression ifTrue, Expression ifFalse, string str)
 335            {
 336                if (!(result.NodeType == et))
 337                {
 338                    Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
 339                    return 1;
 340                }
 341                if (!(result.Type == type))
 342                {
 343                    Console.WriteLine("Unexpected result type: " + result.Type.ToString());
 344                    return 1;
 345                }
 346
 347                if (test == null)
 348                {
 349                    if (result.Test != null) return 1;
 350                }
 351                else
 352                {
 353                    if (!(result.Test.Equals(test))) return 1;
 354                }
 355
 356                if (ifTrue == null)
 357                {
 358                    if (result.IfTrue != null) return 1;
 359                }
 360                else
 361                {
 362                    if (!(result.IfTrue.Equals(ifTrue))) return 1;
 363                }
 364
 365                if (ifFalse == null)
 366                {
 367                    if (result.IfFalse != null) return 1;
 368                }
 369                else
 370                {
 371                    if (!(result.IfFalse.Equals(ifFalse))) return 1;
 372                }
 373
 374                if (!(result.ToString() == str)) return 1;
 375
 376                return 0;
 377            }
 378
 379            public static int VerifyMemberParms(MemberExpression result, ExpressionType et, Type type, Expression exp_expr, MemberInfo exp_member, string str)
 380            {
 381                if (!(result.NodeType == et))
 382                {
 383                    Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
 384                    return 1;
 385                }
 386                if (!(result.Type == type))
 387                {
 388                    Console.WriteLine("Unexpected result type: " + result.Type.ToString());
 389                    return 1;
 390                }
 391
 392                if (exp_expr == null)
 393                {
 394                    if (result.Expression != null)
 395                    {
 396                        Console.WriteLine("Expression is not null: " + result.Expression.ToString());
 397                        return 1;
 398                    }
 399                }
 400                else
 401                {
 402                    if (!(result.Expression.Equals(exp_expr)))
 403                    {
 404                        Console.WriteLine("Unexpected Expression: " + result.Expression.ToString());
 405                        return 1;
 406                    }
 407                }
 408
 409                if (!(result.Member == exp_member))
 410                {
 411                    Console.WriteLine("Unexpected result member: " + result.Member.ToString());
 412                    return 1;
 413                }
 414
 415                if (!(result.ToString() == str))
 416                {
 417                    Console.WriteLine("Unexpected result: " + result.ToString() + " - Expected: " + str);
 418                    return 1;
 419                }
 420
 421                return 0;
 422            }
 423
 424            public static int VerifyNewParms(NewExpression result, ExpressionType et, Type type, ConstructorInfo constructor, string str, Expression[] arguments, params MemberInfo[] members)
 425            {
 426                if (!(result.NodeType == et))
 427                {
 428                    Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
 429                    return 1;
 430                }
 431                if (!(result.Type == type))
 432                {
 433                    Console.WriteLine("Unexpected result type: " + result.Type.ToString());
 434                    return 1;
 435                }
 436
 437                if (!(result.Constructor == constructor))
 438                {
 439                    Console.WriteLine("Unexpected constructor");
 440                    return 1;
 441                }
 442
 443                if (!(result.ToString() == str))
 444                {
 445                    Console.WriteLine("Unexpected result: " + result.ToString() + " - Expected: " + str);
 446                    return 1;
 447                }
 448
 449                if (arguments == null)
 450                {
 451                    if (result.Arguments.Count != 0)
 452                    {
 453                        Console.WriteLine("More than one argument supplied: " + result.Arguments.Count);
 454                        return 1;
 455                    }
 456                }
 457                else
 458                {
 459                    if (result.Arguments.Count != arguments.Length)
 460                    {
 461                        Console.WriteLine("Different number of arguments obtained: " + result.Arguments.Count);
 462                        return 1;
 463                    }
 464                    for (int i = 0; i < arguments.Length; i++)
 465                    {
 466                        if (result.Arguments[i] != arguments[i])
 467                        {
 468                            Console.WriteLine("Argument " + i.ToString() + " is different than expected: Expected " + arguments[i].ToString() + " and got " + result.Arguments[i].ToString());
 469                            return 1;
 470                        }
 471                    }
 472                }
 473
 474                if (result.Members == null)
 475                {
 476                    Console.WriteLine("result.Members was null");
 477                    return 1;
 478                }
 479
 480                if (members == null)
 481                {
 482                    if (result.Members.Count != 0)
 483                    {
 484                        Console.WriteLine("Got more than zero members");
 485                        return 1;
 486                    }
 487                }
 488                else
 489                {
 490                    if (result.Members.Count != members.Length)
 491                    {
 492                        Console.WriteLine("Got an unexpected number of members: " + result.Members.Count);
 493                        return 1;
 494                    }
 495
 496                    for (int i = 0; i < members.Length; i++)
 497                    {
 498                        if (result.Members[i] != members[i])
 499                        {
 500                            Console.WriteLine("Member " + i.ToString() + " is different than expected: Expected " + members[i].ToString() + " and got " + result.Members[i].ToString());
 501                            return 1;
 502                        }
 503                    }
 504                }
 505
 506                return 0;
 507            }
 508
 509            public static int VerifyNewParms(NewExpression result, ExpressionType et, Type type, ConstructorInfo constructor, string str, Expression[] arguments)
 510            {
 511                if (!(result.NodeType == et))
 512                {
 513                    Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
 514                    return 1;
 515                }
 516                if (!(result.Type == type))
 517                {
 518                    Console.WriteLine("Unexpected result type: " + result.Type.ToString());
 519                    return 1;
 520                }
 521
 522                if (!(result.Constructor == constructor))
 523                {
 524                    Console.WriteLine("Constructor is different from expected.");
 525                    return 1;
 526                }
 527
 528                if (!(result.ToString() == str))
 529                {
 530                    Console.WriteLine("Unexpected result: " + result.ToString() + " - Expected: " + str);
 531                    return 1;
 532                }
 533
 534                if (result.Arguments.Count != arguments.Length)
 535                {
 536                    Console.WriteLine("Different number of arguments: " + result.Arguments.Count);
 537                    return 1;
 538                }
 539
 540                for (int i = 0; i < arguments.Length; i++)
 541                {
 542                    if (result.Arguments[i] != arguments[i])
 543                    {
 544                        Console.WriteLine("Argument " + i.ToString() + " is different than expected: Expected " + arguments[i].ToString() + " and got " + result.Arguments[i].ToString());
 545                        return 1;
 546                    }
 547                }
 548
 549                if (result.Members != null)
 550                {
 551                    Console.WriteLine("result.Members isn't null");
 552                    return 1;
 553                }
 554
 555                return 0;
 556            }
 557
 558            public static int VerifyListInitParms(ListInitExpression result, ExpressionType et, Type type, NewExpression newExpression, string str, params ElementInit[] initializers)
 559            {
 560                if (!(result.NodeType == et))
 561                {
 562                    Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
 563                    return 1;
 564                }
 565                if (!(result.Type == type))
 566                {
 567                    Console.WriteLine("Unexpected result type: " + result.Type.ToString());
 568                    return 1;
 569                }
 570
 571                if (!(result.NewExpression == newExpression)) return 1;
 572
 573                if (!(result.ToString() == str))
 574                {
 575                    Console.WriteLine("Unexpected result: " + result.ToString() + " - Expected: " + str);
 576                    return 1;
 577                }
 578
 579                if (result.Initializers.Count != initializers.Length) return 1;
 580
 581                for (int i = 0; i < initializers.Length; i++)
 582                {
 583                    if (result.Initializers[i].AddMethod != initializers[i].AddMethod) return 1;
 584
 585                    if (result.Initializers[i].Arguments.Count != initializers[i].Arguments.Count) return 1;
 586
 587                    for (int j = 0; j < result.Initializers[i].Arguments.Count; j++)
 588                    {
 589                        if (result.Initializers[i].Arguments[j] != initializers[i].Arguments[j]) return 1;
 590                    }
 591                }
 592
 593                return 0;
 594            }
 595
 596            public static int VerifyElementInitParms(ElementInit result, MethodInfo exp_mi, string str, params Expression[] args)
 597            {
 598                if (result.AddMethod != exp_mi) return 1;
 599                if (!(result.ToString() == str))
 600                {
 601                    Console.WriteLine("Unexpected result: " + result.ToString() + " - Expected: " + str);
 602                    return 1;
 603                }
 604
 605                if (result.Arguments.Count != args.Length) return 1;
 606
 607                for (int i = 0; i < args.Length; i++)
 608                {
 609                    if (result.Arguments[i] != args[i]) return 1;
 610                }
 611
 612                return 0;
 613            }
 614
 615            public static int VerifyMemberAssignmentParms(MemberAssignment result, MemberBindingType bt, Expression expr, MemberInfo member, string str)
 616            {
 617                if (!(result.BindingType == bt)) return 1;
 618                if (!(result.Expression == expr)) return 1;
 619                if (!(result.Member.Equals(member))) return 1;
 620                if (!(result.ToString() == str))
 621                {
 622                    Console.WriteLine("Unexpected result: " + result.ToString() + " - Expected: " + str);
 623                    return 1;
 624                }
 625
 626                return 0;
 627            }
 628
 629            public static int VerifyMemberListBindParms(MemberListBinding result, MemberBindingType bt, ElementInit[] initializers, MemberInfo member, string str)
 630            {
 631                if (!(result.BindingType == bt)) return 1;
 632
 633                if (!(result.Member.Equals(member))) return 1;
 634                if (!(result.ToString() == str))
 635                {
 636                    Console.WriteLine("Unexpected result: " + result.ToString() + " - Expected: " + str);
 637                    return 1;
 638                }
 639
 640                if (result.Initializers.Count != initializers.Length) return 1;
 641
 642                for (int i = 0; i < initializers.Length; i++)
 643                {
 644                    if (result.Initializers[i].AddMethod != initializers[i].AddMethod) return 1;
 645
 646                    if (result.Initializers[i].Arguments.Count != initializers[i].Arguments.Count) return 1;
 647
 648                    for (int j = 0; j < result.Initializers[i].Arguments.Count; j++)
 649                    {
 650                        if (result.Initializers[i].Arguments[j] != initializers[i].Arguments[j]) return 1;
 651                    }
 652                }
 653
 654
 655                return 0;
 656            }
 657
 658            public static int VerifyMemberMemberBindParms(MemberMemberBinding result, MemberBindingType bt, MemberBinding[] bindings, MemberInfo member, string str)
 659            {
 660                if (!(result.BindingType == bt)) return 1;
 661
 662                if (!(result.Member.Equals(member))) return 1;
 663                if (!(result.ToString() == str))
 664                {
 665                    Console.WriteLine("Unexpected result: " + result.ToString() + " - Expected: " + str);
 666                    return 1;
 667                }
 668
 669                if (result.Bindings.Count != bindings.Length) return 1;
 670
 671                for (int i = 0; i < bindings.Length; i++)
 672                {
 673                    if (!(result.Bindings[i].Equals(bindings[i]))) return 1;
 674                }
 675
 676                return 0;
 677            }
 678
 679            public static int VerifyMemberInitParms(MemberInitExpression result, ExpressionType et, Type type, NewExpression newExpr, MemberBinding[] bindings, string str)
 680            {
 681                if (!(result.NodeType == et))
 682                {
 683                    Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
 684                    return 1;
 685                }
 686                if (!(result.Type == type))
 687                {
 688                    Console.WriteLine("Unexpected result type: " + result.Type.ToString());
 689                    return 1;
 690                }
 691                if (!(result.NewExpression.Equals(newExpr))) return 1;
 692                if (!(result.ToString() == str)) return 1;
 693
 694                if (result.Bindings.Count != bindings.Length) return 1;
 695
 696                for (int i = 0; i < bindings.Length; i++)
 697                {
 698                    if (!(result.Bindings[i].Equals(bindings[i]))) return 1;
 699                }
 700
 701                return 0;
 702            }
 703
 704            public static int VerifyNewArrayParms(NewArrayExpression result, ExpressionType et, Type type, Expression[] expr, string str)
 705            {
 706                if (!(result.NodeType == et))
 707                {
 708                    Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
 709                    return 1;
 710                }
 711                if (!(result.Type == type))
 712                {
 713                    Console.WriteLine("Unexpected result type: " + result.Type.ToString());
 714                    return 1;
 715                }
 716
 717                if (result.Expressions.Count != expr.Length) return 1;
 718
 719                for (int i = 0; i < expr.Length; i++)
 720                {
 721                    if (!(result.Expressions[i].Equals(expr[i]))) return 1;
 722                }
 723                if (!(result.ToString() == str))
 724                {
 725                    Console.WriteLine("Unexpected result: " + result.ToString() + " - Expected: " + str);
 726                    return 1;
 727                }
 728
 729                return 0;
 730            }
 731
 732            public static int VerifyParameterParms(ParameterExpression result, ExpressionType et, Type type, string name, string str)
 733            {
 734                if (!(result.NodeType == et))
 735                {
 736                    Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
 737                    return 1;
 738                }
 739                if (!(result.Type == type))
 740                {
 741                    Console.WriteLine("Unexpected result type: " + result.Type.ToString());
 742                    return 1;
 743                }
 744                if (!(result.Name == name)) return 1;
 745
 746                if (!(result.ToString() == str))
 747                {
 748                    Console.WriteLine("Unexpected result: " + result.ToString() + " - Expected: " + str);
 749                    return 1;
 750                }
 751
 752                return 0;
 753            }
 754
 755            public static int VerifyLambdaParms(LambdaExpression result, ExpressionType et, Type type, Expression expr, ParameterExpression[] parms, string str)
 756            {
 757                if (!(result.NodeType == et))
 758                {
 759                    Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
 760                    return 1;
 761                }
 762                if (!(result.Type == type))
 763                {
 764                    Console.WriteLine("Unexpected result type: " + result.Type.ToString());
 765                    return 1;
 766                }
 767
 768                if (expr == null)
 769                {
 770                    if (result.Body != null) return 1;
 771                }
 772                else
 773                {
 774                    if (!(result.Body.Equals(expr))) return 1;
 775                }
 776
 777                if (result.Parameters.Count != parms.Length) return 1;
 778
 779                for (int i = 0; i < parms.Length; i++)
 780                {
 781                    if (!(result.Parameters[i].Equals(parms[i]))) return 1;
 782                }
 783
 784                if (!(result.ToString() == str))
 785                {
 786                    Console.WriteLine("Unexpected result: " + result.ToString() + " - Expected: " + str);
 787                    return 1;
 788                }
 789
 790                return 0;
 791            }
 792
 793            public static int VerifyInvokeParms(InvocationExpression result, ExpressionType et, Type type, Expression expr, Expression[] args, string str)
 794            {
 795                if (!(result.NodeType == et))
 796                {
 797                    Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
 798                    return 1;
 799                }
 800                if (!(result.Type == type))
 801                {
 802                    Console.WriteLine("Unexpected result type: " + result.Type.ToString());
 803                    return 1;
 804                }
 805
 806                if (expr == null)
 807                {
 808                    if (result.Expression != null) return 1;
 809                }
 810                else
 811                {
 812                    if (!(result.Expression.Equals(expr))) return 1;
 813                }
 814
 815                if (result.Arguments.Count != args.Length) return 1;
 816
 817                for (int i = 0; i < args.Length; i++)
 818                {
 819                    if (!(result.Arguments[i].Equals(args[i])))
 820                    {
 821                        return 1;
 822                    }
 823                }
 824
 825                if (result.ToString() != str)
 826                {
 827                    Console.WriteLine("Expected: " + str + " Actual: " + result.ToString());
 828                    return 1;
 829                }
 830
 831                return 0;
 832            }
 833        }
 834
 835
 836    }
 837
 838    //-------- Scenario 783
 839    namespace Scenario783
 840    {
 841
 842        namespace Not
 843        {
 844            public class Test
 845            {
 846                // Test for functionality: Argument is of type integer
 847                public static int Test2()
 848                {
 849                    ConstantExpression ce = Expression.Constant(10);
 850                    Type exp_type = ce.Type;
 851                    ExpressionType exp_et = ExpressionType.Not;
 852                    string exp_str = "Not(" + ce.ToString() + ")";
 853                    Expression exp_operand = ce;
 854
 855                    UnaryExpression result = Expression.Not(ce);
 856
 857                    return Verification.VerifyUnaryParms(result, exp_et, exp_type, exp_operand, exp_str, null, false, false);
 858                }
 859
 860
 861                [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "Not2__", new string[] { "positive", "cslinq", "FullTrustOnly", "Pri1" })]
 862                public static Expression Not2__()
 863                {
 864                    if (Main() != 0)
 865                    {
 866                        throw new Exception();
 867                    }
 868                    else
 869                    {
 870                        return Expression.Constant(0);
 871                    }
 872                }
 873                public static int Main()
 874                {
 875                    return Test2();
 876                }
 877            }
 878        }
 879
 880
 881        public static class Extension
 882        {
 883            public static bool CompareParamName(this ArgumentException ex, string expected)
 884            {
 885#if SILVERLIGHT
 886#if SLRESOURCES
 887			        return ex.Message.Substring(ex.Message.LastIndexOf(": ") + 2) == expected;
 888#else
 889			        return true;
 890#endif
 891#else
 892                return ex.ParamName == expected;
 893#endif
 894            }
 895
 896            public static bool CompareParamName(this ArgumentNullException ex, string expected)
 897            {
 898#if SILVERLIGHT
 899#if SLRESOURCES
 900			        return ex.Message.Substring(ex.Message.LastIndexOf(": ") + 2) == expected;
 901#else
 902			        return true;
 903#endif
 904#else
 905                return ex.ParamName == expected;
 906#endif
 907            }
 908        }
 909
 910        public static class Verification
 911        {
 912            public static int VerifyConstParms(ConstantExpression result, ExpressionType et, Type type, object val, string str)
 913            {
 914                if (!(result.NodeType == et))
 915                {
 916                    Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
 917                    return 1;
 918                }
 919                if (!(result.Type == type))
 920                {
 921                    Console.WriteLine("Unexpected result type: " + result.Type.ToString());
 922                    return 1;
 923                }
 924                if (val == null)
 925                {
 926                    if (result.Value != null) return 1;
 927                }
 928                else
 929                {
 930                    if (!(result.Value.Equals(val))) return 1;
 931                }
 932                if (!(result.ToString() == str)) return 1;
 933                return 0;
 934            }
 935
 936            public static int VerifyUnaryParms(UnaryExpression result, ExpressionType et, Type type, Expression operand, string str, MethodInfo mi, bool islifted, bool isliftedtonull)
 937            {
 938                if (!(result.NodeType == et))
 939                {
 940                    Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
 941                    return 1;
 942                }
 943                if (!(result.Type == type))
 944                {
 945                    Console.WriteLine("Unexpected result type: " + result.Type.ToString());
 946                    return 1;
 947                }
 948                if (operand == null)
 949                {
 950                    if (result.Operand != null) return 1;
 951                }
 952                else
 953                {
 954                    if (!(result.Operand.Equals(operand))) return 1;
 955                }
 956                if (!(result.ToString() == str))
 957                {
 958                    Console.WriteLine("Expected: " + str + " Actual: " + result.ToString());
 959                    return 1;
 960                }
 961
 962                if (result.Method != mi) return 1;
 963                if (result.IsLifted != islifted) return 1;
 964                if (result.IsLiftedToNull != isliftedtonull) return 1;
 965
 966                return 0;
 967            }
 968
 969            public static int VerifyBinaryParms(BinaryExpression result, ExpressionType et, Type type, Expression left, Expression right, string str, MethodInfo mi, bool islifted, bool isliftedtonull)
 970            {
 971                if (!(result.NodeType == et))
 972                {
 973                    Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
 974                    return 1;
 975                }
 976                if (!(result.Type == type))
 977                {
 978                    Console.WriteLine("Unexpected result type: " + result.Type.ToString());
 979                    return 1;
 980                }
 981
 982                if (left == null)
 983                {
 984                    if (result.Left != null)
 985                    {
 986                        Console.WriteLine("left was null");
 987                        return 1;
 988                    }
 989                }
 990                else
 991                {
 992                    if (!(result.Left.Equals(left)))
 993                    {
 994                        Console.WriteLine("left was different");
 995                        return 1;
 996                    }
 997                }
 998
 999                if (right == null)
1000                {
1001                    if (result.Right != null) return 1;
1002                }
1003                else
1004                {
1005                    if (!(result.Right.Equals(right))) return 1;
1006                }
1007
1008                if (!(result.ToString() == str))
1009                {
1010                    Console.WriteLine("Expected: " + str + " Actual: " + result.ToString());
1011                    return 1;
1012                }
1013
1014                if (result.Method != mi) return 1;
1015                if (result.IsLifted != islifted) return 1;
1016                if (result.IsLiftedToNull != isliftedtonull) return 1;
1017
1018                if (result.Conversion != null) return 1;
1019
1020                return 0;
1021            }
1022
1023            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)
1024            {
1025                if (!(result.NodeType == et))
1026                {
1027                    Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
1028                    return 1;
1029                }
1030                if (!(result.Type == type))
1031                {
1032                    Console.WriteLine("Unexpected result type: " + result.Type.ToString());
1033                    return 1;
1034                }
1035
1036                if (left == null)
1037                {
1038                    if (result.Left != null) return 1;
1039                }
1040                else
1041                {
1042                    if (!(result.Left.Equals(left))) return 1;
1043                }
1044
1045                if (right == null)
1046                {
1047                    if (result.Right != null) return 1;
1048                }
1049                else
1050                {
1051                    if (!(result.Right.Equals(right))) return 1;
1052                }
1053
1054                if (!(result.ToString() == str)) return 1;
1055
1056                if (result.Method != mi) return 1;
1057                if (result.IsLifted != islifted) return 1;
1058                if (result.IsLiftedToNull != isliftedtonull) return 1;
1059
1060                if (result.Conversion.ToString() != conv_expr.ToString()) return 1;
1061
1062                return 0;
1063            }
1064
1065            public static int VerifyMethodCallParms(MethodCallExpression result, ExpressionType et, Type type, MethodInfo method, Expression obj, string str, params Expression[] arguments)
1066            {
1067                if (!(result.NodeType == et))
1068                {
1069                    Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
1070                    return 1;
1071                }
1072                if (!(result.Type == type))
1073                {
1074                    Console.WriteLine("Unexpected result type: " + result.Type.ToString());
1075                    return 1;
1076                }
1077
1078                if (!(result.Method == method)) return 1;
1079
1080                if (obj == null)
1081                {
1082                    if (result.Object != null)
1083                    {
1084                        Console.WriteLine("Expected object to be null.");
1085                        return 1;
1086                    }
1087                }
1088                else
1089                {
1090                    if (!(result.Object.Equals(obj)))
1091                    {
1092                        Console.WriteLine("Object on which call is made is different from the result.");
1093                        return 1;
1094                    }
1095                }
1096
1097                if (!(result.ToString() == str))
1098                {
1099                    Console.WriteLine("Expected: " + str + " Actual: " + result.ToString());
1100                    return 1;
1101                }
1102
1103                if (result.Arguments.Count != arguments.Length) return 1;
1104
1105                for (int i = 0; i < arguments.Length; i++)
1106                {
1107                    if (result.Arguments[i] != arguments[i]) return 1;
1108                }
1109
1110                return 0;
1111            }
1112
1113            public static int VerifyTypeBinaryParms(TypeBinaryExpression result, ExpressionType et, Type type, Expression expr, Type typeop, string str)
1114            {
1115                if (!(result.NodeType == et))
1116                {
1117                    Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
1118                    return 1;
1119                }
1120                if (!(result.Type == type))
1121                {
1122                    Console.WriteLine("Unexpected result type: " + result.Type.ToString());
1123                    return 1;
1124                }
1125
1126                if (expr == null)
1127                {
1128                    Console.WriteLine("expr was null.");
1129                    if (result.Expression != null) return 1;
1130                }
1131                else
1132                {
1133                    if (!(result.Expression.Equals(expr)))
1134                    {
1135                        return 1;
1136                    }
1137                }
1138
1139                if (!(result.TypeOperand == typeop)) return 1;
1140
1141                if (!(result.ToString() == str))
1142                {
1143                    Console.WriteLine("Expected: " + str + " Actual: " + result.ToString());
1144                    return 1;
1145                }
1146
1147                return 0;
1148            }
1149
1150            public static int VerifyConditionalParms(ConditionalExpression result, ExpressionType et, Type type, Expression test, Expression ifTrue, Expression ifFalse, string str)
1151            {
1152                if (!(result.NodeType == et))
1153                {
1154                    Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
1155                    return 1;
1156                }
1157                if (!(result.Type == type))
1158                {
1159                    Console.WriteLine("Unexpected result type: " + result.Type.ToString());
1160                    return 1;
1161                }
1162
1163                if (test == null)
1164                {
1165                    if (result.Test != null) return 1;
1166                }
1167                else
1168                {
1169                    if (!(result.Test.Equals(test))) return 1;
1170                }
1171
1172                if (ifTrue == null)
1173                {
1174                    if (result.IfTrue != null) return 1;
1175                }
1176                else
1177                {
1178                    if (!(result.IfTrue.Equals(ifTrue))) return 1;
1179                }
1180
1181                if (ifFalse == null)
1182                {
1183                    if (result.IfFalse != null) return 1;
1184                }
1185                else
1186                {
1187                    if (!(result.IfFalse.Equals(ifFalse))) return 1;
1188                }
1189
1190                if (!(result.ToString() == str)) return 1;
1191
1192                return 0;
1193            }
1194
1195            public static int VerifyMemberParms(MemberExpression result, ExpressionType et, Type type, Expression exp_expr, MemberInfo exp_member, string str)
1196            {
1197                if (!(result.NodeType == et))
1198                {
1199                    Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
1200                    return 1;
1201                }
1202                if (!(result.Type == type))
1203                {
1204                    Console.WriteLine("Unexpected result type: " + result.Type.ToString());
1205                    return 1;
1206                }
1207
1208                if (exp_expr == null)
1209                {
1210                    if (result.Expression != null)
1211                    {
1212                        Console.WriteLine("Expression is not null: " + result.Expression.ToString());
1213                        return 1;
1214                    }
1215                }
1216                else
1217                {
1218                    if (!(result.Expression.Equals(exp_expr)))
1219                    {
1220                        Console.WriteLine("Unexpected Expression: " + result.Expression.ToString());
1221                        return 1;
1222                    }
1223                }
1224
1225                if (!(result.Member == exp_member))
1226                {
1227                    Console.WriteLine("Unexpected result member: " + result.Member.ToString());
1228                    return 1;
1229                }
1230
1231                if (!(result.ToString() == str))
1232                {
1233                    Console.WriteLine("Unexpected result: " + result.ToString() + " - Expected: " + str);
1234                    return 1;
1235                }
1236
1237                return 0;
1238            }
1239
1240            public static int VerifyNewParms(NewExpression result, ExpressionType et, Type type, ConstructorInfo constructor, string str, Expression[] arguments, params MemberInfo[] members)
1241            {
1242                if (!(result.NodeType == et))
1243                {
1244                    Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
1245                    return 1;
1246                }
1247                if (!(result.Type == type))
1248                {
1249                    Console.WriteLine("Unexpected result type: " + result.Type.ToString());
1250                    return 1;
1251                }
1252
1253                if (!(result.Constructor == constructor))
1254                {
1255                    Console.WriteLine("Unexpected constructor");
1256                    return 1;
1257                }
1258
1259                if (!(result.ToString() == str))
1260                {
1261                    Console.WriteLine("Unexpected result: " + result.ToString() + " - Expected: " + str);
1262                    return 1;
1263                }
1264
1265                if (arguments == null)
1266                {
1267                    if (result.Arguments.Count != 0)
1268                    {
1269                        Console.WriteLine("More than one argument supplied: " + result.Arguments.Count);
1270                        return 1;
1271                    }
1272                }
1273                else
1274                {
1275                    if (result.Arguments.Count != arguments.Length)
1276                    {
1277                        Console.WriteLine("Different number of arguments obtained: " + result.Arguments.Count);
1278                        return 1;
1279                    }
1280                    for (int i = 0; i < arguments.Length; i++)
1281                    {
1282                        if (result.Arguments[i] != arguments[i])
1283                        {
1284                            Console.WriteLine("Argument " + i.ToString() + " is different than expected: Expected " + arguments[i].ToString() + " and got " + result.Arguments[i].ToString());
1285                            return 1;
1286                        }
1287                    }
1288                }
1289
1290                if (result.Members == null)
1291                {
1292                    Console.WriteLine("result.Members was null");
1293                    return 1;
1294                }
1295
1296                if (members == null)
1297                {
1298                    if (result.Members.Count != 0)
1299                    {
1300                        Console.WriteLine("Got more than zero members");
1301                        return 1;
1302                    }
1303                }
1304                else
1305                {
1306                    if (result.Members.Count != members.Length)
1307                    {
1308                        Console.WriteLine("Got an unexpected number of members: " + result.Members.Count);
1309                        return 1;
1310                    }
1311
1312                    for (int i = 0; i < members.Length; i++)
1313                    {
1314                        if (result.Members[i] != members[i])
1315                        {
1316                            Console.WriteLine("Member " + i.ToString() + " is different than expected: Expected " + members[i].ToString() + " and got " + result.Members[i].ToString());
1317                            return 1;
1318                        }
1319                    }
1320                }
1321
1322                return 0;
1323            }
1324
1325            public static int VerifyNewParms(NewExpression result, ExpressionType et, Type type, ConstructorInfo constructor, string str, Expression[] arguments)
1326            {
1327                if (!(result.NodeType == et))
1328                {
1329                    Console.WriteLine("Unexpected result node type: " + result.NodeType.ToString());
1330                    return 1;
1331                }
1332                if (!(result.Type == type))
1333                {
1334                    Console.WriteLine("Unexpected result type: " + result.Type.ToString());
1335                    return 1;
1336                }
1337
1338                if (!(result.Constructor == constructor))
1339                {
1340                    Console.WriteLine("Constructor is different from expected.");
1341                    return 1;
1342                }
1343
1344                if (!(result.ToString() == str))
1345                {
1346                    Console.WriteLine("Unexpected result: " + result.ToString() + " - Expected: " + str);
1347                    return 1;
1348                }
1349
1350                if (result.Arguments.Count != arguments.Length)
1351                {
1352                    Console.WriteLine("Different number of arguments: " + result.Arguments.Count);
1353                    return 1;
1354                }
1355
1356                for (int i = 0; i < arguments.Length; i++)
1357                {
1358 

Large files files are truncated, but you can click here to view the full file