Reading database from ...
------------------------------------------ ------ ------ ------ ------ ------
File stmt bran cond sub total
------------------------------------------ ------ ------ ------ ------ ------
tests/cond_branch 90.2 79.3 32.9 100.0 76.1
Total 90.2 79.3 32.9 100.0 76.1
------------------------------------------ ------ ------ ------ ------ ------
Run: ...
Perl version: ...
OS: ...
Start: ...
Finish: ...
tests/cond_branch
line err stmt bran cond sub code
1 #!/usr/bin/perl
2
3 # Copyright 2002-2017, Paul Johnson (paul@pjcj.net)
4
5 # This software is free. It is licensed under the same terms as Perl itself.
6
7 # The latest version of this software should be available from my homepage:
8 # http://www.pjcj.net
9
10 1 1 use strict;
1
1
11 1 1 use warnings;
1
1
12
13 1 my @x;
14
15 1 for my $y (0, 0) {
16 2 for my $z (1, 0) {
17 *** 4 50 33 if ($y && $z) {
18 *** 0 $x[1]++;
19 } else {
20 4 $x[2]++;
21 }
22 *** 4 100 66 if ($y || $z) {
23 2 $x[3]++;
24 } else {
25 2 $x[4]++;
26 }
27
28 *** 4 50 $y && $x[5]++;
29 *** 4 50 $x[5]++ if $y;
30
31 4 100 $z && $x[6]++;
32 4 100 $x[6]++ if $z;
33
34 *** 4 50 $y || $x[7]++;
35 *** 4 50 $x[7]++ unless $y;
36
37 4 100 $z || $x[8]++;
38 4 100 $x[8]++ unless $z;
39
40 *** 4 50 $y ? $x[9]++ : $x[10]++;
41 4 100 $z ? $x[11]++ : $x[12]++;
42
43 *** 4 50 33 if ($y) {
*** 50 66
100
44 *** 0 $x[13]++;
45 } elsif ($y && $z) {
46 *** 0 $x[14]++;
47 } elsif ($y || $z) {
48 2 $x[15]++;
49 } else {
50 2 $x[16]++;
51 }
52
53 *** 4 50 33 $y && $z && $x[17]++; $y && $z && $x[18]++;
*** 4 50 33
54 }
55 }
56
57
58 1 for my $y (0, 1) {
59 2 100 $y || next;
60 1 $x[18]++;
61 }
62
63 1 for my $y (1, 0) {
64 2 100 $y || next;
65 1 $x[19]++;
66 }
67
68 1 for my $y (0, 1) {
69 2 100 $y && next;
70 1 $x[20]++;
71 }
72
73 1 for my $y (1, 0) {
74 2 100 $y && next;
75 1 $x[21]++;
76 }
77
78 1 for my $y (0, 1) {
79 1 1 no warnings "void";
1
1
80 *** 2 0 my $w = $y xor next;
81 *** 0 $x[22]++;
82 }
83
84 1 for my $y (1, 0) {
85 1 1 no warnings "void";
1
1
86 *** 2 0 my $w = $y xor next;
87 *** 0 $x[23]++;
88 }
89
90
91 1 for my $y (0, 1) {
92 *** 1 50 $y || last;
93 *** 0 $x[24]++;
94 }
95
96 1 for my $y (1, 0) {
97 2 100 $y || last;
98 1 $x[25]++;
99 }
100
101 1 for my $y (0, 1) {
102 2 100 $y && last;
103 1 $x[26]++;
104 }
105
106 1 for my $y (1, 0) {
107 *** 1 50 $y && last;
108 *** 0 $x[27]++;
109 }
110
111 1 for my $y (0, 1) {
112 1 1 no warnings "void";
1
1
113 *** 1 0 my $w = $y xor last;
114 *** 0 $x[28]++;
115 }
116
117 1 for my $y (1, 0) {
118 1 1 no warnings "void";
1
1
119 *** 1 0 my $w = $y xor last;
120 *** 0 $x[29]++;
121 }
122
123
124 1 for my $y (0, 1) {
125 *** 1 50 $y || goto G1;
126 *** 0 $x[30]++;
127 }
128 G1:
129
130 1 for my $y (1, 0) {
131 2 100 $y || goto G2;
132 1 $x[31]++;
133 }
134 G2:
135
136 1 for my $y (0, 1) {
137 2 100 $y && goto G3;
138 1 $x[32]++;
139 }
140 G3:
141
142 1 for my $y (1, 0) {
143 *** 1 50 $y && goto G4;
144 *** 0 $x[33]++;
145 }
146 G4:
147
148 1 for my $y (0, 1) {
149 1 1 no warnings "void";
1
1
150 *** 1 0 my $w = $y xor goto G5;
151 *** 0 $x[34]++;
152 }
153 G5:
154
155 1 for my $y (1, 0) {
156 1 1 no warnings "void";
1
1
157 *** 1 0 my $w = $y xor goto G6;
158 *** 0 $x[35]++;
159 }
160 G6:
161
162
163 1 my $z;
164
165 1 $z = -1;
166 1 for my $y (0, 1) {
167 3 $z++;
168 3 100 last if $z > 1;
169 2 100 $z || redo;
170 1 $x[36]++;
171 }
172
173 1 $z = -1;
174 1 for my $y (1, 0) {
175 3 $z++;
176 3 100 last if $z > 1;
177 2 100 !$z || redo;
178 1 $x[37]++;
179 }
180
181 1 $z = -1;
182 1 for my $y (0, 1) {
183 3 $z++;
184 3 100 last if $z > 1;
185 2 100 $z && redo;
186 1 $x[38]++;
187 }
188
189 1 $z = -1;
190 1 for my $y (1, 0) {
191 3 $z++;
192 3 100 last if $z > 1;
193 2 100 !$z && redo;
194 1 $x[39]++;
195 }
196
197
198 1 $z = -1;
199 1 for my $y (0, 1) {
200 3 $z++;
201 3 100 last if $z > 1;
202 1 1 no warnings "void";
1
1
203 *** 2 0 my $w = $z xor redo;
204 *** 0 $x[40]++;
205 }
206
207 1 $z = -1;
208 1 for my $y (1, 0) {
209 3 $z++;
210 3 100 last if $z > 1;
211 1 1 no warnings "void";
1
1
212 *** 2 0 my $w = !$z xor redo;
213 *** 0 $x[41]++;
214 }
215
216
217 my @s = (
218 sub {
219 4 100 4 shift || return;
220 2 $x[42]++;
221 },
222
223 sub {
224 4 100 4 shift && return;
225 2 $x[43]++;
226 },
227
228 sub {
229 1 1 no warnings "void";
1
1
230 *** 4 0 4 shift xor return;
231 *** 0 $x[44]++;
232 },
233
234 sub {
235 4 100 4 my $x = shift || return;
236 2 $x[45]++;
237 },
238
239 sub {
240 4 100 4 my $x = shift && return;
241 2 $x[46]++;
242 },
243
244 sub {
245 4 4 my $x = shift;
246 4 for my $y (1 .. 2) {
247 6 100 my $z = $x || last;
248 4 $x[47]++;
249 }
250 },
251
252 sub {
253 4 4 my $x = shift;
254 4 for my $y (1 .. 2) {
255 8 100 my $z = $x || next;
256 4 $x[48]++;
257 }
258 },
259
260 sub {
261 4 4 my $x = shift;
262 4 for my $y (1 .. 2) {
263 10 100 my $z = $x++ || redo;
264 8 $x[49]++;
265 }
266 },
267
268 sub {
269 4 4 my $x = shift;
270 4 for my $y (1 .. 2) {
271 6 100 my $z = $x || goto GR;
272 4 $x[50]++;
273 }
274 GR:
275 },
276
277 sub {
278 4 4 my $x = shift;
279 4 for my $y (1 .. 2) {
280 8 100 eval { my $z = $x || die };
8
281 8 $x[51]++;
282 }
283 },
284 1 );
285
286 1 for my $s (@s) {
287 10 for my $y (0, 1) {
288 20 $s->($y)
289 }
290
291 10 for my $y (1, 0) {
292 20 $s->($y)
293 }
294 }
295
296
297 1 my ($a, $b) = (0, 1);
298
299 *** 1 50 33 if ($a && $b) {
*** 50 33
*** 50 50
300 *** 0 print "path 1\n";
301 } elsif (!$a && !$b) {
302 *** 0 print "path 2\n";
303 } elsif ($b || 0) {
304 1 print "path 3\n";
305 *** 1 50 33 if (!$b || $a) {
*** 50 33
306 *** 0 print "path 4\n";
307 } elsif (!$a && $b) {
308 1 print "path 5\n";
309 }
310 }
Branches
--------
line err % true false branch
----- --- ------ ------ ------ ------
17 *** 50 0 4 if ($y and $z) { }
22 100 2 2 if ($y or $z) { }
28 *** 50 0 4 if $y
29 *** 50 0 4 if $y
31 100 2 2 if $z
32 100 2 2 if $z
34 *** 50 4 0 unless $y
35 *** 50 4 0 unless $y
37 100 2 2 unless $z
38 100 2 2 unless $z
40 *** 50 0 4 $y ? :
41 100 2 2 $z ? :
43 *** 50 0 4 if ($y) { }
*** 50 0 4 elsif ($y and $z) { }
100 2 2 elsif ($y or $z) { }
53 *** 50 0 4 if $y and $z
*** 50 0 4 if $y and $z
59 100 1 1 unless $y
64 100 1 1 unless $y
69 100 1 1 if $y
74 100 1 1 if $y
92 *** 50 1 0 unless $y
97 100 1 1 unless $y
102 100 1 1 if $y
107 *** 50 1 0 if $y
125 *** 50 1 0 unless $y
131 100 1 1 unless $y
137 100 1 1 if $y
143 *** 50 1 0 if $y
168 100 1 2 if $z > 1
169 100 1 1 unless $z
176 100 1 2 if $z > 1
177 100 1 1 if $z
184 100 1 2 if $z > 1
185 100 1 1 if $z
192 100 1 2 if $z > 1
193 100 1 1 unless $z
201 100 1 2 if $z > 1
210 100 1 2 if $z > 1
219 100 2 2 unless shift @_
224 100 2 2 if shift @_
299 *** 50 0 1 if ($a and $b) { }
*** 50 0 1 elsif (not $a || $b) { }
*** 50 1 0 elsif ($b or 0) { }
305 *** 50 0 1 if (not $b or $a) { }
*** 50 1 0 elsif (not $a and $b) { }
Conditions
----------
and 2 conditions
line err % l !l expr
----- --- ------ ------ ------ ----
240 100 2 2 shift @_ && return
and 3 conditions
line err % !l l&&!r l&&r expr
----- --- ------ ------ ------ ------ ----
17 *** 33 4 0 0 $y and $z
43 *** 33 4 0 0 $y and $z
53 *** 33 4 0 0 $y and $z
*** 33 4 0 0 $y and $z
299 *** 33 1 0 0 $a and $b
305 *** 33 0 0 1 not $a and $b
or 2 conditions
line err % l !l expr
----- --- ------ ------ ------ ----
235 100 2 2 shift @_ || return
247 100 4 2 $x || last
255 100 4 4 $x || next
263 100 8 2 $x++ || redo
271 100 4 2 $x || goto GR
280 100 4 4 $x || die
299 *** 50 1 0 $b or 0
or 3 conditions
line err % l !l&&r !l&&!r expr
----- --- ------ ------ ------ ------ ----
22 *** 66 0 2 2 $y or $z
43 *** 66 0 2 2 $y or $z
299 *** 33 0 1 0 $a || $b
305 *** 33 0 0 1 not $b or $a
xor 4 conditions
line err % l&&r l&&!r !l&&r !l&&!r expr
----- --- ------ ------ ------ ------ ------ ----
80 *** 0 0 0 0 0 my $w = $y xor next
86 *** 0 0 0 0 0 my $w = $y xor next
113 *** 0 0 0 0 0 my $w = $y xor last
119 *** 0 0 0 0 0 my $w = $y xor last
150 *** 0 0 0 0 0 my $w = $y xor goto G5
157 *** 0 0 0 0 0 my $w = $y xor goto G6
203 *** 0 0 0 0 0 my $w = $z xor redo
212 *** 0 0 0 0 0 my $w = !$z xor redo
230 *** 0 0 0 0 0 shift @_ xor return
Covered Subroutines
-------------------
Subroutine Count Location
---------- ----- ---------------------
BEGIN 1 tests/cond_branch:10
BEGIN 1 tests/cond_branch:11
BEGIN 1 tests/cond_branch:112
BEGIN 1 tests/cond_branch:118
BEGIN 1 tests/cond_branch:149
BEGIN 1 tests/cond_branch:156
BEGIN 1 tests/cond_branch:202
BEGIN 1 tests/cond_branch:211
BEGIN 1 tests/cond_branch:229
BEGIN 1 tests/cond_branch:79
BEGIN 1 tests/cond_branch:85
__ANON__ 4 tests/cond_branch:219
__ANON__ 4 tests/cond_branch:224
__ANON__ 4 tests/cond_branch:230
__ANON__ 4 tests/cond_branch:235
__ANON__ 4 tests/cond_branch:240
__ANON__ 4 tests/cond_branch:245
__ANON__ 4 tests/cond_branch:253
__ANON__ 4 tests/cond_branch:261
__ANON__ 4 tests/cond_branch:269
__ANON__ 4 tests/cond_branch:278