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 ? :
590 0 8 unless @$deck
609 0 0 if $s->state eq 'stopped'
618 4 0 defined $s->metadata->{'announce'} ? :
0 4 defined $s->metadata->{'announce-list'} ? :
636 0 3 if $a++ > 10
645 0 4 if $tier->{'failures'} > 5
646 0 4 if $#{$$tier{'urls'};} < 0
647 0 4 unless $tier->{'urls'}[0] =~ m[^https?://.+]
655 4 0 $e ? :
671 0 0 if ($hdr->{'Status'} =~ /^2/) { }
673 0 0 if (defined $reply->{'failure reason'}) { }
684 0 0 if $reply->{'peers'}
688 0 0 if $reply->{'peers6'}
695 0 0 if $s->state eq 'stopped'
799 0 0 unless $s->_left
807 0 0 $_->{'peers'} ? :
0 0 $_->{'peers6'} ? :
809 0 0 unless @cache
811 0 0 if $i > 10
813 0 0 if scalar keys %{$s->peers;} > 100
842 0 0 $fatal ? :
846 0 0 if not $fatal
874 0 0 unless $packet
879 0 0 if (defined $packet->{'error'}) { }
0 0 elsif ($packet->{'type'} == $AnyEvent::BitTorrent::HANDSHAKE) { }
884 0 0 if ref $packet->{'payload'} ne 'ARRAY'
887 0 0 if $packet->{'payload'}[1] ne $s->infohash
904 0 0 unless $packet
909 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::PORT) { }
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) { }
921 0 0 if $packet->{'payload'}[1] ne $s->infohash
939 0 0 unless (vec($s->peers->{$h}{'reserved'}, 7, 1) & 4)
943 0 0 unless defined $s->working_pieces->{$req->[0]}{$req->[1]}[4]
984 0 0 if $_->[0] == $index and $_->[1] == $offset
987 0 0 unless grep {$_->[2] == length $data if $_->[0] == $index and $_->[1] == $offset;} @{$s->peers->{$h}{'local_requests'};}
990 0 0 unless $_->[0] != $index or $_->[1] != $offset
998 0 0 if (0 == scalar grep({not defined $_->[4];} values %{$s->working_pieces->{$index};}))
1004 0 0 if (substr($s->pieces, $index * 20, 20) eq &sha1($piece)) { }
1007 0 0 if $s->_write($index, 0, $piece) == length $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
1076 0 0 if $_->[0] == $index and $_->[1] == $offset
1079 0 0 unless grep {$_->[2] == $length if $_->[0] == $index and $_->[1] == $offset;} @{$s->peers->{$h}{'local_requests'};}
1083 0 0 unless $_->[0] != $index or $_->[1] != $offset
1099 0 0 if 5 > length($h->rbuf // '')
1105 0 0 if (vec($s->peers->{$h}{'reserved'}, 7, 1) & 4)
1106 0 0 if ($s->seed) { }
0 0 elsif (not $s->bitfield =~ /[^\0]/) { }
1127 0 0 if $s->state ne 'active'
1128 0 0 if $s->complete
1130 0 0 index(substr(unpack('b*', $relevence), 0, $s->piece_count + 1), '1', 0) != -1 ? :
1134 0 0 if ($interesting) { }
1135 0 0 if (not $p->{'local_interested'})
1141 0 0 if ($p->{'local_interested'})
1163 4 0 $end != int $end ? :
1168 0 0 if $s->state ne 'active'
1169 0 0 unless &isweak($p)
1173 0 0 if (scalar keys %{$s->working_pieces;} < 10) { }
1177 0 0 vec($p->{'bitfield'}, $index, 1) && !vec($s->bitfield, $index, 1) ? :
1188 0 0 unless @indexes
1190 0 0 $index == $s->piece_count ? :
1195 0 0 int $block_count == $block_count ? :
1207 0 0 $offset == $offsets[-1] ? :
1233 0 0 unless $_->[0] != $index or $_->[1] != $offset
1246 0 0 unless &isweak($s->working_pieces->{$index}{$offset}[3])
1280 4 3 if $s->state eq 'stopped'
1296 0 4 unless $s->state eq 'active'
1317 4 0 if $s->state eq 'active'
1319 0 4 if $s->state eq 'paused'
1326 0 0 unless $h