rename jgac/vmw4j2ee_110 to jcag/framework
[mono.git] / mcs / tests / gtest-linq-01.cs
1 // Compiler options: -langversion:linq
2
3 using System;
4 using System.Collections.Generic;
5 using System.Linq;
6
7 namespace from
8 {
9         interface ITest
10         {
11                 int Id { get; }
12         }
13
14         class C
15         {
16                 // This is pure grammar test
17                 public static void Main ()
18                 {
19                         int[] i2 = new int [] { 0, 1 };
20                         int[] i_b = new int [] { 0, 1 };
21                         ITest[] join_test = null;
22                         
23                         IEnumerable<int> e;
24                         IEnumerable<IGrouping<int,int>> g;
25
26                         // FROM
27                         e = from i in i2 select i;
28                         e = from int i in i2 select i;
29                         e = from i in new int[0] select i;
30                         e = from x in i2 from y in i2 select y;
31
32                         // WHERE
33                         e = from i in i2 where i % 3 != 0 select i;
34
35                         // ORDER BY
36                         e = from i in i2 orderby i select i;
37                         e = from i in i2 orderby i, i, i, i select i;
38                         e = from i in i2 orderby i descending select i;
39                         e = from i in i2 orderby i ascending select i;
40                         
41                         // JOIN
42                         e = from i in i2 join j in join_test on i equals j.Id select i;
43                         e = from i in i2 join ITest j in join_test on i equals j.Id select i;
44                         e = from i in i2 join j in join_test on i equals j.Id
45                                 join j2 in join_test on i equals j2.Id select i;
46                         e = from i in i2 join j in i_b on i equals j into j select i;
47                         e = from i in i2 join int j in i_b on i equals j into j select i;
48
49                         // GROUP BY
50                         g = from i in i2 group i by 2;
51                         g = from i in i2 group i by 2 into i select i;
52
53                         // LET
54                         e = from i in i2 let l = i + 4 select i;
55                         e = from i in i2 let l = i + 4 let l2 = l + 2 select i;
56
57                         int from = 0;
58                         bool let = false;
59                         
60                         //object o = (object)from i in i2 select i;
61                 }
62         }
63 }