2004-12-06 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mcs / tests / a-capture2.cs
1 //
2 // This test checks various uses of captured local variables
3 //
4 delegate void S ();
5 using System;
6
7 class X {
8         static int Main ()
9         {
10                 int a = 1;
11                 Console.WriteLine ("A is = " + a);
12                 int c = a;
13                 Console.WriteLine (c);
14                 if (a != 1){
15                         return 1;
16                 }
17                 
18                 S b = delegate {
19                         if (a != 1)
20                                 Environment.Exit (1);
21                         Console.WriteLine ("in Delegate");
22                         a = 2;
23                         if (a != 2)
24                                 Environment.Exit (2);
25                         Console.WriteLine ("Inside = " + a);
26                         a = 3;
27                         Console.WriteLine ("After = " + a);
28                 };
29                 if (a != 1)
30                         return 3;
31                 b ();
32                 if (a != 3)
33                         return 4;
34                 Console.WriteLine ("Back, got " + a);
35                 Console.WriteLine ("Test is ok");
36                 return 0;
37         }
38 }