2010-06-21 Atsushi Enomoto <atsushi@ximian.com>
[mcs.git] / tests / test-anon-61.cs
blob4a98dbc0774d9cbf09c8efc54f98eb490ad608d0
1 using System;
3 public class X
5 public int p;
6 public delegate void TestDelegate ();
8 static long sum_i, sum_k, sum_p;
10 public int Test ()
12 TestDelegate d = null;
13 for (int i = 1; i <= 5; i++) {
14 int k = i;
15 TestDelegate temp = delegate {
16 Console.WriteLine ("i = {0}, k = {1}, p = {2}", i, k, p);
17 sum_i += 1 << i;
18 sum_k += 1 << k;
19 sum_p += 1 << p;
20 p += k;
22 temp ();
23 d += temp;
25 Console.WriteLine ("SUM i = {0}, k = {1}, p = {2}", sum_i, sum_k, sum_p);
26 Console.WriteLine ();
27 if (sum_i != 62)
28 return 1;
29 if (sum_k != 62)
30 return 2;
31 if (sum_p != 35168)
32 return 3;
33 sum_i = sum_k = sum_p = 0;
34 d();
35 Console.WriteLine ("SUM i = {0}, k = {1}, p = {2}", sum_i, sum_k, sum_p);
36 Console.WriteLine ();
37 if (sum_i != 320)
38 return 4;
39 if (sum_k != 62)
40 return 5;
41 if (sum_p != 1152385024)
42 return 6;
43 return 0;
46 public static int Main ()
48 X x = new X ();
49 x.p = 5;
50 int result = x.Test ();
51 if (result != 0)
52 Console.WriteLine ("ERROR: {0}", result);
53 else
54 Console.WriteLine ("OK");
55 return result;