add failing test for bnc550722
[mcs.git] / tests / gtest-linq-01.cs
blob384191a0c93e2c995e2bda0456a35c30843e444f
3 using System;
4 using System.Collections.Generic;
5 using System.Linq;
7 namespace from
9 interface ITest
11 int Id { get; }
14 class C
16 // This is pure grammar test
17 public static void Main ()
19 int[] i2 = new int [] { 0, 1 };
20 int[] i_b = new int [] { 0, 1 };
21 ITest[] join_test = new ITest[0];
23 IEnumerable<int> e;
24 IEnumerable<IGrouping<int,int>> g;
26 // FROM
27 e = from i in i2 select i;
28 e = from int i in i2 select i;
29 var e2 = from bool? i in i2 select i;
30 e = from i in new int[0] select i;
31 e = from x in i2 from y in i2 select y;
33 // WHERE
34 e = from i in i2 where i % 3 != 0 select i;
36 // ORDER BY
37 e = from i in i2 orderby i select i;
38 e = from i in i2 orderby i, i, i, i select i;
39 e = from i in i2 orderby i descending select i;
40 e = from i in i2 orderby i ascending select i;
42 // JOIN
43 e = from i in i2 join j in join_test on i equals j.Id select i;
44 e = from i in i2 join ITest j in join_test on i equals j.Id select i;
45 e = from i in i2 join j in join_test on i equals j.Id
46 join j2 in join_test on i equals j2.Id select i;
47 e = from i in i2 join j in i_b on i equals j into j select i;
48 e = from i in i2 join int j in i_b on i equals j into j select i;
50 // GROUP BY
51 g = from i in i2 group i by 2;
52 g = from i in i2 group i by 2 into i select i;
54 // LET
55 e = from i in i2 let l = i + 4 select i;
56 e = from i in i2 let l = i + 4 let l2 = l + 2 select i;
58 // INTO
59 g = from i in i2 group i by 2 into i9
60 from i in i2 group i by 2 into i9
61 from i in i2 group i by 2 into i9
62 from i in i2 group i by 2 into i9
63 select i9;
65 // NESTED
66 var e3 = from a in
67 from b in i2
68 select b
69 orderby a
70 select a;
72 var e4 = from i in
73 from x in i2
74 select x
75 let l = from x2 in i2 select x2
76 let l2 = 50
77 select 1;
79 int from = 0;
80 bool let = false;
82 // TODO: Re-enable when we fix cast of query expression
83 //object o = (object)from i in i2 select i;
86 void Foo (int from, bool where)
88 int Foo = 0;
89 if (from < Foo) // This tests generics micro-parser awareness
90 return;
93 int foo;
94 void Do (string[] args)
96 int from = this.foo;
97 Console.WriteLine (args [from]);
101 class D
103 public bool check (object from, object to)
105 if (from is int && to is int) return true;
106 return false;