2007-05-25 Jonathan Chambers <joncham@gmail.com>
[mcs.git] / tests / test-469.cs
blob9e22abaa27339990a9eeafe65e146f826593e136
1 //
2 // Do not extend this test
3 //
4 // This test copes with the case where a parameter was already captured
5 // and a second anonymous method on the same scope captured a parameter
6 //
7 using System;
9 delegate void Del (int n);
11 class Lambda {
13 static int v;
15 static void f (int va)
17 v = va;
20 static Del[] Make2 (int x) {
21 return new Del[] {
22 delegate (int a) { f(x += a); },
23 delegate (int b) { f(x += b); }
27 static int Main () {
28 Del[] d = Make2(10);
29 d[0](10);
30 if (v != 20)
31 return 1;
33 d[1](11);
34 if (v != 31)
35 return 2;
36 Console.WriteLine ("OK");
37 return 0;