Die/syswrite.pm

filter: Statementstmt 100% 22 / 22 Branchbran 100% 12 / 12 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 2 / 2 Podpod n/a totaltotal 100% 41 / 41 CC 8 SCAR 19.8
CC
8
Cov
100%
syswrite
8.0
BEGIN
1.0
CRAP 7.2
« Die/chown.pm ↑ Summary Die/print.pm »
1 package IO::Die;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 16 ▶sub syswrite {
Subroutine syswrite: called CC=8 SCAR=20.8
6 16 my ( $NS, $fh, @length_offset ) = ( shift, shift, @_[ 1 .. $#_ ] );
7  
8 #https://github.com/pjcj/Devel--Cover/issues/125
9 #my ( $NS, $fh, $buffer_sr, @length_offset ) = ( shift, shift, \shift, @_ );
10  
11 16 my ( $length, $offset ) = @length_offset;
12  
13 16 local ( $!, $^E );
14  
15 16 my $ret;
16 16 ▶ if ( @length_offset > 1 ) {
Branch: 2 branches
BranchTrueFalseTotal
if (@length_offset > 1) { } 5 11 16
elsif (@length_offset) { } 3 8 11
17 5 $ret = CORE::syswrite( $fh, $_[0], $length, $offset );
18 }
19 elsif (@length_offset) {
20 3 $ret = CORE::syswrite( $fh, $_[0], $length );
21 }
22 else {
23 8 $ret = CORE::syswrite( $fh, $_[0] );
24 }
25  
26 16 ▶ if ( !defined $ret ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $ret) 6 10 16
27 6 my $real_length = length $_[0];
28  
29 6 ▶ if ($offset) {
Branch: 1 branch
BranchTrueFalseTotal
if ($offset) 3 3 6
30 3 ▶ if ( $offset > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($offset > 0) { } 2 1 3
31 2 $real_length -= $offset;
32 }
33 else {
34 1 $real_length = 0 - $offset;
35 }
36 }
37  
38 6 ▶ if ( defined $length && $length < $real_length ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $length and $length < $real_length) 2 4 6
Condition100%3/3
defined $length and $length < $real_length
!ll&&!rl&&r
132
MC/DC100%2/2
defined $length and $length < $real_length
defined $length $length < $real_length
Truth table100%3/3
A and B
A= defined $lengthB= $length < $real_length
ABresult
0X0
100
111
39 2 $real_length = $length;
40 }
41  
42 6 $NS->__THROW( 'Write', length => $real_length );
43 }
44  
45 10 return $ret;
46 }
47  
48 4 1;
« Die/chown.pm ↑ Summary Die/print.pm »