repo.or.cz
/
mcs.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
2009-08-30 Jb Evain <jbevain@novell.com>
[mcs.git]
/
tests
/
test-47.cs
blob
c269d0b6c712a2082c200004db2d2d1679ee211c
1
//
2
// Short-circuit evaluation tests
3
//
4
using
System
;
5
6
class
X
{
7
8
static int
t_count
=
0
;
9
static int
f_count
=
0
;
10
11
static bool
f
()
12
{
13
Console
.
WriteLine
(
"f"
);
14
f_count
++;
15
return false
;
16
}
17
18
static bool
t
()
19
{
20
Console
.
WriteLine
(
"t"
);
21
t_count
++;
22
return true
;
23
}
24
25
static int
Main
()
26
{
27
if
(
t
() &&
t
()){
28
f_count
--;
29
}
30
31
if
(
t_count
!=
2
)
32
return
1
;
33
34
if
(
f_count
!= -
1
)
35
return
3
;
36
37
f_count
=
0
;
38
39
if
(
t
() &&
f
())
40
if
(
t_count
!=
3
&&
f_count
==
1
)
41
return
2
;
42
43
if
(
f
() &&
f
())
44
return
3
;
45
46
if
(
f_count
!=
2
)
47
return
4
;
48
49
if
(
f
() &&
t
())
50
return
5
;
51
52
if
(
f_count
!=
3
)
53
return
6
;
54
55
if
(
t_count
!=
3
)
56
return
7
;
57
58
//
59
// reset
60
//
61
Console
.
WriteLine
(
"or"
);
62
63
t_count
=
f_count
=
0
;
64
65
if
(
t
() ||
t
()){
66
if
(
t_count
!=
1
)
67
return
8
;
68
}
else
69
return
9
;
70
71
if
(
t
() ||
f
()){
72
if
(
f_count
!=
0
)
73
return
10
;
74
if
(
t_count
!=
2
)
75
return
16
;
76
}
else
77
return
11
;
78
79
if
(
f
() ||
f
()){
80
return
12
;
81
}
else
82
if
(
f_count
!=
2
)
83
return
13
;
84
85
if
(
f
() ||
t
()){
86
if
(
f_count
!=
3
)
87
return
15
;
88
if
(
t_count
!=
3
)
89
return
17
;
90
}
else
91
return
14
;
92
93
return
0
;
94
}
95
}