Welcome to mirror list, hosted at ThFree Co, Russian Federation.

test-636.cs « tests « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4dc161ba8cd1127ca97e6f0e9da791e86ed3face (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 ();
  }

  public static void Main ()
  {
    test_while (100);
    test_do_while (100);
    test_for (100);
    test_for_empty ();
  }
}