Branch Coverage

blib/lib/Chess/Game.pm
Criterion Covered Total %
branch 220 324 67.9


line true false branch
255 0 225 unless $obj_data
272 3443 157 if ($old_piece->isa('Chess::Piece::King') or not $old_piece->captured) { }
277 225 3218 if defined $new_piece and $new_piece->isa('Chess::Piece::King')
282 157 292 if ($capture eq $old_piece)
291 3203 397 if ($old_piece->isa('Chess::Piece::King') or not $old_piece->captured) { }
296 225 2978 if defined $new_piece and $new_piece->isa('Chess::Piece::King')
301 397 1562 if ($capture eq $old_piece)
319 397 980 if $p1_move->is_capture
320 0 1377 if $p1_move->is_short_castle
321 0 1377 if $p1_move->is_long_castle
322 38 1339 if $p1_move->is_en_passant
324 1213 164 if (defined $p2_move)
329 157 1056 if $p2_move->is_capture
330 14 1199 if $p2_move->is_short_castle
331 0 1213 if $p2_move->is_long_castle
332 0 1213 if $p2_move->is_en_passant
351 0 3 unless ref $self
353 0 3 unless $obj_data
359 0 0 unless ref $self
361 0 0 unless $obj_data
362 0 0 if (defined $player) { }
374 0 0 unless ref $self
376 0 0 unless $obj_data
382 0 2 unless ref $self
384 0 2 unless $obj_data
390 0 8 unless ref $self
392 0 8 unless $obj_data
400 0 2 unless ref $self
402 0 2 unless $obj_data
404 2 0 if exists $$captures{$player}{$movenum}
420 291 1821 if $p1_piece->isa('Chess::Piece::King') or $p1_piece->captured
423 1757 64 unless $p1_piece->can_reach($p2_sq)
424 1 63 if ($p1_piece->isa('Chess::Piece::Pawn')) { }
0 63 elsif ($p1_piece->isa('Chess::Piece::King')) { }
63 0 elsif (not $p1_piece->isa('Chess::Piece::Knight')) { }
425 0 1 if 'Chess::Board'->horz_distance($p1_sq, $p2_sq) == 0
428 0 0 if 'Chess::Board'->horz_distance($p1_sq, $p2_sq) == 2
434 19 44 unless $board_c->line_is_open($p1_sq, $p2_sq)
439 344 1768 if $p2_piece->isa('Chess::Piece::King') or $p2_piece->captured
442 1757 11 unless $p2_piece->can_reach($p1_sq)
443 0 11 if ($p2_piece->isa('Chess::Piece::Pawn')) { }
0 11 elsif ($p2_piece->isa('Chess::Piece::King')) { }
9 2 elsif (not $p2_piece->isa('Chess::Piece::Knight')) { }
444 0 0 if 'Chess::Board'->horz_distance($p1_sq, $p2_sq) == 0
447 0 0 if 'Chess::Board'->horz_distance($p1_sq, $p2_sq) == 2
453 4 5 unless $board_c->line_is_open($p1_sq, $p2_sq)
465 3 42 unless $move
467 28 14 unless $piece2->isa('Chess::Piece::Pawn')
471 8 6 if ($piece2->get_player eq $player1) { }
472 8 0 unless 'Chess::Board'->square_up_from($sq2) eq $p2_sq
475 4 2 unless 'Chess::Board'->square_down_from($sq2) eq $p2_sq
486 3 4 $player eq $player1 ? :
487 3 4 unless $sq2 eq $tsq
488 0 4 unless (not $piece->moved)
493 2 2 if ($player eq $player1) { }
499 0 4 unless (defined $rook and not $rook->moved)
503 2 2 $player eq $player1 ? :
504 2 2 $player eq $player1 ? :
508 1 3 unless ($board_c->line_is_open($king_sq, $rook_sq))
521 3 3 $player eq $player1 ? :
522 3 3 unless $sq2 eq $tsq
523 0 3 unless (not $piece->moved)
528 3 0 if ($player eq $player1) { }
534 1 2 unless (defined $rook and not $rook->moved)
538 2 0 $player eq $player1 ? :
539 2 0 $player eq $player1 ? :
543 0 2 unless ($board_c->line_is_open($king_sq, $rook_sq))
552 0 371 unless ('Chess::Board'->square_is_valid($sq1))
556 0 371 unless ('Chess::Board'->square_is_valid($sq2))
560 0 371 unless ref $self
562 0 371 unless $obj_data
567 0 371 unless (defined $piece)
574 1 370 if (defined $last_moved and $last_moved eq $player or not defined $last_moved and $player ne $player1)
579 0 370 unless $piece->can_reach($sq2)
581 171 199 if (defined $capture) { }
582 127 44 unless ($capture->get_player ne $player)
586 6 38 if ($piece->isa('Chess::Piece::Pawn')) { }
1 37 elsif ($piece->isa('Chess::Piece::King')) { }
587 3 3 unless (abs 'Chess::Board'->horz_distance($sq1, $sq2) == 1)
593 1 0 unless (abs 'Chess::Board'->horz_distance($sq1, $sq2) < 2)
600 61 138 if ($piece->isa('Chess::Piece::Pawn'))
602 17 44 unless ('Chess::Board'->horz_distance($sq1, $sq2) == 0 or _is_valid_en_passant($obj_data, $piece, $sq1, $sq2))
612 58 164 $player eq $player1 ? :
613 14 208 if ($piece->isa('Chess::Piece::King')) { }
191 17 elsif (not $piece->isa('Chess::Piece::Knight')) { }
615 6 8 if (abs $hdist == 2)
617 1 5 unless (not $king->threatened)
621 3 2 if ($hdist > 0) { }
622 1 2 unless _is_valid_short_castle($obj_data, $piece, $sq1, $sq2)
626 1 1 unless _is_valid_long_castle($obj_data, $piece, $sq1, $sq2)
635 105 86 unless ($board_c->line_is_open($sq1, $sq2))
640 111 3 if (not $valid_castle) { }
643 35 76 unless (not $king->threatened)
649 2 1 if ($valid_castle == 2) { }
653 1 1 unless (not $king->threatened)
659 0 1 unless (not $king->threatened)
668 0 1 unless (not $king->threatened)
674 0 1 unless (not $king->threatened)
687 1 202 unless defined $validate
688 0 203 unless ('Chess::Board'->square_is_valid($sq1))
692 0 203 unless ('Chess::Board'->square_is_valid($sq2))
696 84 119 if ($validate)
697 8 76 unless $self->is_move_legal($sq1, $sq2)
699 0 195 unless ref $self
701 0 195 unless $obj_data
707 0 195 unless (defined $piece)
714 30 165 if ($validate and $piece->isa('Chess::Piece::Pawn'))
715 13 17 if ($player eq $player1) { }
716 0 13 if 'Chess::Board'->vert_distance('d8', $sq2) == 0
719 2 15 if 'Chess::Board'->vert_distance('d1', $sq2) == 0
722 32 163 if (defined $capture) { }
734 1 162 if ($validate and $piece->isa('Chess::Piece::Pawn') and _is_valid_en_passant($obj_data, $piece, $sq1, $sq2)) { }
751 4 158 if ($validate and $piece->isa('Chess::Piece::King'))
752 1 3 if _is_valid_short_castle($obj_data, $piece, $sq1, $sq2)
753 1 3 if _is_valid_long_castle($obj_data, $piece, $sq1, $sq2)
755 2 160 if ($flags & 2 or $flags & 4) { }
758 1 1 if ($player eq $player1) { }
759 0 1 $flags & 2 ? :
760 0 1 $flags & 2 ? :
762 0 1 $flags & 2 ? :
765 1 0 $flags & 2 ? :
766 1 0 $flags & 2 ? :
768 1 0 $flags & 2 ? :
802 0 4 unless ref $self
804 0 4 unless $obj_data
810 3 1 if (defined $move)
816 1 2 if ($move->is_promotion)
819 0 3 if ($move->is_capture) { }
0 3 elsif ($move->is_short_castle) { }
0 3 elsif ($move->is_long_castle) { }
821 0 0 if ($move->is_en_passant)
822 0 0 if ($player eq $player1) { }
834 0 0 if $piece->_firstmoved == $movenum
837 0 0 $player eq $player1 ? :
838 0 0 $player eq $player1 ? :
839 0 0 $player eq $player1 ? :
840 0 0 $player eq $player1 ? :
852 0 0 $player eq $player1 ? :
853 0 0 $player eq $player1 ? :
854 0 0 $player eq $player1 ? :
855 0 0 $player eq $player1 ? :
870 3 0 if $piece->_firstmoved == $movenum
882 5 4 if (exists $$obj_data{'_player_has_moves'}{$player}{$movenum})
886 6 37 if not $piece->isa('Chess::Piece::King') and $piece->captured
890 2 285 if ($self->is_move_legal($csq, $sq))
902 0 2 unless ref $self
904 0 2 unless $obj_data
910 0 2 unless $move->is_promotion
920 0 10 unless ref $self
922 0 10 unless $obj_data
925 2 8 $player eq $player1 ? :
931 1 4 unless $self->player_in_check($player)
932 1 3 if ($self->_player_has_moves($player)) { }
942 1 2 if $self->player_in_check($player)
943 0 2 if ($self->_player_has_moves($player)) { }
953 0 3 unless ref $self
955 0 3 unless $obj_data
960 2 1 $last_moved eq $player1 ? :
961 1 2 if $self->_player_has_moves($player)
962 1 1 if $self->player_stalemated($player)
963 1 0 if $self->player_checkmated($player) and $player eq $player2
964 0 0 if $self->player_checkmated($player)