Branch Coverage

blib/lib/AnyEvent/BitTorrent.pm
Criterion Covered Total %
branch 28 248 11.2


line true false branch
66 0 0 if $s->state eq 'stopped'
126 0 4 $VERSION =~ /[^\d\.^v]/ ? :
210 0 12635 $count == int $count ? :
254 0 4 defined $s->metadata->{'info'}{'files'} ? :
280 3 0 if $s->files->[$i]{'mode'} eq $m
281 0 0 if (defined $s->files->[$i]{'fh'})
287 0 0 if ($m eq 'r') { }
0 0 elsif ($m eq 'w') { }
0 0 elsif ($m eq 'c') { }
289 0 0 unless sysopen $s->files->[$i]{'fh'}, $s->files->[$i]{'path'}, 0
291 0 0 unless flock $s->files->[$i]{'fh'}, 1
292 0 0 unless &isweak($s)
302 0 0 unless -d $dir
305 0 0 unless sysopen $s->files->[$i]{'fh'}, $s->files->[$i]{'path'}, 65
310 0 0 if -s $s->files->[$i]{'fh'} != $s->files->[$i]{'length'}
311 0 0 unless &isweak($s)
325 0 0 scalar @{$s->files;} == 1 ? :
342 0 0 unless -d $dir
343 0 0 unless sysopen my $fh, $path, 65
364 0 0 unless sysopen my $fh, $path, 0
392 0 0 unless defined $s->files->[$file_index]{'length'}
399 3 6309 $total_offset + $length >= $s->files->[$file_index]{'length'} ? :
406 6312 0 if (not -f $s->files->[$file_index]{'path'} && $s->_open($file_index, 'r')) { }
415 0 0 if $_data
420 0 0 unless &isweak($s)
430 6312 0 unless defined $s->files->[$file_index]
457 0 0 unless defined $s->files->[$file_index]{'length'}
464 0 0 $total_offset + length($data) >= $s->files->[$file_index]{'length'} ? :
471 0 0 if ($s->files->[$file_index]{'priority'} == 0) { }
484 0 0 unless &isweak($s)
490 0 0 unless defined $s->files->[$file_index]
498 0 3 @_ ? :
506 0 6312 if $index < 0 or $index > $s->piece_count
507 3 6309 $index == $s->piece_count ? :
520 0 0 $ok ? :
525 9 6303 $ok ? :
591 0 8 unless @$deck
610 0 0 if $s->state eq 'stopped'
619 4 0 defined $s->metadata->{'announce'} ? :
0 4 defined $s->metadata->{'announce-list'} ? :
637 0 3 if $a++ > 10
646 0 4 if $tier->{'failures'} > 5
647 0 4 if $#{$$tier{'urls'};} < 0
648 0 4 unless $tier->{'urls'}[0] =~ m[^https?://.+]
656 4 0 $e ? :
672 0 0 if ($hdr->{'Status'} =~ /^2/) { }
674 0 0 if (defined $reply->{'failure reason'}) { }
685 0 0 if $reply->{'peers'}
689 0 0 if $reply->{'peers6'}
696 0 0 if $s->state eq 'stopped'
800 0 0 unless $s->_left
808 0 0 $_->{'peers'} ? :
0 0 $_->{'peers6'} ? :
810 0 0 unless @cache
812 0 0 if $i > 10
814 0 0 if scalar keys %{$s->peers;} > 100
843 0 0 $fatal ? :
847 0 0 if not $fatal
875 0 0 unless $packet
880 0 0 if (defined $packet->{'error'}) { }
0 0 elsif ($packet->{'type'} == $AnyEvent::BitTorrent::HANDSHAKE) { }
885 0 0 if ref $packet->{'payload'} ne 'ARRAY'
888 0 0 if $packet->{'payload'}[1] ne $s->infohash
905 0 0 unless $packet
910 0 0 if (defined $packet->{'error'}) { }
0 0 elsif ($packet->{'type'} eq $AnyEvent::BitTorrent::KEEPALIVE) { }
0 0 elsif ($packet->{'type'} == $AnyEvent::BitTorrent::HANDSHAKE) { }
0 0 elsif ($packet->{'type'} == $AnyEvent::BitTorrent::INTERESTED) { }
0 0 elsif ($packet->{'type'} == $AnyEvent::BitTorrent::NOT_INTERESTED) { }
0 0 elsif ($packet->{'type'} == $AnyEvent::BitTorrent::CHOKE) { }
0 0 elsif ($packet->{'type'} == $AnyEvent::BitTorrent::UNCHOKE) { }
0 0 elsif ($packet->{'type'} == $AnyEvent::BitTorrent::HAVE) { }
0 0 elsif ($packet->{'type'} == $AnyEvent::BitTorrent::BITFIELD) { }
0 0 elsif ($packet->{'type'} == $AnyEvent::BitTorrent::REQUEST) { }
0 0 elsif ($packet->{'type'} == $AnyEvent::BitTorrent::PIECE) { }
0 0 elsif ($packet->{'type'} == $AnyEvent::BitTorrent::CANCEL) { }
0 0 elsif ($packet->{'type'} == $AnyEvent::BitTorrent::SUGGEST) { }
0 0 elsif ($packet->{'type'} == $AnyEvent::BitTorrent::HAVE_ALL) { }
0 0 elsif ($packet->{'type'} == $AnyEvent::BitTorrent::HAVE_NONE) { }
0 0 elsif ($packet->{'type'} == $AnyEvent::BitTorrent::REJECT) { }
0 0 elsif ($packet->{'type'} == $AnyEvent::BitTorrent::ALLOWED_FAST) { }
922 0 0 if $packet->{'payload'}[1] ne $s->infohash
940 0 0 unless (vec($s->peers->{$h}{'reserved'}, 7, 1) & 4)
944 0 0 unless defined $s->working_pieces->{$req->[0]}{$req->[1]}[4]
985 0 0 if $_->[0] == $index and $_->[1] == $offset
988 0 0 unless grep {$_->[2] == length $data if $_->[0] == $index and $_->[1] == $offset;} @{$s->peers->{$h}{'local_requests'};}
991 0 0 unless $_->[0] != $index or $_->[1] != $offset
999 0 0 if (0 == scalar grep({not defined $_->[4];} values %{$s->working_pieces->{$index};}))
1005 0 0 if (substr($s->pieces, $index * 20, 20) eq &sha1($piece)) { }
1007 0 0 unless $s->_write($index, 0, $piece)
1019 0 0 unless scalar grep({$_;} split(//, substr(unpack('b*', ~$s->bitfield), 0, $s->piece_count + 1), 0))
1042 0 0 if $_->[0] == $index and $_->[1] == $offset
1045 0 0 unless grep {$_->[2] == $length if $_->[0] == $index and $_->[1] == $offset;} @{$s->peers->{$h}{'remote_requests'};}
1048 0 0 unless $_->[0] != $index or $_->[1] != $offset
1072 0 0 if $_->[0] == $index and $_->[1] == $offset
1075 0 0 unless grep {$_->[2] == $length if $_->[0] == $index and $_->[1] == $offset;} @{$s->peers->{$h}{'local_requests'};}
1079 0 0 unless $_->[0] != $index or $_->[1] != $offset
1095 0 0 if 5 > length($h->rbuf // '')
1101 0 0 if (vec($s->peers->{$h}{'reserved'}, 7, 1) & 4)
1102 0 0 if ($s->seed) { }
0 0 elsif (not $s->bitfield =~ /[^\0]/) { }
1123 0 0 if $s->state ne 'active'
1124 0 0 if $s->complete
1126 0 0 index(substr(unpack('b*', $relevence), 0, $s->piece_count + 1), '1', 0) != -1 ? :
1130 0 0 if ($interesting) { }
1131 0 0 if (not $p->{'local_interested'})
1137 0 0 if ($p->{'local_interested'})
1159 4 0 $end != int $end ? :
1164 0 0 if $s->state ne 'active'
1165 0 0 unless &isweak($p)
1169 0 0 if (scalar keys %{$s->working_pieces;} < 10) { }
1173 0 0 unless vec $p->{'bitfield'}, $index, 1 and not vec($s->bitfield, $index, 1)
1183 0 0 unless @indexes
1185 0 0 $index == $s->piece_count ? :
1190 0 0 int $block_count == $block_count ? :
1204 0 0 $offset == $offsets[-1] ? :
1208 0 0 unless $_block_size
1231 0 0 unless $_->[0] != $index or $_->[1] != $offset
1244 0 0 unless &isweak($s->working_pieces->{$index}{$offset}[3])
1278 4 3 if $s->state eq 'stopped'
1294 0 4 unless $s->state eq 'active'
1315 4 0 if $s->state eq 'active'
1317 0 4 if $s->state eq 'paused'
1324 0 0 unless $h