blob: e6aea951222685f818c233e8106b3bb25a2bba32 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
using System;
class Foo {
static int calls;
static bool False { get { ++calls; return true; } }
static void ping () { ++calls; }
static int test_while (int n)
{
int i = 0;
calls = 0;
while (!(False & false)) {
if (calls != ++i)
throw new Exception ();
if (calls == n)
return 0;
}
}
static int test_do_while (int n)
{
int i = 0;
calls = 0;
do {
if (calls != i++)
throw new Exception ();
if (calls == n)
return 0;
} while (!(False & false));
}
static int test_for (int n)
{
int i = 2;
calls = 0;
for (bool dummy = False; !(False & false); ++i) {
if (calls != i)
throw new Exception ();
if (calls == n)
return 0;
}
}
static void test_for_empty ()
{
calls = 0;
for (ping (); False & false; )
throw new Exception ();
if (calls != 2)
throw new Exception ();
}
static void Main ()
{
test_while (100);
test_do_while (100);
test_for (100);
test_for_empty ();
}
}
|