2009-02-10 Jeffrey Stedfast <fejj@novell.com>
[mono-project/dkf.git] / mcs / tests / test-anon-02.cs
blob21fe237a934697bde738795aa8cc36e4b4494a03
1 //
2 // This test checks various uses of captured local variables
3 //
4 using System;
6 delegate void S ();
8 class X {
9 static int Main ()
11 int a = 1;
12 Console.WriteLine ("A is = " + a);
13 int c = a;
14 Console.WriteLine (c);
15 if (a != 1){
16 return 1;
19 S b = delegate {
20 if (a != 1)
21 Environment.Exit (1);
22 Console.WriteLine ("in Delegate");
23 a = 2;
24 if (a != 2)
25 Environment.Exit (2);
26 Console.WriteLine ("Inside = " + a);
27 a = 3;
28 Console.WriteLine ("After = " + a);
30 if (a != 1)
31 return 3;
32 b ();
33 if (a != 3)
34 return 4;
35 Console.WriteLine ("Back, got " + a);
36 Console.WriteLine ("Test is ok");
37 return 0;