Branch Coverage

blib/lib/Net/BitTorrent.pm
Criterion Covered Total %
branch 133 192 69.2


line true false branch
14 0 0 $^O eq 'MSWin32' ? :
15 0 0 $^O eq 'MSWin32' ? :
65 42 5 if (defined $args)
66 3 39 if (ref $args ne 'HASH')
71 11 28 if defined $$args{'LocalHost'}
76 2 4 ref $$args{'LocalPort'} eq 'ARRAY' ? :
6 33 defined $$args{'LocalPort'} ? :
85 41 5 if $self->_socket_open_tcp($host, $port) and $self->_socket_open_udp($host, $port)
117 1 43 unless defined $_tcp{refaddr $self}
125 0 3 unless defined $_tcp{refaddr $self}
133 0 25 unless defined $_udp{refaddr $self}
141 0 3 unless defined $_udp{refaddr $self}
155 0 6 if (not defined $value or $value != _MSE_DISABLED() and $value != _MSE_ENABLED() and $value != _MSE_FORCED())
169 0 1 unless (defined $value and $value =~ /^\d+$/ and $value)
179 0 1 unless (defined $value and $value =~ /^\d+$/)
189 0 0 if (not defined $value && $value =~ /^\d+$/ or $value < 1)
199 0 0 if (not defined $value && $value =~ /^\d+$/ or $value < 1)
209 0 6 if (not defined $value && $value =~ /^\d+$/ or $value < 1)
219 0 15 unless (defined $value and $value =~ /^[10]$/)
235 0 1381 $timeout < 0 ? :
1381 2 defined $timeout && $timeout =~ /^(\-1|\d+)\.?\d*$/ ? :
243 7342 152 if $_connections{refaddr $self}{$fileno}{'Mode'} =~ /r/
245 4657 2837 if $_connections{refaddr $self}{$fileno}{'Mode'} =~ /w/
250 812 571 if $nfound and $nfound != -1
272 3 2400 unless (defined $connection)
276 1 2399 unless (blessed $connection)
282 105 2294 if (not $_sock or ref $_sock ne 'GLOB')
283 0 2294 unless ($mode and $mode =~ /^(?:ro|rw|wo)$/)
296 0 98 unless (defined $connection)
300 0 98 unless (blessed $connection)
306 31 67 unless defined $socket
312 0 55 unless ($self or not blessed $self || !$self->isa('Net::BitTorrent'))
319 0 46 unless ($_tcp{refaddr $self} or $host)
324 1 54 if (defined $port and not $port =~ /^\d+$/)
334 3 51 if ($host and not $host =~ /^(?:(?:(?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.]?){4})$/) { }
337 2 1 unless my($name, $aliases, $addrtype, $length, @addrs) = gethostbyname $host
343 0 52 unless socket my $_tcp, 2, 1, getprotobyname 'tcp'
357 5 47 unless bind $_tcp, pack_sockaddr_in($port, $_packed_host)
359 0 47 unless listen $_tcp, 1
360 0 47 unless $_connections{refaddr $self}{fileno $_tcp} = {'Object', $self, 'Mode', 'ro'}
364 6 0 if (defined $_tcp{refaddr $self} and fileno $_tcp{refaddr $self} and defined $_connections{refaddr $self}{fileno $_tcp{refaddr $self}})
376 0 50 unless ($self or not blessed $self || !$self->isa('Net::BitTorrent'))
383 0 0 unless ($_tcp{refaddr $self} or $host)
388 1 49 if (defined $port and not $port =~ /^\d+$/)
400 3 46 if ($host and not $host =~ /^(?:(?:(?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.]?){4})$/) { }
403 2 1 unless my($name, $aliases, $addrtype, $length, @addrs) = gethostbyname $host
409 0 47 unless socket my $_udp, 2, 2, getprotobyname 'udp'
423 0 47 unless bind $_udp, pack_sockaddr_in($port, $_packed_host)
425 0 47 unless $_connections{refaddr $self}{fileno $_udp} = {'Object', $self, 'Mode', 'ro'}
429 6 0 if ($_udp{refaddr $self} and fileno $_udp{refaddr $self} and defined $_connections{refaddr $self}{fileno $_udp{refaddr $self}})
441 0 812 unless ($rin and ref $rin and ref $rin eq 'SCALAR' and ($win and ref $win and ref $win eq 'SCALAR') and ($ein and ref $ein and ref $ein eq 'SCALAR'))
451 0 6346 unless defined $_connections{refaddr $self}{$fileno}
452 812 5534 if ($_tcp{refaddr $self} and $fileno == fileno $_tcp{refaddr $self}) { }
812 4722 elsif ($_udp{refaddr $self} and $fileno == fileno $_udp{refaddr $self}) { }
454 67 745 if (vec($$rin, $fileno, 1) == 1)
456 67 0 if (scalar grep({not $$_{'Object'}->torrent if $$_{'Object'}->isa('Net::BitTorrent::Peer');} values %{$_connections{refaddr $self};}) < $_half_open{refaddr $self})
457 406 134 if $$_{'Object'}->isa('Net::BitTorrent::Peer')
463 0 67 unless accept my $new_socket, $_tcp{refaddr $self}
474 198 614 if (vec($$rin, $fileno, 1) == 1)
476 0 198 unless my $paddr = recv($_udp{refaddr $self}, my $data, 1024, 0)
479 75 123 if ($__UDP_OBJECT_CACHE{refaddr $self}{$paddr}{'Object'}) { }
480 32 43 unless $__UDP_OBJECT_CACHE{refaddr $self}{$paddr}{'Object'}->_on_data($paddr, $data)
490 0 0 if $_->isa('Net::BitTorrent::Torrent::Tracker::UDP')
496 0 0 if ($tracker and $tracker->_on_data($paddr, $data))
507 57 66 if ($_use_dht{refaddr $self} and $_dht{refaddr $self}->_on_data($paddr, $data))
518 0 4722 $_max_dl_rate{refaddr $self} ? :
527 0 4722 $_max_ul_rate{refaddr $self} ? :
540 4341 53 if ($read or $write or $error)
544 4650 19 defined $this_r ? :
545 4650 19 defined $this_w ? :
558 0 76 unless $infohash =~ /^[\d|a-f]{40}$/i
561 47 29 $torrents{refaddr $self}{lc $infohash} ? :
569 1 30 if (ref $args ne 'HASH')
576 0 30 unless defined $torrent
577 1 29 if $self->_locate_torrent($torrent->infohash)
583 1 1 unless (blessed $torrent and $torrent->isa('Net::BitTorrent::Torrent'))
600 0 32 unless ___check_event($type)
608 0 2118 unless ___check_event($type)
612 109 2009 $_event{refaddr $self}{$type} ? :
638 1 2967 if (not $args or ref $args ne 'HASH')
643 1 2966 unless ($$args{'Object'} and blessed($$args{'Object'}))
648 0 2966 unless ($$args{'Time'} and $$args{'Time'} =~ /^\d+(?:\.\d+)?$/)
653 0 2966 if (not $$args{'Code'} or ref $$args{'Code'} ne 'CODE')
668 0 1 unless ($tid)
672 0 1 unless ($_schedule{refaddr $self}{$tid})
684 2133 32700 if ($_schedule{refaddr $self}{$job}{'Timestamp'} <= time)
685 2092 41 if defined $_schedule{refaddr $self}{$job}{'Object'}
696 0 2966 if defined $_[1]
700 47 0 $_tid{refaddr $self} =~ /\0/ ? :
47 2919 $_tid{refaddr $self} =~ /^z*(\0*)$/ ? :
745 2 0 $_use_dht{refaddr $self} ? :
6 2 !$advanced ? :
747 6 2 defined wantarray ? :
766 0 6 if $_tcp{refaddr $self}
767 0 6 if $_udp{refaddr $self}
769 0 0 if $$conn{'Object'}