blib/lib/Linux/Event/Framer/Fixed.pm

filter: Statementstmt 100% 28 / 28 Branchbran 64.2% 9 / 14 Conditioncond 50.0% 3 / 6 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 100% 7 / 7 Podpod n/a totaltotal 81.3% 48 / 59 CC 10 SCAR 17.4
CC
10
Cov
83%
_build_definition
9.6
_frame
3.0
BEGIN
1.0
CRAP 5.7
« bench/run-listen-microbench.pl ↑ Summary bench/run-process-pipe-drain-bench.pl »
1 package Linux::Event::Framer::Fixed;
2 19 ▶use v5.36;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 19 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 19 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 19 our $VERSION = '0.119';
7  
8 19 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 19 ▶use bytes ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 20 ▶sub _build_definition ($class, @args) {
Subroutine _build_definition: called CC=8 SCAR=22.6
12 20 ▶ croak 'Fixed options must be key/value pairs' if @args != 1 && @args % 2;
Branch: 1 branch
BranchTrueFalseTotal
if @args != 1 and @args % 2 0 20 20
Condition33%1/3
@args != 1 and @args % 2
!ll&&!rl&&r
0200
MC/DC0%0/2
@args != 1 and @args % 2
@args != 1 @args % 2
Truth table33%1/3
A and B
A= @args != 1B= @args % 2
ABresult
0X0
100
111
13 20 ▶ my %opt = @args == 1 ? (size => $args[0]) : @args;
Branch: 1 branch
BranchTrueFalseTotal
@args == 1 ? : 0 20 20
14 20 my $size = delete $opt{size};
15 20 ▶ croak 'Fixed requires size' if !defined $size;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $size 0 20 20
16 20 ▶ croak 'size must be a positive integer'
Branch: 1 branch
BranchTrueFalseTotal
if not $size =~ /\A\d+\z/u or $size <= 0 1 19 20
Condition66%2/3
not $size =~ /\A\d+\z/u or $size <= 0
l!l&&r!l&&!r
0119
MC/DC50%1/2
not $size =~ /\A\d+\z/u or $size <= 0
not $size =~ /\A\d+\z/u $size <= 0
Truth table66%2/3
not(A) or B
A= not $size =~ /\A\d+\z/uB= $size <= 0
ABresult
1X1
011
000
17 if $size !~ /\A\d+\z/ || $size <= 0;
18 19 ▶ croak 'unknown Fixed options: ' . join(', ', sort keys %opt) if %opt;
Branch: 1 branch
BranchTrueFalseTotal
if %opt 0 19 19
19  
20 19 my $native = { read_mode => 3, fixed_size => 0 + $size };
21 19 return { native => $native, frame => \&_frame };
22 }
23  
24 2 ▶sub _frame ($config, $payload) {
Subroutine _frame: called CC=3 SCAR=11.0
25 2 ▶ $payload = '' if !defined $payload;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $payload 0 2 2
26 2 my $length = bytes::length($payload);
27 croak "send(): payload length $length does not equal fixed size $config->{fixed_size}"
28 2 ▶ if $length != $config->{fixed_size};
Branch: 1 branch
BranchTrueFalseTotal
if $length != $config->{"fixed_size"} 1 1 2
29 1 return $payload;
30 }
31  
32 19 1;
33  
34 __END__
« bench/run-listen-microbench.pl ↑ Summary bench/run-process-pipe-drain-bench.pl »