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