New test.
[mono.git] / mcs / tests / test-anon-57.cs
1 using System;
2
3 public class X
4 {
5         public delegate void TestDelegate ();
6
7         static long sum_i, sum_k;
8
9         public static int Test ()
10         {
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;
18                         };
19                         temp ();
20                         d += temp;
21                 }
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;
37         }
38
39         public static int Main ()
40         {
41                 int result = Test ();
42                 if (result != 0)
43                         Console.WriteLine ("ERROR: {0}", result);
44                 else
45                         Console.WriteLine ("OK");
46                 return result;
47         }
48 }