[mono/tests] Fix out of tree build.
[mono-project.git] / mcs / tests / gtest-etree-27.cs
blobe413be7ea8c898bc6acb1c41d28ddf4859dd6f2b
1 using System;
2 using System.Linq.Expressions;
3 using System.Collections.Generic;
5 public class Node
7 Node parent;
9 public Node ()
11 Values = new List<int> ();
14 public string Name { get; set; }
16 public Node Parent {
17 get {
18 return parent ?? new Node ();
20 set {
21 parent = value;
25 public List<int> Values { get; set; }
27 public static int Main ()
29 Expression<Func<Node>> e = () => new Node () { Parent = { Name = "Parent" } };
30 var mie = (MemberInitExpression) e.Body;
31 if (mie.Bindings[0].BindingType != MemberBindingType.MemberBinding)
32 return 1;
34 e.Compile () ();
36 e = () => new Node () { Values = { 1, 2, 3 } };
37 mie = (MemberInitExpression) e.Body;
38 if (mie.Bindings[0].BindingType != MemberBindingType.ListBinding)
39 return 2;
41 e.Compile () ();
43 e = () => new Node () { Parent = null };
44 mie = (MemberInitExpression) e.Body;
45 if (mie.Bindings[0].BindingType != MemberBindingType.Assignment)
46 return 3;
48 e.Compile () ();
50 e = () => new Node () { Values = { } };
51 mie = (MemberInitExpression) e.Body;
52 if (mie.Bindings[0].BindingType != MemberBindingType.MemberBinding)
53 return 4;
55 e.Compile () ();
57 e = () => new Node() { Parent = { Name = "Parent" }, Values = { 4, 5, 7, 8 } };
58 mie = (MemberInitExpression) e.Body;
59 if (mie.Bindings[0].BindingType != MemberBindingType.MemberBinding)
60 return 5;
62 if (mie.Bindings[1].BindingType != MemberBindingType.ListBinding)
63 return 6;
65 e.Compile () ();
66 Console.WriteLine ("ok");
67 return 0;