Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mcs / tests / gtest-linq-08.cs
1
2
3 using System;
4
5 class TestA
6 {
7         public string value;
8         
9         public TestA (string value)
10         {
11                 this.value = value;
12         }
13         
14         public string Select<U> (Func<TestA, U> f)
15         {
16                 return value;
17         }
18 }
19
20 static class TestB
21 {
22         static public TestA Where(this TestA a, Func<TestA,bool> predicate)
23         {
24                 if (predicate (a))
25                         return new TestA ("where used");
26                 
27                 return null;
28         }
29 }
30
31 public class CustomQueryExpressionPattern
32 {
33         public static int Main ()
34         {
35                 var v = new TestA ("Oh yes");
36                 string foo = from a in v select a;
37                 if (foo != "Oh yes")
38                         return 1;
39                 
40                 v = new TestA ("where?");
41                 
42                 // It also tests that select is not called in this case
43                 v = from a in v where a.value != "wrong" select a;
44                 
45                 if (v.value != "where used")
46                         return 1;
47                 
48                 Console.WriteLine (v.value.ToString ());
49                 return 0;
50         }
51 }