Jo Shields a575963da9 Imported Upstream version 3.6.0
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
2014-08-13 10:39:27 +01:00

49 lines
881 B
C#

using System;
public class X
{
public delegate void TestDelegate ();
static long sum_i, sum_k;
public static int Test ()
{
TestDelegate d = null;
for (int i = 1; i <= 5; i++) {
int k = i;
TestDelegate temp = delegate {
Console.WriteLine ("i = {0}, k = {1}", i, k);
sum_i += 1 << i;
sum_k += 1 << k;
};
temp ();
d += temp;
}
Console.WriteLine ("SUM i = {0}, k = {1}", sum_i, sum_k);
Console.WriteLine ();
if (sum_i != 62)
return 1;
if (sum_k != 62)
return 2;
sum_i = sum_k = 0;
d();
Console.WriteLine ("SUM i = {0}, k = {1}", sum_i, sum_k);
Console.WriteLine ();
if (sum_i != 320)
return 3;
if (sum_k != 62)
return 4;
return 0;
}
public static int Main ()
{
int result = Test ();
if (result != 0)
Console.WriteLine ("ERROR: {0}", result);
else
Console.WriteLine ("OK");
return result;
}
}