1 // Compiler options: -langversion:linq
3 // Lambda expression test, basics.
7 delegate int IntFunc (int x);
8 delegate void VoidFunc (int x);
12 static IntFunc func, increment;
13 static VoidFunc nothing;
21 // The following tests body-style lambda
23 increment = (int x) => { return x + 1; };
25 Console.WriteLine ("Should be 5={0}", r);
30 // This tests the body of a lambda being an expression
32 func = (int x) => x + 1;
34 Console.WriteLine ("Should be 11={0}", r);
39 // The following tests that the body is a statement
41 nothing = (int x) => { y = x; };
43 Console.WriteLine ("Should be 10={0}", y);
47 nothing = (int x) => { new X (x); };
49 if (instantiated_value != 314)
52 Console.WriteLine ("All tests pass");
56 static int instantiated_value;
60 instantiated_value = v;