2 using System
.Linq
.Expressions
;
3 using System
.Collections
;
4 using System
.Collections
.Generic
;
8 static void AssertNodeType (LambdaExpression e
, ExpressionType et
)
10 if (e
.Body
.NodeType
!= et
)
11 throw new ApplicationException (e
.Body
.NodeType
+ " != " + et
);
14 static void Assert
<T
> (T expected
, T
value)
16 if (!EqualityComparer
<T
>.Default
.Equals (expected
, value)) {
17 throw new ApplicationException (expected
+ " != " + value);
23 // It also tests constant boxing
24 Expression
<Func
<ArrayList
>> e1
= () => new ArrayList { null, "Hello", "World", 5 }
;
25 AssertNodeType (e1
, ExpressionType
.ListInit
);
26 /* Verification exception on .NET */
27 var re1
= e1
.Compile ().Invoke ();
29 Assert (null, re1
[0]);
30 Assert ("Hello", re1
[1]);
31 Assert ("World", re1
[2]);
34 Console
.WriteLine ("OK");