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

test-47.cs « tests « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 85686e1c6ce3e9aae5c1acfb2df7488e138d6c21 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//
// Short-circuit evaluation tests
//
using System;

class X {

	static int t_count = 0;
	static int f_count = 0;

	static bool f ()
	{
		Console.WriteLine ("f");
		f_count++;
		return false;
	}

	static bool t ()
	{
		Console.WriteLine ("t");
		t_count++;
		return true;
	}			
	
	public static int Main ()
	{
		if (t () && t ()){
			f_count--;
		}
		
		if (t_count != 2)
			return 1;

		if (f_count != -1)
			return 3;

		f_count = 0;

		if (t () && f ())
			if (t_count != 3 && f_count == 1)
				return 2;

		if (f () && f ())
			return 3;

		if (f_count != 2)
			return 4;

		if (f () && t ())
			return 5;

		if (f_count != 3)
			return 6;

		if (t_count != 3)
			return 7;

		//
		// reset
		//
		Console.WriteLine ("or");
		
		t_count = f_count = 0;

		if (t () || t ()){
			if (t_count != 1)
				return 8;
		} else
			return 9;

		if (t () || f ()){
			if (f_count != 0)
				return 10;
			if (t_count != 2)
				return 16;
		} else
			return 11;
		
		if (f () || f ()){
			return 12;
		} else
			if (f_count != 2)
				return 13;
		
		if (f () || t ()){
			if (f_count != 3)
				return 15;
			if (t_count != 3)
				return 17;
		} else
			return 14;
			
		return 0;
	}
}