Ping/TCP.pm

filter: Statementstmt 97.1% 34 / 35 Branchbran 66.6% 4 / 6 Conditioncond 44.4% 4 / 9 MC/DCmcdc 16.6% 1 / 6 Subroutinesub 88.8% 8 / 9 Podpod 0.0% 0 / 1 totaltotal 77.2% 51 / 66 CC 7 SCAR 11.0
CC
7
Cov
84%
__ANON__
5.5
ping
3.3
__ANON__
2.0
CRAP 3.0
« Ping.pm ↑ Summary
1 package Net::Async::Ping::TCP;
2 1 $Net::Async::Ping::TCP::VERSION = '0.001001';
3 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings NONFATAL => 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use Future;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use POSIX 'ECONNREFUSED';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Time::HiRes;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 has default_timeout => (
13 is => 'ro',
14 default => 5,
15 );
16  
17 1 has service_check => ( is => 'rw' );
18  
19 1 has bind => ( is => 'rw' );
20  
21 1 has port_number => (
22 is => 'rw',
23 default => 7,
24 );
25  
26 sub ping {
27 2 ▶ my ($self, $loop, $host, $timeout) = @_;
Subroutine ping: called CC=3 SCAR=11.8
Pod undocumented
28 2 ▶ $timeout ||= $self->default_timeout;
Condition33%1/3
$timeout ||= $self->default_timeout
l!l&&r!l&&!r
020
MC/DC0%0/2
$timeout ||= $self->default_timeout
$timeout $self->default_timeout
Truth table33%1/3
A ||= B
A= $timeoutB= $self->default_timeout
ABresult
1X1
011
000
29  
30 2 my $service_check = $self->service_check;
31  
32 2 my $t0 = [Time::HiRes::gettimeofday];
33  
34 return Future->wait_any(
35 $loop->connect(
36 host => $host,
37 service => $self->port_number,
38 socktype => 'stream',
39 ($self->bind ? (
40 local_host => $self->bind,
41 ) : ()),
42 ),
43 $loop->timeout_future(after => $timeout)
44 )
45 ->then(
46 0 ▶ sub { Future->done(Time::HiRes::tv_interval($t0)) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
47 sub {
48 2 ▶ my ($human, $layer) = @_;
Subroutine __ANON__: called CC=5 SCAR=17.0
49 2 my $ex = pop;
50 2 ▶ if ($layer && $layer eq 'connect') {
Branch: 1 branch
BranchTrueFalseTotal
if ($layer and $layer eq "connect") 1 1 2
Condition66%2/3
$layer and $layer eq "connect"
!ll&&!rl&&r
101
MC/DC50%1/2
$layer and $layer eq "connect"
$layer $layer eq "connect"
Truth table66%2/3
A and B
A= $layerB= $layer eq "connect"
ABresult
0X0
100
111
51 1 ▶ return Future->done(Time::HiRes::tv_interval($t0))
Branch: 1 branch
BranchTrueFalseTotal
if not $service_check and $ex == 111 1 0 1
Condition33%1/3
not $service_check and $ex == 111
!ll&&!rl&&r
001
MC/DC0%0/2
not $service_check and $ex == 111
not $service_check $ex == 111
Truth table33%1/3
not(A) and B
A= not $service_checkB= $ex == 111
ABresult
0X0
100
111
52 if !$service_check && $ex == ECONNREFUSED;
53 }
54 1 Future->fail(Time::HiRes::tv_interval($t0))
55 },
56 )
57 2 ▶}
Branch: 1 branch
BranchTrueFalseTotal
$self->bind ? : 0 2 2
58  
59 1 1;
60  
61 __END__
« Ping.pm ↑ Summary