Reading database from ...
------------------------------------------ ------ ------ ------ ------ ------
File stmt bran cond sub total
------------------------------------------ ------ ------ ------ ------ ------
tests/cond_branch 90.3 79.3 32.9 100.0 76.2
Total 90.3 79.3 32.9 100.0 76.2
------------------------------------------ ------ ------ ------ ------ ------
Run: ...
Perl version: ...
OS: ...
Start: ...
Finish: ...
tests/cond_branch
line err stmt bran cond sub code
1 #!/usr/bin/perl
2
3 # Copyright 2002-2013, 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 {
17 2 for my $z (1, 0)
18 {
19 *** 4 50 33 if ($y && $z)
20 {
21 *** 0 $x[1]++;
22 }
23 else
24 {
25 4 $x[2]++;
26 }
27 *** 4 100 66 if ($y || $z)
28 {
29 2 $x[3]++;
30 }
31 else
32 {
33 2 $x[4]++;
34 }
35
36 *** 4 50 $y && $x[5]++;
37 *** 4 50 $x[5]++ if $y;
38
39 4 100 $z && $x[6]++;
40 4 100 $x[6]++ if $z;
41
42 *** 4 50 $y || $x[7]++;
43 *** 4 50 $x[7]++ unless $y;
44
45 4 100 $z || $x[8]++;
46 4 100 $x[8]++ unless $z;
47
48 *** 4 50 $y ? $x[9]++ : $x[10]++;
49 4 100 $z ? $x[11]++ : $x[12]++;
50
51 *** 4 50 33 if ($y)
*** 50 66
100
52 {
53 *** 0 $x[13]++;
54 }
55 elsif ($y && $z)
56 {
57 *** 0 $x[14]++;
58 }
59 elsif ($y || $z)
60 {
61 2 $x[15]++;
62 }
63 else
64 {
65 2 $x[16]++;
66 }
67
68 *** 4 50 33 $y && $z && $x[17]++; $y && $z && $x[18]++;
*** 4 50 33
69 }
70 }
71
72
73 1 for my $y (0, 1)
74 {
75 2 100 $y || next;
76 1 $x[18]++;
77 }
78
79 1 for my $y (1, 0)
80 {
81 2 100 $y || next;
82 1 $x[19]++;
83 }
84
85 1 for my $y (0, 1)
86 {
87 2 100 $y && next;
88 1 $x[20]++;
89 }
90
91 1 for my $y (1, 0)
92 {
93 2 100 $y && next;
94 1 $x[21]++;
95 }
96
97 1 for my $y (0, 1)
98 {
99 1 1 no warnings "void";
1
1
100 *** 2 0 my $w = $y xor next;
101 *** 0 $x[22]++;
102 }
103
104 1 for my $y (1, 0)
105 {
106 1 1 no warnings "void";
1
1
107 *** 2 0 my $w = $y xor next;
108 *** 0 $x[23]++;
109 }
110
111
112 1 for my $y (0, 1)
113 {
114 *** 1 50 $y || last;
115 *** 0 $x[24]++;
116 }
117
118 1 for my $y (1, 0)
119 {
120 2 100 $y || last;
121 1 $x[25]++;
122 }
123
124 1 for my $y (0, 1)
125 {
126 2 100 $y && last;
127 1 $x[26]++;
128 }
129
130 1 for my $y (1, 0)
131 {
132 *** 1 50 $y && last;
133 *** 0 $x[27]++;
134 }
135
136 1 for my $y (0, 1)
137 {
138 1 1 no warnings "void";
1
1
139 *** 1 0 my $w = $y xor last;
140 *** 0 $x[28]++;
141 }
142
143 1 for my $y (1, 0)
144 {
145 1 1 no warnings "void";
1
1
146 *** 1 0 my $w = $y xor last;
147 *** 0 $x[29]++;
148 }
149
150
151 1 for my $y (0, 1)
152 {
153 *** 1 50 $y || goto G1;
154 *** 0 $x[30]++;
155 }
156 G1:
157
158 1 for my $y (1, 0)
159 {
160 2 100 $y || goto G2;
161 1 $x[31]++;
162 }
163 G2:
164
165 1 for my $y (0, 1)
166 {
167 2 100 $y && goto G3;
168 1 $x[32]++;
169 }
170 G3:
171
172 1 for my $y (1, 0)
173 {
174 *** 1 50 $y && goto G4;
175 *** 0 $x[33]++;
176 }
177 G4:
178
179 1 for my $y (0, 1)
180 {
181 1 1 no warnings "void";
1
1
182 *** 1 0 my $w = $y xor goto G5;
183 *** 0 $x[34]++;
184 }
185 G5:
186
187 1 for my $y (1, 0)
188 {
189 1 1 no warnings "void";
1
1
190 *** 1 0 my $w = $y xor goto G6;
191 *** 0 $x[35]++;
192 }
193 G6:
194
195
196 1 my $z;
197
198 1 $z = -1;
199 1 for my $y (0, 1)
200 {
201 3 $z++;
202 3 100 last if $z > 1;
203 2 100 $z || redo;
204 1 $x[36]++;
205 }
206
207 1 $z = -1;
208 1 for my $y (1, 0)
209 {
210 3 $z++;
211 3 100 last if $z > 1;
212 2 100 !$z || redo;
213 1 $x[37]++;
214 }
215
216 1 $z = -1;
217 1 for my $y (0, 1)
218 {
219 3 $z++;
220 3 100 last if $z > 1;
221 2 100 $z && redo;
222 1 $x[38]++;
223 }
224
225 1 $z = -1;
226 1 for my $y (1, 0)
227 {
228 3 $z++;
229 3 100 last if $z > 1;
230 2 100 !$z && redo;
231 1 $x[39]++;
232 }
233
234
235 1 $z = -1;
236 1 for my $y (0, 1)
237 {
238 3 $z++;
239 3 100 last if $z > 1;
240 1 1 no warnings "void";
1
1
241 *** 2 0 my $w = $z xor redo;
242 *** 0 $x[40]++;
243 }
244
245 1 $z = -1;
246 1 for my $y (1, 0)
247 {
248 3 $z++;
249 3 100 last if $z > 1;
250 1 1 no warnings "void";
1
1
251 *** 2 0 my $w = !$z xor redo;
252 *** 0 $x[41]++;
253 }
254
255
256 my @s =
257 (
258 sub
259 {
260 4 100 4 shift || return;
261 2 $x[42]++;
262 },
263
264 sub
265 {
266 4 100 4 shift && return;
267 2 $x[43]++;
268 },
269
270 sub
271 {
272 1 1 no warnings "void";
1
1
273 *** 4 0 4 shift xor return;
274 *** 0 $x[44]++;
275 },
276
277 sub
278 {
279 4 100 4 my $x = shift || return;
280 2 $x[45]++;
281 },
282
283 sub
284 {
285 4 100 4 my $x = shift && return;
286 2 $x[46]++;
287 },
288
289 sub
290 {
291 4 4 my $x = shift;
292 4 for my $y (1 .. 2)
293 {
294 6 100 my $z = $x || last;
295 4 $x[47]++;
296 }
297 },
298
299 sub
300 {
301 4 4 my $x = shift;
302 4 for my $y (1 .. 2)
303 {
304 8 100 my $z = $x || next;
305 4 $x[48]++;
306 }
307 },
308
309 sub
310 {
311 4 4 my $x = shift;
312 4 for my $y (1 .. 2)
313 {
314 10 100 my $z = $x++ || redo;
315 8 $x[49]++;
316 }
317 },
318
319 sub
320 {
321 4 4 my $x = shift;
322 4 for my $y (1 .. 2)
323 {
324 6 100 my $z = $x || goto GR;
325 4 $x[50]++;
326 }
327 GR:
328 4 },
329
330 sub
331 {
332 4 4 my $x = shift;
333 4 for my $y (1 .. 2)
334 {
335 8 100 eval { my $z = $x || die };
8
336 8 $x[51]++;
337 }
338 },
339 1 );
340
341 1 for my $s (@s)
342 {
343 10 for my $y (0, 1)
344 {
345 20 $s->($y)
346 }
347
348 10 for my $y (1, 0)
349 {
350 20 $s->($y)
351 }
352 }
353
354
355 1 my ($a, $b) = (0, 1);
356
357 *** 1 50 33 if ($a && $b)
*** 50 33
*** 50 50
358 {
359 *** 0 print "path 1\n";
360 }
361 elsif (!$a && !$b)
362 {
363 *** 0 print "path 2\n";
364 }
365 elsif ($b || 0)
366 {
367 1 print "path 3\n";
368 *** 1 50 33 if (!$b || $a)
*** 50 33
369 {
370 *** 0 print "path 4\n";
371 }
372 elsif (!$a && $b)
373 {
374 1 print "path 5\n";
375 }
376 }
Branches
--------
line err % true false branch
----- --- ------ ------ ------ ------
19 *** 50 0 4 if ($y and $z) { }
27 100 2 2 if ($y or $z) { }
36 *** 50 0 4 if $y
37 *** 50 0 4 if $y
39 100 2 2 if $z
40 100 2 2 if $z
42 *** 50 4 0 unless $y
43 *** 50 4 0 unless $y
45 100 2 2 unless $z
46 100 2 2 unless $z
48 *** 50 0 4 $y ? :
49 100 2 2 $z ? :
51 *** 50 0 4 if ($y) { }
*** 50 0 4 elsif ($y and $z) { }
100 2 2 elsif ($y or $z) { }
68 *** 50 0 4 if $y and $z
*** 50 0 4 if $y and $z
75 100 1 1 unless $y
81 100 1 1 unless $y
87 100 1 1 if $y
93 100 1 1 if $y
114 *** 50 1 0 unless $y
120 100 1 1 unless $y
126 100 1 1 if $y
132 *** 50 1 0 if $y
153 *** 50 1 0 unless $y
160 100 1 1 unless $y
167 100 1 1 if $y
174 *** 50 1 0 if $y
202 100 1 2 if $z > 1
203 100 1 1 unless $z
211 100 1 2 if $z > 1
212 100 1 1 if $z
220 100 1 2 if $z > 1
221 100 1 1 if $z
229 100 1 2 if $z > 1
230 100 1 1 unless $z
239 100 1 2 if $z > 1
249 100 1 2 if $z > 1
260 100 2 2 unless shift()
266 100 2 2 if shift()
357 *** 50 0 1 if ($a and $b) { }
*** 50 0 1 elsif (not $a || $b) { }
*** 50 1 0 elsif ($b or 0) { }
368 *** 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
----- --- ------ ------ ------ ----
285 100 2 2 shift() && return
and 3 conditions
line err % !l l&&!r l&&r expr
----- --- ------ ------ ------ ------ ----
19 *** 33 4 0 0 $y and $z
51 *** 33 4 0 0 $y and $z
68 *** 33 4 0 0 $y and $z
*** 33 4 0 0 $y and $z
357 *** 33 1 0 0 $a and $b
368 *** 33 0 0 1 not $a and $b
or 2 conditions
line err % l !l expr
----- --- ------ ------ ------ ----
279 100 2 2 shift() || return
294 100 4 2 $x || last
304 100 4 4 $x || next
314 100 8 2 $x++ || redo
324 100 4 2 $x || goto GR
335 100 4 4 $x || die
357 *** 50 1 0 $b or 0
or 3 conditions
line err % l !l&&r !l&&!r expr
----- --- ------ ------ ------ ------ ----
27 *** 66 0 2 2 $y or $z
51 *** 66 0 2 2 $y or $z
357 *** 33 0 1 0 $a || $b
368 *** 33 0 0 1 not $b or $a
xor 4 conditions
line err % l&&r l&&!r !l&&r !l&&!r expr
----- --- ------ ------ ------ ------ ------ ----
100 *** 0 0 0 0 0 my $w = $y xor next
107 *** 0 0 0 0 0 my $w = $y xor next
139 *** 0 0 0 0 0 my $w = $y xor last
146 *** 0 0 0 0 0 my $w = $y xor last
182 *** 0 0 0 0 0 my $w = $y xor goto G5
190 *** 0 0 0 0 0 my $w = $y xor goto G6
241 *** 0 0 0 0 0 my $w = $z xor redo
251 *** 0 0 0 0 0 my $w = !$z xor redo
273 *** 0 0 0 0 0 shift() xor return
Covered Subroutines
-------------------
Subroutine Count Location
---------- ----- ---------------------
BEGIN 1 tests/cond_branch:10
BEGIN 1 tests/cond_branch:106
BEGIN 1 tests/cond_branch:11
BEGIN 1 tests/cond_branch:138
BEGIN 1 tests/cond_branch:145
BEGIN 1 tests/cond_branch:181
BEGIN 1 tests/cond_branch:189
BEGIN 1 tests/cond_branch:240
BEGIN 1 tests/cond_branch:250
BEGIN 1 tests/cond_branch:272
BEGIN 1 tests/cond_branch:99
__ANON__ 4 tests/cond_branch:260
__ANON__ 4 tests/cond_branch:266
__ANON__ 4 tests/cond_branch:273
__ANON__ 4 tests/cond_branch:279
__ANON__ 4 tests/cond_branch:285
__ANON__ 4 tests/cond_branch:291
__ANON__ 4 tests/cond_branch:301
__ANON__ 4 tests/cond_branch:311
__ANON__ 4 tests/cond_branch:321
__ANON__ 4 tests/cond_branch:332