blib/lib/Linux/Event/IO/Pipe.pm

filter: Statementstmt 100% 25 / 25 Branchbran 75.0% 6 / 8 Conditioncond 50.0% 3 / 6 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 1 totaltotal 82.6% 43 / 52 CC 7 SCAR 14.9
CC
7
Cov
87%
new
7.9
BEGIN
1.0
BEGIN
1.0
CRAP 4.4
« bench/run-stream-transition-bench.pl ↑ Summary bench/run-performance-regression.pl »
1 package Linux::Event::IO::Pipe;
2 10 ▶use v5.36;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 10 our $VERSION = '0.119';
7  
8 10 ▶use parent 'Linux::Event::_ByteStream';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 10 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 # Linux fcntl.h: F_LINUX_SPECIFIC_BASE + 8. Linux::Event is Linux-only and
12 # F_GETPIPE_SZ succeeds only for pipe/FIFO descriptors, so this avoids the
13 # heavier stat-backed -p file test while preserving the concrete leaf contract.
14 10 ▶use constant _F_GETPIPE_SZ => 1032;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 11 ▶sub _is_pipe ($fh) {
Subroutine _is_pipe: called CC=1 SCAR=0.0
17 11 return defined fcntl($fh, _F_GETPIPE_SZ, 0);
18 }
19  
20 11 ▶sub new ($class, %option) {
Subroutine new: called CC=7 SCAR=20.7
Pod undocumented
21 11 ▶ if (defined(my $fh = $option{fh})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $fh = $option{'fh'})) { } 1 10 11
22 1 ▶ croak 'new(): fh is not a pipe or FIFO' if !_is_pipe($fh);
Branch: 1 branch
BranchTrueFalseTotal
unless _is_pipe($fh) 1 0 1
23 } else {
24 croak 'new(): read_fh is not a pipe or FIFO'
25 10 ▶ if defined($option{read_fh}) && !_is_pipe($option{read_fh});
Branch: 1 branch
BranchTrueFalseTotal
if defined $option{"read_fh"} and not _is_pipe($option{"read_fh"}) 1 9 10
Condition66%2/3
defined $option{"read_fh"} and not _is_pipe($option{"read_fh"})
!ll&&!rl&&r
091
MC/DC50%1/2
defined $option{"read_fh"} and not _is_pipe($option{"read_fh"})
defined $option{"read_fh"} not _is_pipe($option{"read_fh"})
Truth table66%2/3
A and not(B)
A= defined $option{"read_fh"}B= not _is_pipe($option{"read_fh"})
ABresult
0X0
100
111
26 croak 'new(): write_fh is not a pipe or FIFO'
27 9 ▶ if defined($option{write_fh}) && !_is_pipe($option{write_fh});
Branch: 1 branch
BranchTrueFalseTotal
if defined $option{"write_fh"} and not _is_pipe($option{"write_fh"}) 0 9 9
Condition33%1/3
defined $option{"write_fh"} and not _is_pipe($option{"write_fh"})
!ll&&!rl&&r
900
MC/DC0%0/2
defined $option{"write_fh"} and not _is_pipe($option{"write_fh"})
defined $option{"write_fh"} not _is_pipe($option{"write_fh"})
Truth table33%1/3
A and not(B)
A= defined $option{"write_fh"}B= not _is_pipe($option{"write_fh"})
ABresult
0X0
100
111
28 }
29 9 return $class->SUPER::new(%option);
30 }
31  
32 10 1;
33  
34 __END__
« bench/run-stream-transition-bench.pl ↑ Summary bench/run-performance-regression.pl »