blib/lib/Linux/Event/Framer.pm

filter: Statementstmt 100% 32 / 32 Branchbran 75.0% 9 / 12 Conditioncond 36.3% 4 / 11 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 75.7% 50 / 66 CC 12 SCAR 23.7
CC
12
Cov
82%
import
13.9
BEGIN
1.0
BEGIN
1.0
CRAP 10.7
« blib/lib/Linux/Event/Loop/Introspection.pm ↑ Summary bench/run-stream-microbench.pl »
1 package Linux::Event::Framer;
2 39 ▶use v5.36;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 39 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 39 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 39 our $VERSION = '0.105';
7  
8 39 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 96 ▶sub import ($class, $keyword = undef, @args) {
Subroutine import: called CC=12 SCAR=26.4
11 96 my $target = caller;
12 96 ▶ croak "use $class requires a built-in framer name"
Branch: 1 branch
BranchTrueFalseTotal
if not defined $keyword or $keyword eq "" 0 96 96
Condition33%1/3
not defined $keyword or $keyword eq ""
l!l&&r!l&&!r
0096
MC/DC0%0/2
not defined $keyword or $keyword eq ""
not defined $keyword $keyword eq ""
Truth table33%1/3
not(A) or B
A= not defined $keywordB= $keyword eq ""
ABresult
1X1
011
000
13 if !defined($keyword) || $keyword eq '';
14 96 ▶ croak "invalid framer name '$keyword'"
Branch: 1 branch
BranchTrueFalseTotal
unless $keyword =~ /\A[A-Za-z_][A-Za-z0-9_]*\z/u 1 95 96
15 if $keyword !~ /\A[A-Za-z_][A-Za-z0-9_]*\z/;
16 95 ▶ croak "$target must inherit from Linux::Event::Stream before declaring a framer"
Branch: 1 branch
BranchTrueFalseTotal
unless $target->isa("Linux::Event::Stream") 1 94 95
17 if !$target->isa('Linux::Event::Stream');
18  
19 94 my $package = "${class}::${keyword}";
20 94 (my $file = "$package.pm") =~ s{::}{/}g;
21 94 ▶ eval { require $file; 1 } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { require $file; 1 } } or do { my $error = $@ || "unable to load $package"; $error =~ s/\s+\z//u; croak("cannot declare framer '${keyword}': $error") } 93 1 94
22 1 ▶ my $error = $@ || "unable to load $package";
Condition50%1/2
$@ || "unable to load $package"
l!l
10
MC/DC0%0/1
$@ || "unable to load $package"
$@
Truth table50%1/2
A
A= $@
Aresult
11
00
23 1 $error =~ s/\s+\z//;
24 1 croak "cannot declare framer '$keyword': $error";
25 };
26  
27 93 ▶ my $builder = $package->can('_build_definition')
Branch: 1 branch
BranchTrueFalseTotal
my $builder = $package->can("_build_definition") or croak("$package is not a Linux::Event built-in framer") 93 0 93
28 or croak "$package is not a Linux::Event built-in framer";
29 93 my $definition = $builder->($package, @args);
30 croak "$package returned an invalid framer definition"
31 if ref($definition) ne 'HASH'
32 || ref($definition->{native}) ne 'HASH'
33 90 ▶ || ref($definition->{frame}) ne 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
if ref $definition ne "HASH" or ref $definition->{"native"} ne "HASH" or ref $definition->{"frame"} ne "CODE" 0 90 90
Condition33%2/6
ref $definition ne "HASH" or ref $definition->{"native"} ne "HASH" or ref $definition->{"frame"} ne "CODE"
l!l&&r!l&&!r
0090
ref $definition ne "HASH" or ref $definition->{"native"} ne "HASH"
l!l&&r!l&&!r
0090
MC/DC0%0/3
ref $definition ne "HASH" or ref $definition->{"native"} ne "HASH" or ref $definition->{"frame"} ne "CODE"
ref $definition ne "HASH" ref $definition->{"native"} ne "HASH" ref $definition->{"frame"} ne "CODE"
Truth table25%1/4
A or B or C
A= ref $definition ne "HASH"B= ref $definition->{"native"} ne "HASH"C= ref $definition->{"frame"} ne "CODE"
ABCresult
1XX1
01X1
0011
0000
34  
35 90 $definition->{package} = $package;
36 90 Linux::Event::Stream->_declare_framer($target, $definition);
37 89 return;
38 }
39  
40 39 1;
41  
42 __END__
« blib/lib/Linux/Event/Loop/Introspection.pm ↑ Summary bench/run-stream-microbench.pl »