Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mcs / tests / test-636.cs
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)
7   {
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;
15     }
16   }
17   static int test_do_while (int n)
18   {
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));
27   }
28   static int test_for (int n)
29   {
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;
37     }
38   }
39   static void test_for_empty ()
40   {
41     calls = 0;
42     for (ping (); False & false; )
43       throw new Exception ();
44     if (calls != 2)
45       throw new Exception ();
46   }
47
48   public static void Main ()
49   {
50     test_while (100);
51     test_do_while (100);
52     test_for (100);
53     test_for_empty ();
54   }
55 }