ParamCheck/Implementation/RefUtilXS.pm

filter: Statementstmt 100% 46 / 46 Branchbran 95.4% 21 / 22 Conditioncond 70.3% 19 / 27 MC/DCmcdc 50.0% 7 / 14 Subroutinesub 100% 12 / 12 Podpod 0.0% 0 / 2 totaltotal 85.3% 105 / 123 CC 23 SCAR 22.2
CC
23
Cov
91%
__ANON__
13.1
__ANON__
12.0
BEGIN
1.0
CRAP 9.2
« ParamCheck/Implementation/Perl.pm ↑ Summary ParamCheck/Implementation/ParamsCheck/Perl.pm »
1 4 ▶use v5.12;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Benchmark::Featureset::ParamCheck::Implementation::RefUtilXS;
6  
7 4 our $AUTHORITY = 'cpan:TOBYINK';
8 4 our $VERSION = '0.006';
9  
10 4 ▶use parent qw(Benchmark::Featureset::ParamCheck::Base);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 4 ▶use Ref::Util::XS 0.116 qw(is_blessed_ref is_plain_hashref is_plain_arrayref is_ref);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 4 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 4 ▶use constant long_name => 'Pure Perl Implementation with Ref::Util::XS';
Subroutine BEGIN: called CC=1 SCAR=0.0
15 4 ▶use constant short_name => 'RefUtilXS';
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 sub get_named_check {
18 state $check = sub {
19 600018 ▶ my %args = (@_==1 && ref($_[0]) eq 'HASH') ? %{$_[0]} : @_;
Subroutine __ANON__: called CC=13 SCAR=25.7
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 && ref $_[0] eq 'HASH' ? : 600009 9 600018
Condition66%2/3
@_ == 1 and ref $_[0] eq "HASH"
!ll&&!rl&&r
90600009
MC/DC50%1/2
@_ == 1 and ref $_[0] eq "HASH"
@_ == 1 ref $_[0] eq "HASH"
Truth table66%2/3
A and B
A= @_ == 1B= ref $_[0] eq "HASH"
ABresult
0X0
100
111
20 600018 ▶ die 'invalid key' if grep !/\A(integer|object|hashes)\z/, keys %args;
Branch: 1 branch
BranchTrueFalseTotal
if grep((!/\A(integer|object|hashes)\z/u), keys %args) 2 600016 600018
21
22 die 'bad integer' unless
23 defined($args{integer})
24 && !is_ref($args{integer})
25 600016 ▶ && $args{integer} =~ /\A-?[0-9]+\z/;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"integer"} and not Ref::Util::XS::is_ref($args{"integer"}) and $args{"integer"} =~ /\A-?[0-9]+\z/u 2 600012 600014
Condition83%5/6
defined $args{"integer"} and not Ref::Util::XS::is_ref($args{"integer"}) and $args{"integer"} =~ /\A-?[0-9]+\z/u
!ll&&!rl&&r
22600012
defined $args{"integer"} and not Ref::Util::XS::is_ref($args{"integer"})
!ll&&!rl&&r
20600014
MC/DC66%2/3
defined $args{"integer"} and not Ref::Util::XS::is_ref($args{"integer"}) and $args{"integer"} =~ /\A-?[0-9]+\z/u
defined $args{"integer"} not Ref::Util::XS::is_ref($args{"integer"}) $args{"integer"} =~ /\A-?[0-9]+\z/u
Truth table75%3/4
A and not(B) and C
A= defined $args{"integer"}B= not Ref::Util::XS::is_ref($args{"integer"})C= $args{"integer"} =~ /\A-?[0-9]+\z/u
ABCresult
0XX0
10X0
1100
1111
26
27 die 'bad object' unless
28 is_blessed_ref($args{object})
29 && $args{object}->can('print')
30 600012 ▶ && $args{object}->can('close');
Branch: 1 branch
BranchTrueFalseTotal
unless Ref::Util::XS::is_blessed_ref($args{"object"}) and $args{"object"}->can("print") and $args{"object"}->can("close") 2 600008 600010
Condition83%5/6
Ref::Util::XS::is_blessed_ref($args{"object"}) and $args{"object"}->can("print") and $args{"object"}->can("close")
!ll&&!rl&&r
40600008
Ref::Util::XS::is_blessed_ref($args{"object"}) and $args{"object"}->can("print")
!ll&&!rl&&r
22600008
MC/DC66%2/3
Ref::Util::XS::is_blessed_ref($args{"object"}) and $args{"object"}->can("print") and $args{"object"}->can("close")
Ref::Util::XS::is_blessed_ref($args{"object"}) $args{"object"}->can("print") $args{"object"}->can("close")
Truth table75%3/4
A and B and C
A= Ref::Util::XS::is_blessed_ref($args{"object"})B= $args{"object"}->can("print")C= $args{"object"}->can("close")
ABCresult
0XX0
10X0
1100
1111
31
32 die 'bad hashes' unless
33 600008 ▶ is_plain_arrayref($args{hashes});
Branch: 1 branch
BranchTrueFalseTotal
unless Ref::Util::XS::is_plain_arrayref($args{"hashes"}) 2 600006 600008
34 600006 for my $arr (@{ $args{hashes} }) {
35 2000026 ▶ die 'bad hashes' unless is_plain_hashref($arr);
Branch: 1 branch
BranchTrueFalseTotal
unless Ref::Util::XS::is_plain_hashref($arr) 2 2000024 2000026
36 }
37
38 600004 \%args;
39 78 ▶ };
Subroutine get_named_check: called CC=1 SCAR=0.0
Pod undocumented
40 }
41  
42 sub get_positional_check {
43 state $check = sub {
44 800007 ▶ die 'wrong number of parameters' unless @_==3;
Subroutine __ANON__: called CC=11 SCAR=24.8
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 3 2 800005 800007
45
46 800005 ▶ die 'bad integer' unless
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_[0] and not Ref::Util::XS::is_ref($_[0]) and $_[0] =~ /\A-?[0-9]+\z/u 1 800004 800005
Condition50%3/6
defined $_[0] and not Ref::Util::XS::is_ref($_[0]) and $_[0] =~ /\A-?[0-9]+\z/u
!ll&&!rl&&r
01800004
defined $_[0] and not Ref::Util::XS::is_ref($_[0])
!ll&&!rl&&r
00800005
MC/DC33%1/3
defined $_[0] and not Ref::Util::XS::is_ref($_[0]) and $_[0] =~ /\A-?[0-9]+\z/u
defined $_[0] not Ref::Util::XS::is_ref($_[0]) $_[0] =~ /\A-?[0-9]+\z/u
Truth table50%2/4
A and not(B) and C
A= defined $_[0]B= not Ref::Util::XS::is_ref($_[0])C= $_[0] =~ /\A-?[0-9]+\z/u
ABCresult
0XX0
10X0
1100
1111
47 defined($_[0])
48 && !is_ref($_[0])
49 && $_[0] =~ /\A-?[0-9]+\z/;
50
51 800004 ▶ die 'bad object' unless
Branch: 1 branch
BranchTrueFalseTotal
unless Ref::Util::XS::is_blessed_ref($_[2]) and $_[2]->can("print") and $_[2]->can("close") 1 800003 800004
Condition66%4/6
Ref::Util::XS::is_blessed_ref($_[2]) and $_[2]->can("print") and $_[2]->can("close")
!ll&&!rl&&r
10800003
Ref::Util::XS::is_blessed_ref($_[2]) and $_[2]->can("print")
!ll&&!rl&&r
01800003
MC/DC33%1/3
Ref::Util::XS::is_blessed_ref($_[2]) and $_[2]->can("print") and $_[2]->can("close")
Ref::Util::XS::is_blessed_ref($_[2]) $_[2]->can("print") $_[2]->can("close")
Truth table50%2/4
A and B and C
A= Ref::Util::XS::is_blessed_ref($_[2])B= $_[2]->can("print")C= $_[2]->can("close")
ABCresult
0XX0
10X0
1100
1111
52 is_blessed_ref($_[2])
53 && $_[2]->can('print')
54 && $_[2]->can('close');
55
56 800003 ▶ die 'bad hashes' unless
Branch: 1 branch
BranchTrueFalseTotal
unless Ref::Util::XS::is_plain_arrayref($_[1]) 0 800003 800003
57 is_plain_arrayref($_[1]);
58 800003 for my $arr (@{ $_[1] }) {
59 2000013 ▶ die 'bad hashes' unless is_plain_hashref($arr);
Branch: 1 branch
BranchTrueFalseTotal
unless Ref::Util::XS::is_plain_hashref($arr) 1 2000012 2000013
60 }
61
62 800002 @_;
63 87 ▶ };
Subroutine get_positional_check: called CC=1 SCAR=0.0
Pod undocumented
64 }
65  
66 4 1;
« ParamCheck/Implementation/Perl.pm ↑ Summary ParamCheck/Implementation/ParamsCheck/Perl.pm »