codeowners update
[mono.git] / mcs / tests / gtest-etree-05.cs
1 using System;
2 using System.Linq.Expressions;
3 using System.Collections;
4 using System.Collections.Generic;
5
6 class C
7 {
8         static void AssertNodeType (LambdaExpression e, ExpressionType et)
9         {
10                 if (e.Body.NodeType != et)
11                         throw new ApplicationException (e.Body.NodeType + " != " + et);
12         }
13
14         static void Assert<T> (T expected, T value)
15         {
16                 if (!EqualityComparer<T>.Default.Equals (expected, value)) {
17                         throw new ApplicationException (expected + " != " + value);
18                 }
19         }
20         
21         public static int Main()
22         {
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 ();
28                 
29                 Assert (null, re1 [0]);
30                 Assert ("Hello", re1 [1]);
31                 Assert ("World", re1 [2]);
32                 Assert (5, re1 [3]);
33                 
34                 Console.WriteLine ("OK");
35                 return 0;
36         }
37 }