2007-10-17 Jonathan Pobst <monkey@jpobst.com>
[mono.git] / mcs / tests / gtest-anontype-05.cs
1 // Compiler options: -langversion:linq
2 // Tests anonymous type consolidation
3
4 using System;
5 using System.Collections;
6
7 public class Test
8 {
9         static string Null ()
10         {
11                 return null;
12         }
13         
14         static int Main ()
15         {
16                 var v1 = new { Name = "Scott", Age = 21 };
17                 var v2 = new { Age = 20, Name = "Sam" };
18                 var v3 = new { Name = Null (), Age = 33 };
19                 
20                 if (v1.GetType () == v2.GetType ())
21                         return 1;
22                         
23                 if (v1.Equals (v2))
24                         return 2;
25                         
26                 if (v1.GetType () != v3.GetType ())
27                         return 3;
28                         
29                 if (!v1.Equals (v1))
30                         return 4;
31                                         
32                 if (v1.GetHashCode () != v1.GetHashCode ())
33                         return 5;
34                 
35                 Console.WriteLine (v1);
36                 Console.WriteLine (v3);
37                 
38                 if (v1.ToString () != "Name = Scott, Age = 21")
39                         return 6;
40                         
41                 if (v3.ToString () != "Name = <null>, Age = 33")
42                         return 7;
43                 
44                 return 0;
45         }
46 }