dlr bug
[mcs.git] / tests / gtest-etree-05.cs
blob2045e07d99fd5d86f6619e3e59f9ff69deaac463
1 using System;
2 using System.Linq.Expressions;
3 using System.Collections;
4 using System.Collections.Generic;
6 class C
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);
21 static int Main()
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]);
32 Assert (5, re1 [3]);
34 Console.WriteLine ("OK");
35 return 0;