Branch Coverage

blib/lib/IO/Async/Loop.pm
Criterion Covered Total %
branch 222 344 64.5


line true false branch
160 0 98 unless $class->can("API_VERSION")
163 0 98 unless $class->API_VERSION >= "0.33"
181 97 1 if $IO::Async::Loop::METRICS
190 0 98 if ($old_timer != ($self->can("cancel_timer") != \&IO::Async::Loop::cancel_timer))
194 0 98 if ($old_timer)
207 28 35 if $IO::Async::Loop::METRICS
304 6 74 unless eval { do { local $SIG{'__WARN__'} = sub { } ; require $file } }
310 74 0 if $self = eval { do { $class->new } }
336 1 5 if defined $ENV{'IO_ASYNC_LOOP'}
338 2 4 if defined $LOOP
341 1 2 unless $class =~ /::/u
342 3 0 if $self = __try_new($class)
348 2 1 unless ($LOOP_NO_OS)
350 4 2 unless $class =~ /::/u
351 0 6 if $self = __try_new($class)
366 71 0 if $self = __try_new("IO::Async::Loop::$class")
400 1 1367 if (defined $notifier->parent)
404 1 1366 if (defined $notifier->loop)
419 66 1886 if $IO::Async::Loop::METRICS
442 1 919 if (defined $notifier->parent)
456 0 1169 unless exists $self->{'notifiers'}{$nkey}
459 36 1133 if $IO::Async::Loop::METRICS
542 6 4 wantarray ? :
812 55 13 if ($signal eq "CHLD")
814 0 55 unless caller eq "IO::Async::Loop"
818 65 3 unless ($self->{'sigattaches'}{$signal})
862 0 9 unless my $attaches = $self->{'sigattaches'}{$signal}
865 3 9 unless \$attaches->[$i] == $id
870 6 3 if (not @$attaches)
907 26 2 if $code
912 1 0 unless $f->is_ready
1156 1 3 if $params{'on_exit'}
1193 1 1 unless ref $on_finish
1199 0 1 if (my $on_error = delete $params{'on_error'})
1200 0 0 unless ref $on_error
1291 1 84 if $params{'on_finish'}
1294 1 83 unless ref $capture eq "ARRAY"
1299 6 77 if (my $child_stdin = delete $params{'stdin'})
1300 0 6 if ref $child_stdin
1309 1 174 unless grep {$_ eq $name;} "exitcode", "stdout", "stderr"
1311 67 107 if $name eq "stdout"
1312 46 128 if $name eq "stderr"
1319 3 79 if keys %params
1329 1 67 if ($fail_on_nonzero and $results{'exitcode'} > 0) { }
1342 79 0 if $cancel_signal
1393 2 39 unless ref $on_finish
1696 2 15 if ($extensions = delete $params{'extensions'} and @$extensions)
1702 0 2 unless $self->can($method)
1704 1 1 @others ? :
1714 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) { }
1718 0 2 if defined $handle
1727 0 1 if defined $handle
1738 8 7 if ($on_connect_error = $params{'on_connect_error'}) { }
0 7 elsif (not defined wantarray) { }
1746 4 11 if ($on_resolve_error = $params{'on_resolve_error'}) { }
0 11 elsif (not defined wantarray and exists $params{'host'} || exists $params{'local_host'}) { }
1760 7 8 if $handle
1762 8 7 if $on_done
1764 2 1 if $on_connect_error and $_[1] eq "connect"
1765 0 3 if $on_resolve_error and $_[1] eq "resolve"
1768 7 8 if defined wantarray
1961 8 4 unless exists $params{$_}
1962 0 4 if $params{'listener'}
1977 2 3 if ($extensions = delete $params{'extensions'} and @$extensions)
1981 0 2 if ($ext eq "SSL" and $IO::Async::SSL::VERSION < "0.12001")
1988 0 2 unless $self->can($method)
1990 1 1 @others ? :
1994 2 0 if $remove_on_error
2005 1 2 if ($params{'addr'} and not $params{'addrs'})
2010 1 2 if (my $handle = delete $params{'handle'}) { }
1 1 elsif (my $addrs = delete $params{'addrs'}) { }
1 0 elsif (defined $params{'service'}) { }
2014 0 1 unless $on_listen_error or defined wantarray
2019 0 1 unless $on_listen_error or defined wantarray
2021 0 1 unless $on_resolve_error or defined wantarray
2029 0 3 if $on_notifier
2030 2 1 if (my $on_listen = $params{'on_listen'})
2035 0 0 if $on_listen_error and $how eq "listen"
2036 0 0 if $on_resolve_error and $how eq "resolve"
2038 2 1 if $remove_on_error
2040 2 1 if defined wantarray
2064 0 2 unless not defined $on_fail or ref $on_fail
2067 0 2 if defined $params{'reuseaddr'} and not $params{'reuseaddr'}
2078 0 2 unless ($sock = "IO::Async::OS"->socket($family, $socktype, $proto))
2080 0 0 if $on_fail
2086 2 0 if ($reuseaddr)
2087 0 2 unless ($sock->sockopt(2, 1))
2089 0 0 if $on_fail
2094 0 2 if (defined $v6only and $family == 10)
2095 0 0 unless ($sock->setsockopt(41, 26, $v6only))
2097 0 0 if $on_fail
2102 0 2 unless ($sock->bind($address))
2104 0 0 if $on_fail
2108 0 2 unless ($sock->listen($queuesize))
2110 0 0 if $on_fail
2118 0 0 if $listenerr
2119 0 0 if $binderr
2120 0 0 if $sockopterr
2121 0 0 if $socketerr
2137 0 1 unless defined $gai_hints{'socktype'} or defined $gai_hints{'protocol'}
2230 0 334 unless my $code = $params{'code'}
2233 0 334 unless defined $kid
2235 30 304 if ($kid == 0)
2236 29 1 unless ($params{'keep_signals'})
2238 0 1943 if /^__(WARN|DIE)__$/u
2239 29 1914 if ref $SIG{$_} eq "CODE"
2249 0 0 unless defined $exitvalue
2254 9 295 if (defined $params{'on_exit'})
2258 10 294 if $IO::Async::Loop::METRICS
2315 0 0 unless eval { do { require threads } }
2317 0 0 unless my $code = $params{'code'}
2318 0 0 unless my $on_joined = $params{'on_joined'}
2322 0 0 unless ($self->{'thread_join_pipe'})
2323 0 0 unless (my $rd, $self->{'thread_join_pipe'}) = "IO::Async::OS"->pipepair
2331 0 0 unless sysread $rd, my $buffer, 8192
2339 0 0 unless my($thread, $on_joined) = @{delete $threadwatches->{$tid};}
2355 0 0 unless eval { do { $context eq "list" ? @ret = &$code() : ($context eq "scalar" ? $ret[0] = &$code() : &$code()); 1 } }
2356 0 0 $context eq 'scalar' ? :
0 0 if ($context eq 'list') { }
2364 0 0 if $died
2409 221 27 if $IO::Async::Loop::METRICS and $self->{'processing_start'}
2415 248 1216 if $IO::Async::Loop::METRICS
2469 0 801 unless my $handle = delete $params{'handle'}
2470 0 801 unless defined eval { do { $handle->fileno } }
2473 4 797 if $handle->blocking
2479 702 99 if (exists $params{'on_read_ready'})
2483 101 700 if (exists $params{'on_write_ready'})
2487 2 799 if (exists $params{'on_hangup'})
2488 0 2 unless $self->_CAN_ON_HANGUP
2492 0 801 if keys %params
2532 0 718 unless my $handle = delete $params{'handle'}
2534 35 683 unless my $watch = $self->{'iowatches'}{$handle->fileno}
2536 596 87 if (delete $params{'on_read_ready'})
2540 93 590 if (delete $params{'on_write_ready'})
2544 2 681 if (delete $params{'on_hangup'})
2545 0 2 unless $self->_CAN_ON_HANGUP
2549 670 0 unless ($watch->[1] or $watch->[2] or $watch->[3])
2553 0 683 if keys %params
2684 541 54 if (exists $args{'after'}) { }
54 0 elsif (exists $args{'at'}) { }
2694 0 595 if ($self->{'old_timer'}) { }
2724 0 523 if ($self->{'old_timer'}) { }
2740 54 541 if (exists $params{'time'}) { }
541 0 elsif (exists $params{'delay'}) { }
2744 0 541 exists $params{'now'} ? :
2773 0 0 if exists $params{'delay'}
2774 0 0 if exists $params{'time'}
2883 0 38 unless ref $code
2885 0 38 unless my $when = delete $params{'when'}
2888 0 38 unless $when eq "later"
2914 3 0 if defined $idx
2925 314 315 if not defined $zid or $zid == 0 or $zid == -1
2928 303 12 if (defined $childwatches->{$zid})
2933 14 301 if (defined $childwatches->{'0'})
2989 0 338 if ($self->API_VERSION < "0.76" and ($self->can("watch_child") // 0) != \&IO::Async::Loop::watch_child)
2997 0 338 if exists $childwatches->{$pid}
2999 55 283 unless ($self->{'childwatch_sigid'})
3006 15 40 if (defined $zid and $zid > 0)
3032 0 2 if ($self->API_VERSION < "0.76" and ($self->can("unwatch_child") // 0) != \&IO::Async::Loop::unwatch_child)
3042 2 0 if (not keys %$childwatches)
3073 32 1438 if @{$self->{'deferrals'};}
3075 0 1438 if (defined $self->{'sigproxy'} and not $params{'no_sigwait'})
3076 0 0 if not defined $$timeref or $$timeref > $MAX_SIGWAIT_TIME
3083 181 1257 unless defined $timequeue
3086 26 1231 unless defined $nexttime
3088 0 1231 exists $params{'now'} ? :
3091 3 1228 if ($timer_delay < 0) { }
72 1156 elsif (not defined $$timeref or $timer_delay < $$timeref) { }
3117 1276 194 if $timequeue