Branch Coverage

blib/lib/Games/Chess.pm
Criterion Covered Total %
branch 120 206 58.2


line true false branch
50 12 102 unless $sq =~ /^([a-h])([1-8])$/
57 292 0 if $colour == 1 or $colour == 2
71 0 224 if ($Games::Chess::DEBUG > 0)
74 0 0 $Games::Chess::DEBUG >= 2 ? :
81 225 0 if $halfmove =~ /^[0-9]+$/
87 425 0 if $move =~ /^[0-9]+$/ and $move > 0
93 284 0 if 1 <= $piece and $piece <= 6
99 101 64 unless &xy_valid($x, $y)
105 3252 2 if 0 <= $x and $x < 8 and 0 <= $y and $y < 8
129 1 2974 if (@_ < 2) { }
0 2974 elsif (@_ > 3) { }
284 2690 elsif (@_ == 3) { }
13 2677 elsif (UNIVERSAL::isa($val, 'Games::Chess::Piece')) { }
49 2628 elsif (exists $PIECE_CODES{$val}) { }
0 2628 elsif (not $val =~ /^\d+$/) { }
2628 0 elsif (0 <= $val and $val < 256 and $val == int $val) { }
134 0 284 unless colour_valid $_[1]
135 0 284 unless piece_valid $_[2]
155 398 2145 $col == 2 ? :
193 0 0 unless &xy_valid($xs, $ys) and &xy_valid($xd, $yd)
195 0 0 if (@promotion)
197 0 0 unless $p
205 0 0 unless UNIVERSAL::isa($b, 'Games::Chess::Move')
248 0 25 if (defined $val and UNIVERSAL::isa($val, 'Games::Chess::Position'))
254 2 23 unless $val
261 0 25 unless @ranks == 8
268 0 200 unless length $rank == 8
271 0 200 unless @{$ranks[$r];} == 8
279 0 25 unless defined $fields[1]
280 21 4 if ($fields[1] eq 'w') { }
4 0 elsif ($fields[1] eq 'b') { }
289 0 25 unless defined $fields[2]
290 13 12 unless ($fields[2] eq '-')
291 0 13 unless join('', sort(split(//, $fields[2], 0))) eq $fields[2]
294 0 38 unless /^[KQkq]$/
300 0 25 unless defined $fields[3]
301 2 23 unless ($fields[3] eq '-')
303 0 2 unless @square == 2
308 0 25 unless defined $fields[4]
309 0 25 unless halfmove_count_valid $fields[4]
313 0 25 unless defined $fields[5]
314 0 25 unless move_number_valid $fields[5]
323 0 2748 unless &xy_valid($x, $y)
324 2628 120 unless @piece
327 0 120 unless defined $p
340 0 116 unless defined $p
342 0 116 unless $code =~ /^[KQkq]$/
344 84 32 unless defined $can_castle
345 16 16 if ($can_castle) { }
355 0 120 unless &xy_valid($x, $y)
363 258 2 defined $ep ? :
260 256 unless @en_passant
364 0 256 unless &xy_valid(@en_passant)
371 204 200 unless defined $halfmove
372 0 200 unless &halfmove_count_valid($halfmove)
379 404 400 unless defined $move
380 0 400 unless &move_number_valid($move)
387 12 8 unless defined $colour
388 0 8 unless &colour_valid($colour)
417 1 18 unless $n{'p'} <= 8
418 1 17 unless $n{'P'} <= 8
421 1 16 2 < $n{'n'} ? :
1 16 2 < $n{'b'} ? :
1 16 2 < $n{'r'} ? :
1 16 1 < $n{'q'} ? :
1 16 unless $n{'p'} + (2 < $n{'n'} ? $n{'n'} - 2 : 0) + (2 < $n{'b'} ? $n{'b'} - 2 : 0) + (2 < $n{'r'} ? $n{'r'} - 2 : 0) + (1 < $n{'q'} ? $n{'q'} - 1 : 0) <= 8
424 1 15 2 < $n{'N'} ? :
1 15 2 < $n{'B'} ? :
1 15 2 < $n{'R'} ? :
1 15 1 < $n{'Q'} ? :
1 15 unless $n{'P'} + (2 < $n{'N'} ? $n{'N'} - 2 : 0) + (2 < $n{'B'} ? $n{'B'} - 2 : 0) + (2 < $n{'R'} ? $n{'R'} - 2 : 0) + (1 < $n{'Q'} ? $n{'Q'} - 1 : 0) <= 8
429 1 14 unless $n{'k'} == 1
430 1 13 unless $n{'K'} == 1
433 2 11 unless $m{'p'} == 0
434 2 9 unless $m{'P'} == 0
438 0 9 if ($ep)
439 0 0 if ($$self{'player_to_move'} == &WHITE) { }
440 0 0 unless $$ep[1] == 5
442 0 0 unless $self->at($$ep[0], 6)->code == ' '
444 0 0 unless $self->at($$ep[0], 5)->code == ' '
446 0 0 unless $self->at($$ep[0], 4)->code == 'p'
449 0 0 unless $$ep[1] == 2
451 0 0 unless $self->at($$ep[0], 1)->code == ' '
453 0 0 unless $self->at($$ep[0], 2)->code == ' '
455 0 0 unless $self->at($$ep[0], 3)->code == 'P'
463 18 18 if ($self->can_castle($$c[0], $$c[1]))
469 0 36 unless $self->at(&algebraic_to_xy($sq))->code eq $required
477 0 9 unless 0 <= $h
478 0 9 unless $h == int $h
479 0 9 unless $h <= 50
481 0 9 unless 1 <= $m
482 0 9 unless $m == int $m
505 1 4 $$self{'player_to_move'} == &BLACK ? :
0 5 defined $$self{'en_passant'} ? :
516 91 165 if $sq eq ' ' and ($y + $_) % 2 == 0
532 0 0 unless $opts{'letters'}
534 0 0 unless 0 <= $opts{$_}
536 0 0 unless UNIVERSAL::isa($opts{'font'}, 'GD::Font')
567 0 0 if ($opts{'letters'})
586 0 0 if ($x + $y) % 2 == 0
589 0 0 if $c eq ' '
616 0 0 unless (%Games::Chess::Position::gifs)
619 0 0 if $code eq ' '