2010-06-21 Atsushi Enomoto <atsushi@ximian.com>
[mcs.git] / tests / test-anon-58.cs
blob26837a9bf4e297571460fe0ee7ef09908f429127
1 using System;
3 public class X
5 public delegate void TestDelegate ();
7 static long sum_i, sum_k, sum_p;
9 public static int Test (int p)
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}, p = {2}", i, k, p);
16 sum_i += 1 << i;
17 sum_k += 1 << k;
18 sum_p += 1 << p;
19 p += k;
21 temp ();
22 d += temp;
24 Console.WriteLine ("SUM i = {0}, k = {1}, p = {2}", sum_i, sum_k, sum_p);
25 Console.WriteLine ();
26 if (sum_i != 62)
27 return 1;
28 if (sum_k != 62)
29 return 2;
30 if (sum_p != 35168)
31 return 3;
32 sum_i = sum_k = sum_p = 0;
33 d();
34 Console.WriteLine ("SUM i = {0}, k = {1}, p = {2}", sum_i, sum_k, sum_p);
35 Console.WriteLine ();
36 if (sum_i != 320)
37 return 4;
38 if (sum_k != 62)
39 return 5;
40 if (sum_p != 1152385024)
41 return 6;
42 return 0;
45 public static int Main ()
47 int result = Test (5);
48 if (result != 0)
49 Console.WriteLine ("ERROR: {0}", result);
50 else
51 Console.WriteLine ("OK");
52 return result;