Branch Coverage

blib/lib/IO/Async/Loop.pm
Criterion Covered Total %
branch 223 346 64.4


line true false branch
159 0 101 unless $class->can("API_VERSION")
162 0 101 unless $class->API_VERSION >= "0.33"
180 100 1 if $IO::Async::Loop::METRICS
189 0 101 if ($old_timer != ($self->can("cancel_timer") != \&IO::Async::Loop::cancel_timer))
193 0 101 if ($old_timer)
206 28 35 if $IO::Async::Loop::METRICS
303 6 77 unless eval { do { local $SIG{'__WARN__'} = sub { } ; require $file } }
309 77 0 if $self = eval { do { $class->new } }
335 1 5 if defined $ENV{'IO_ASYNC_LOOP'}
337 2 4 if defined $LOOP
340 1 2 unless $class =~ /::/
341 3 0 if $self = __try_new($class)
347 2 1 unless ($LOOP_NO_OS)
349 4 2 unless $class =~ /::/
350 0 6 if $self = __try_new($class)
365 74 0 if $self = __try_new("IO::Async::Loop::$class")
399 1 1369 if (defined $notifier->parent)
403 1 1368 if (defined $notifier->loop)
418 66 1888 if $IO::Async::Loop::METRICS
441 1 873 if (defined $notifier->parent)
455 0 1169 unless exists $self->{'notifiers'}{$nkey}
458 36 1133 if $IO::Async::Loop::METRICS
541 6 4 wantarray ? :
811 57 13 if ($signal eq "CHLD")
813 0 57 unless caller eq "IO::Async::Loop"
817 67 3 unless ($self->{'sigattaches'}{$signal})
861 0 9 unless my $attaches = $self->{'sigattaches'}{$signal}
864 3 9 unless \$attaches->[$i] == $id
869 6 3 if (not @$attaches)
906 37 2 if $code
911 1 0 unless $f->is_ready
1155 1 3 if $params{'on_exit'}
1192 1 1 unless ref $on_finish
1198 0 1 if (my $on_error = delete $params{'on_error'})
1199 0 0 unless ref $on_error
1290 1 84 if $params{'on_finish'}
1293 1 83 unless ref $capture eq "ARRAY"
1298 6 77 if (my $child_stdin = delete $params{'stdin'})
1299 0 6 if ref $child_stdin
1308 1 174 unless grep {$_ eq $name;} "exitcode", "stdout", "stderr"
1310 67 107 if $name eq "stdout"
1311 46 128 if $name eq "stderr"
1318 3 79 if keys %params
1328 1 67 if ($fail_on_nonzero and $results{'exitcode'} > 0) { }
1341 79 0 if $cancel_signal
1392 2 39 unless ref $on_finish
1695 2 15 if ($extensions = delete $params{'extensions'} and @$extensions)
1701 0 2 unless $self->can($method)
1703 1 1 @others ? :
1713 5 10 if (my $on_connected = delete $params{'on_connected'}) { }
2 8 elsif (my $on_stream = delete $params{'on_stream'}) { }
1 7 elsif (my $on_socket = delete $params{'on_socket'}) { }
0 7 elsif (not defined wantarray) { }
1717 0 2 if defined $handle
1726 0 1 if defined $handle
1737 8 7 if ($on_connect_error = $params{'on_connect_error'}) { }
0 7 elsif (not defined wantarray) { }
1745 4 11 if ($on_resolve_error = $params{'on_resolve_error'}) { }
0 11 elsif (not defined wantarray and exists $params{'host'} || exists $params{'local_host'}) { }
1759 7 8 if $handle
1761 8 7 if $on_done
1763 2 1 if $on_connect_error and $_[1] eq "connect"
1764 0 3 if $on_resolve_error and $_[1] eq "resolve"
1767 7 8 if defined wantarray
1960 8 4 unless exists $params{$_}
1961 0 4 if $params{'listener'}
1976 2 3 if ($extensions = delete $params{'extensions'} and @$extensions)
1980 0 2 if ($ext eq "SSL" and $IO::Async::SSL::VERSION < "0.12001")
1987 0 2 unless $self->can($method)
1989 1 1 @others ? :
1993 2 0 if $remove_on_error
2004 1 2 if ($params{'addr'} and not $params{'addrs'})
2009 1 2 if (my $handle = delete $params{'handle'}) { }
1 1 elsif (my $addrs = delete $params{'addrs'}) { }
1 0 elsif (defined $params{'service'}) { }
2013 0 1 unless $on_listen_error or defined wantarray
2018 0 1 unless $on_listen_error or defined wantarray
2020 0 1 unless $on_resolve_error or defined wantarray
2028 0 3 if $on_notifier
2029 2 1 if (my $on_listen = $params{'on_listen'})
2034 0 0 if $on_listen_error and $how eq "listen"
2035 0 0 if $on_resolve_error and $how eq "resolve"
2037 2 1 if $remove_on_error
2039 2 1 if defined wantarray
2063 0 2 unless not defined $on_fail or ref $on_fail
2066 0 2 if defined $params{'reuseaddr'} and not $params{'reuseaddr'}
2077 0 2 unless ($sock = "IO::Async::OS"->socket($family, $socktype, $proto))
2079 0 0 if $on_fail
2085 2 0 if ($reuseaddr)
2086 0 2 unless ($sock->sockopt(2, 1))
2088 0 0 if $on_fail
2093 0 2 if (defined $v6only and $family == 10)
2094 0 0 unless ($sock->setsockopt(41, 26, $v6only))
2096 0 0 if $on_fail
2101 0 2 unless ($sock->bind($address))
2103 0 0 if $on_fail
2107 0 2 unless ($sock->listen($queuesize))
2109 0 0 if $on_fail
2117 0 0 if $listenerr
2118 0 0 if $binderr
2119 0 0 if $sockopterr
2120 0 0 if $socketerr
2130 0 1 unless defined $service
2136 0 1 unless defined $gai_hints{'socktype'} or defined $gai_hints{'protocol'}
2229 0 334 unless my $code = $params{'code'}
2232 0 334 unless defined $kid
2234 30 304 if ($kid == 0)
2235 29 1 unless ($params{'keep_signals'})
2237 0 1972 if /^__(WARN|DIE)__$/
2238 29 1943 if ref $SIG{$_} eq "CODE"
2248 0 0 unless defined $exitvalue
2253 9 295 if (defined $params{'on_exit'})
2257 10 294 if $IO::Async::Loop::METRICS
2314 0 0 unless eval { do { require threads } }
2316 0 0 unless my $code = $params{'code'}
2317 0 0 unless my $on_joined = $params{'on_joined'}
2321 0 0 unless ($self->{'thread_join_pipe'})
2322 0 0 unless (my $rd, $self->{'thread_join_pipe'}) = "IO::Async::OS"->pipepair
2330 0 0 unless sysread $rd, my $buffer, 8192
2338 0 0 unless my($thread, $on_joined) = @{delete $threadwatches->{$tid};}
2354 0 0 unless eval { do { $context eq "list" ? @ret = &$code() : ($context eq "scalar" ? $ret[0] = &$code() : &$code()); 1 } }
2355 0 0 $context eq 'scalar' ? :
0 0 $context eq 'list' ? :
2363 0 0 if $died
2408 200 27 if $IO::Async::Loop::METRICS and $self->{'processing_start'}
2414 227 1119 if $IO::Async::Loop::METRICS
2463 0 820 unless my $handle = delete $params{'handle'}
2464 0 820 unless defined eval { do { $handle->fileno } }
2467 22 798 if $handle->blocking
2473 710 110 if (exists $params{'on_read_ready'})
2477 112 708 if (exists $params{'on_write_ready'})
2481 2 818 if (exists $params{'on_hangup'})
2482 0 2 unless $self->_CAN_ON_HANGUP
2486 0 820 if keys %params
2526 0 741 unless my $handle = delete $params{'handle'}
2528 35 706 unless my $watch = $self->{'iowatches'}{$handle->fileno}
2530 604 102 if (delete $params{'on_read_ready'})
2534 104 602 if (delete $params{'on_write_ready'})
2538 2 704 if (delete $params{'on_hangup'})
2539 0 2 unless $self->_CAN_ON_HANGUP
2543 693 0 unless ($watch->[1] or $watch->[2] or $watch->[3])
2547 0 706 if keys %params
2678 571 52 if (exists $args{'after'}) { }
52 0 elsif (exists $args{'at'}) { }
2688 0 623 if ($self->{'old_timer'}) { }
2718 0 537 if ($self->{'old_timer'}) { }
2734 52 571 if (exists $params{'time'}) { }
571 0 elsif (exists $params{'delay'}) { }
2738 0 571 exists $params{'now'} ? :
2767 0 0 if exists $params{'delay'}
2768 0 0 if exists $params{'time'}
2877 0 49 unless ref $code
2879 0 49 unless my $when = delete $params{'when'}
2882 0 49 unless $when eq "later"
2908 3 0 if defined $idx
2919 308 308 if not defined $zid or $zid == 0 or $zid == -1
2922 296 12 if (defined $childwatches->{$zid})
2927 14 294 if (defined $childwatches->{'0'})
2983 0 341 if ($self->API_VERSION < "0.76" and ($self->can("watch_child") // 0) != \&IO::Async::Loop::watch_child)
2991 0 341 if exists $childwatches->{$pid}
2993 57 284 unless ($self->{'childwatch_sigid'})
3000 26 31 if (defined $zid and $zid > 0)
3026 0 2 if ($self->API_VERSION < "0.76" and ($self->can("unwatch_child") // 0) != \&IO::Async::Loop::unwatch_child)
3036 2 0 if (not keys %$childwatches)
3067 43 1309 if @{$self->{'deferrals'};}
3069 0 1309 if (defined $self->{'sigproxy'} and not $params{'no_sigwait'})
3070 0 0 if not defined $$timeref or $$timeref > $MAX_SIGWAIT_TIME
3077 144 1165 unless defined $timequeue
3080 56 1109 unless defined $nexttime
3082 0 1109 exists $params{'now'} ? :
3085 3 1106 if ($timer_delay < 0) { }
86 1020 elsif (not defined $$timeref or $timer_delay < $$timeref) { }
3111 1188 164 if $timequeue