blib/lib/Linux/Event/_IO.pm

filter: Statementstmt 59.4% 22 / 37 Branchbran 50.0% 12 / 24 Conditioncond 26.6% 4 / 15 MC/DCmcdc 12.5% 1 / 8 Subroutinesub 85.7% 6 / 7 Podpod n/a totaltotal 49.4% 45 / 91 CC 19 SCAR 35.9
CC
19
Cov
50%
_constructor_handles
90.0
_guard_transition_resource_kind
9.8
_transition_resource_kind
4.0
CRAP 36.3
« blib/lib/Linux/Event/_Socket/Listener.pm ↑ Summary bench/run-stream-payload-sweep.pl »
1 package Linux::Event::_IO;
2 134 ▶use v5.36;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 134 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 134 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6  
7 134 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 0 ▶sub _constructor_handles ($method, $option) {
Subroutine _constructor_handles: not called CC=9 SCAR=45.0
10 0 my $fh = $option->{fh};
11 0 my $read_fh = $option->{read_fh};
12 0 my $write_fh = $option->{write_fh};
13  
14 0 ▶ croak "$method(): fh cannot be combined with read_fh or write_fh"
Branch: 1 branch
BranchTrueFalseTotal
if defined $fh and defined $read_fh || defined $write_fh 0 0 0
Condition0%0/6
defined $fh and defined $read_fh || defined $write_fh
!ll&&!rl&&r
000
defined $read_fh or defined $write_fh
l!l&&r!l&&!r
000
MC/DC0%0/3
defined $fh and defined $read_fh || defined $write_fh
defined $fh defined $read_fh defined $write_fh
Truth table0%0/4
A and B or C
A= defined $fhB= defined $read_fhC= defined $write_fh
ABCresult
0XX0
1000
11X1
1011
15 if defined($fh) && (defined($read_fh) || defined($write_fh));
16 0 ▶ if (defined $fh) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fh) 0 0 0
17 0 $read_fh = $fh;
18 0 $write_fh = $fh;
19 }
20  
21 0 my @handle;
22 my %seen;
23 0 for my $pair ([read_fh => $read_fh], [write_fh => $write_fh]) {
24 0 ▶ next if !defined $pair->[1];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $pair->[1] 0 0 0
25 0 my $fd = fileno($pair->[1]);
26 0 ▶ croak "$method(): $pair->[0] must be a filehandle" if !defined $fd;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fd 0 0 0
27 0 ▶ next if $seen{$fd}++;
Branch: 1 branch
BranchTrueFalseTotal
if $seen{$fd}++ 0 0 0
28 0 push @handle, [$pair->[0], $pair->[1], $fd];
29 }
30 0 return @handle;
31 }
32  
33 304 ▶sub _transition_resource_kind ($target) {
Subroutine _transition_resource_kind: called CC=4 SCAR=13.9
34 304 ▶ return 'pipe' if $target->isa('Linux::Event::IO::Pipe');
Branch: 1 branch
BranchTrueFalseTotal
if $target->isa("Linux::Event::IO::Pipe") 8 296 304
35 296 ▶ return 'tty' if $target->isa('Linux::Event::IO::TTY');
Branch: 1 branch
BranchTrueFalseTotal
if $target->isa("Linux::Event::IO::TTY") 6 290 296
36 290 ▶ return 'stream-socket'
Branch: 1 branch
BranchTrueFalseTotal
if $target->isa("Linux::Event::IO::Sock::Stream") 288 2 290
37 if $target->isa('Linux::Event::IO::Sock::Stream');
38 2 return undef;
39 }
40  
41 153 ▶sub _guard_transition_resource_kind ($self, $class) {
Subroutine _guard_transition_resource_kind: called CC=8 SCAR=22.8
42 153 ▶ return if !defined($class) || ref($class) || $class eq '';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $class or ref $class or $class eq "" 0 153 153
Condition33%2/6
not defined $class or ref $class or $class eq ""
l!l&&r!l&&!r
00153
not defined $class or ref $class
l!l&&r!l&&!r
00153
MC/DC0%0/3
not defined $class or ref $class or $class eq ""
not defined $class ref $class $class eq ""
Truth table25%1/4
not(A) or B or C
A= not defined $classB= ref $classC= $class eq ""
ABCresult
1XX1
01X1
0011
0000
43  
44 153 my $source_kind = _transition_resource_kind($self);
45 153 ▶ return if !defined $source_kind;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $source_kind 2 151 153
46  
47 151 my $target_kind = _transition_resource_kind($class);
48 151 ▶ croak 'transition_to(): cannot change ordered-byte resource kind ('
Branch: 2 branches
BranchTrueFalseTotal
if not defined $target_kind or $source_kind ne $target_kind 8 143 151
defined $target_kind ? : 8 0 8
Condition66%2/3
not defined $target_kind or $source_kind ne $target_kind
l!l&&r!l&&!r
08143
MC/DC50%1/2
not defined $target_kind or $source_kind ne $target_kind
not defined $target_kind $source_kind ne $target_kind
Truth table66%2/3
not(A) or B
A= not defined $target_kindB= $source_kind ne $target_kind
ABresult
1X1
011
000
49 . $source_kind . ' -> '
50 . (defined($target_kind) ? $target_kind : 'other') . ')'
51 if !defined($target_kind) || $source_kind ne $target_kind;
52 143 return;
53 }
54  
55 134 1;
« blib/lib/Linux/Event/_Socket/Listener.pm ↑ Summary bench/run-stream-payload-sweep.pl »