2009-02-15 Jonathan Chambers <joncham@gmail.com>
[mcs.git] / tests / test-anon-07.cs
blob0dcd92fb3bc3b89c2ebc03a696f974e0caa72634
1 //
2 // Tests havign more than one anonymous method that captures the same variable
3 //
4 using System;
6 delegate void D ();
8 class X {
9 static int Main ()
11 int a = 0;
12 D d1 = delegate {
13 Console.WriteLine ("First");
14 a = 1;
17 D d2 = delegate {
18 Console.WriteLine ("Second");
19 a = 2;
21 if (!t (a, 0))
22 return 1;
23 d1 ();
24 if (!t (a, 1))
25 return 2;
26 d2 ();
27 if (!t (a, 2))
28 return 3;
29 Console.WriteLine ("Test passes OK");
30 return 0;
33 static bool t (int a, int b)
35 return a == b;