Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mcs / tests / test-anon-19.cs
1 //
2 // Tests capturing of double nested variables
3 //
4 using System;
5
6 delegate void S ();
7
8 class X {
9         public static int Main ()
10         {
11                 int i;
12                 int a = 0;
13                 S b = null;
14                 
15                 for (i = 0; i < 10; i++){
16                         int j = 0;
17                         b = delegate {
18                                 Console.WriteLine ("i={0} j={1}", i, j);
19                                 i = i + 1;
20                                 j = j + 1;
21                                 a = j;
22                         };
23                 }
24                 b ();
25                 Console.WriteLine ("i = {0}", i);
26                 if (!t (i, 11))
27                         return 1;
28                 b ();
29                 if (!t (i, 12))
30                         return 2;
31                 Console.WriteLine ("i = {0}", i);
32                 Console.WriteLine ("a = {0}", a);
33                 if (!t (a, 2))
34                         return 3;
35                 
36                 return 0;
37         }
38
39         static bool t (int a, int b)
40         {
41                 return a == b;
42         }
43 }