2004-12-25 Ben Maurer <bmaurer@ximian.com>
[mono-project.git] / mcs / tests / a-capture2.cs
blob54d93deb354eef957d695722f071e5b91b72632d
1 //
2 // This test checks various uses of captured local variables
3 //
4 delegate void S ();
5 using System;
7 class X {
8 static int Main ()
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;
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);
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;