Reading database from cover_db ------------------------------------------------- ------ ------ ------ ------ File stmt branch cond total ------------------------------------------------- ------ ------ ------ ------ tests/cond_branch 89.29 70.59 44.44 71.25 Total 89.29 70.59 44.44 71.25 ------------------------------------------------- ------ ------ ------ ------ tests/cond_branch line err stmt branch cond code 1 #!/usr/local/bin/perl 2 3 # Copyright 2002, Paul Johnson (pjcj@cpan.org) 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 use strict; 11 use warnings; 12 13 1 my @x; 14 15 1 for my $y (0, 0) 2 16 { 17 2 for my $z (0, 1) 4 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 if ($y) *** 50 100 52 { 53 *** 0 33 $x[13]++; 54 } 55 elsif ($y && $z) 56 { 57 *** 0 66 $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 # print join(", ", @x), "\n"; Branches -------- line err % true false branch ----- --- ------ ------ ------ ------ 19 *** 50 0 4 if ($y and $z) { } 27 100 2 2 if ($y or $z) { } 36 *** 50 4 0 if $y 37 *** 50 4 0 if $y 39 100 2 2 if $z 40 100 2 2 if $z 42 *** 50 0 4 unless $y 43 *** 50 0 4 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 4 0 if $y and $z *** 50 4 0 if $y and $z Conditions ---------- and 3 conditions line err % !l l&&!r l&&r expr ----- --- ------ ------ ------ ------ ---- 19 *** 33 4 0 0 $y and $z 53 *** 33 4 0 0 $y and $z 68 *** 33 4 0 0 $y and $z *** 33 4 0 0 $y and $z or 3 conditions line err % l !l&&r !l&&!r expr ----- --- ------ ------ ------ ------ ---- 27 *** 66 0 2 2 $y or $z 57 *** 66 0 2 2 $y or $z