In class/Microsoft.Build.Tasks:
[mcs.git] / tests / test-636.cs
blobe6aea951222685f818c233e8106b3bb25a2bba32
1 using System;
2 class Foo {
3 static int calls;
4 static bool False { get { ++calls; return true; } }
5 static void ping () { ++calls; }
6 static int test_while (int n)
8 int i = 0;
9 calls = 0;
10 while (!(False & false)) {
11 if (calls != ++i)
12 throw new Exception ();
13 if (calls == n)
14 return 0;
17 static int test_do_while (int n)
19 int i = 0;
20 calls = 0;
21 do {
22 if (calls != i++)
23 throw new Exception ();
24 if (calls == n)
25 return 0;
26 } while (!(False & false));
28 static int test_for (int n)
30 int i = 2;
31 calls = 0;
32 for (bool dummy = False; !(False & false); ++i) {
33 if (calls != i)
34 throw new Exception ();
35 if (calls == n)
36 return 0;
39 static void test_for_empty ()
41 calls = 0;
42 for (ping (); False & false; )
43 throw new Exception ();
44 if (calls != 2)
45 throw new Exception ();
48 static void Main ()
50 test_while (100);
51 test_do_while (100);
52 test_for (100);
53 test_for_empty ();