2009-07-16 Jb Evain <jbevain@novell.com>
[mcs.git] / tests / test-anon-57.cs
blobf37504e3658ebb5159b9266f73b6a4663b624305
1 using System;
3 public class X
5 public delegate void TestDelegate ();
7 static long sum_i, sum_k;
9 public static int Test ()
11 TestDelegate d = null;
12 for (int i = 1; i <= 5; i++) {
13 int k = i;
14 TestDelegate temp = delegate {
15 Console.WriteLine ("i = {0}, k = {1}", i, k);
16 sum_i += 1 << i;
17 sum_k += 1 << k;
19 temp ();
20 d += temp;
22 Console.WriteLine ("SUM i = {0}, k = {1}", sum_i, sum_k);
23 Console.WriteLine ();
24 if (sum_i != 62)
25 return 1;
26 if (sum_k != 62)
27 return 2;
28 sum_i = sum_k = 0;
29 d();
30 Console.WriteLine ("SUM i = {0}, k = {1}", sum_i, sum_k);
31 Console.WriteLine ();
32 if (sum_i != 320)
33 return 3;
34 if (sum_k != 62)
35 return 4;
36 return 0;
39 public static int Main ()
41 int result = Test ();
42 if (result != 0)
43 Console.WriteLine ("ERROR: {0}", result);
44 else
45 Console.WriteLine ("OK");
46 return result;