blib/lib/Linux/Event/_Socket/Descriptor.pm

filter: Statementstmt 92.4% 49 / 53 Branchbran 73.0% 19 / 26 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 90.0% 9 / 10 Podpod 0.0% 0 / 3 totaltotal 77.4% 79 / 102 CC 18 SCAR 19.5
CC
18
Cov
82%
for_class
11.9
declare_tls
6.9
_tls_for
3.0
CRAP 7.0
« blib/lib/Linux/Event/Framer/DecimalLength.pm ↑ Summary blib/lib/Linux/Event/Kernel/Timer.pm »
1 package Linux::Event::_Socket::Descriptor;
2 120 ▶use v5.36;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 120 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 120 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6  
7 120 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 120 ▶use mro ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 120 ▶use Linux::Event::_SocketConfig ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 120 my %TLS_DEFINITION;
12 my %CLASS_DESCRIPTOR;
13  
14 7 ▶sub declare_tls ($base, $target, $definition) {
Subroutine declare_tls: called CC=6 SCAR=19.3
Pod undocumented
15 7 ▶ croak 'TLS may be declared only for a Linux::Event stream-socket subclass'
Branch: 1 branch
BranchTrueFalseTotal
if $target eq $base or not $target->isa($base) 0 7 7
Condition33%1/3
$target eq $base or not $target->isa($base)
l!l&&r!l&&!r
007
MC/DC0%0/2
$target eq $base or not $target->isa($base)
$target eq $base not $target->isa($base)
Truth table33%1/3
A or not(B)
A= $target eq $baseB= not $target->isa($base)
ABresult
1X1
011
000
16 if $target eq $base || !$target->isa($base);
17 croak "$target already has a stream-socket descriptor"
18 7 ▶ if exists $CLASS_DESCRIPTOR{$target};
Branch: 1 branch
BranchTrueFalseTotal
if exists $CLASS_DESCRIPTOR{$target} 0 7 7
19 7 ▶ croak "$target already declares TLS" if exists $TLS_DEFINITION{$target};
Branch: 1 branch
BranchTrueFalseTotal
if exists $TLS_DEFINITION{$target} 1 6 7
20 6 ▶ croak 'TLS declaration must be a hash reference'
Branch: 1 branch
BranchTrueFalseTotal
if ref $definition ne "HASH" 0 6 6
21 if ref($definition) ne 'HASH';
22 6 $TLS_DEFINITION{$target} = $definition;
23 6 return;
24 }
25  
26 258 ▶sub _tls_for ($class) {
Subroutine _tls_for: called CC=3 SCAR=11.0
27 258 for my $package (@{ mro::get_linear_isa($class) }) {
28 1319 ▶ return $TLS_DEFINITION{$package} if exists $TLS_DEFINITION{$package};
Branch: 1 branch
BranchTrueFalseTotal
if exists $TLS_DEFINITION{$package} 3 1316 1319
29 }
30 255 return undef;
31 }
32  
33 103161 ▶sub for_class ($class) {
Subroutine for_class: called CC=11 SCAR=24.8
Pod undocumented
34 103161 ▶ return $CLASS_DESCRIPTOR{$class} if exists $CLASS_DESCRIPTOR{$class};
Branch: 1 branch
BranchTrueFalseTotal
if exists $CLASS_DESCRIPTOR{$class} 102901 260 103161
35 260 ▶ croak 'Linux::Event::_Socket::Stream is a private implementation base; subclass Linux::Event::IO::Sock::Stream'
Branch: 1 branch
BranchTrueFalseTotal
if $class eq "Linux::Event::_Socket::Stream" 1 259 260
36 if $class eq 'Linux::Event::_Socket::Stream';
37 259 ▶ croak "$class is not a Linux::Event stream-socket class"
Branch: 1 branch
BranchTrueFalseTotal
unless $class->isa("Linux::Event::_Socket::Stream") 0 259 259
38 if !$class->isa('Linux::Event::_Socket::Stream');
39  
40 259 my %option = map { $_ => undef } Linux::Event::_SocketConfig::names();
41 259 ▶ if (my $configure = $class->can('socket_options')) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $configure = $class->can("socket_options")) 5 254 259
42 5 my @configured = $configure->($class);
43 5 my %configured;
44 5 ▶ if (@configured == 1 && ref($configured[0]) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (@configured == 1 and ref $configured[0] eq 'HASH') { } 0 5 5
Condition33%1/3
@configured == 1 and ref $configured[0] eq "HASH"
!ll&&!rl&&r
500
MC/DC0%0/2
@configured == 1 and ref $configured[0] eq "HASH"
@configured == 1 ref $configured[0] eq "HASH"
Truth table33%1/3
A and B
A= @configured == 1B= ref $configured[0] eq "HASH"
ABresult
0X0
100
111
45 0 %configured = %{ $configured[0] };
46 } else {
47 5 ▶ croak "$class socket_options() returned an odd option list"
Branch: 1 branch
BranchTrueFalseTotal
if @configured % 2 0 5 5
48 if @configured % 2;
49 5 %configured = @configured;
50 }
51 5 my @unknown = grep { !exists $option{$_} } keys %configured;
52 5 ▶ croak "$class socket_options() returned unknown options: "
Branch: 1 branch
BranchTrueFalseTotal
if @unknown 0 5 5
53 . join(', ', sort @unknown) if @unknown;
54 5 @option{keys %configured} = values %configured;
55 }
56 259 for my $name (keys %option) {
57 2070 ▶ if (defined $option{$name}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $option{$name}) { } 11 2059 2070
58 $option{$name} = Linux::Event::_SocketConfig::normalize(
59 11 $class, $name, $option{$name},
60 );
61 } else {
62 2059 delete $option{$name};
63 }
64 }
65 258 return $CLASS_DESCRIPTOR{$class} = {
66 options => \%option,
67 tls => _tls_for($class),
68 configure_socket => scalar $class->can('configure_socket'),
69 };
70 }
71  
72 0 ▶sub clear_cache () { %CLASS_DESCRIPTOR = (); return }
Subroutine clear_cache: not called CC=1 SCAR=6.9
Pod undocumented
73  
74 120 1;
« blib/lib/Linux/Event/Framer/DecimalLength.pm ↑ Summary blib/lib/Linux/Event/Kernel/Timer.pm »