File Coverage

blib/lib/Benchmark/Featureset/ParamCheck/Implementation/RefUtilXS.pm
Criterion Covered Total %
statement 43 43 100.0
branch 21 22 95.4
condition 19 27 70.3
subroutine 12 12 100.0
pod 0 2 0.0
total 95 106 89.6


line stmt bran cond sub pod time code
1 4     4   14289 use v5.12;
  4         17  
2 4     4   31 use strict;
  4         9  
  4         78  
3 4     4   18 use warnings;
  4         11  
  4         255  
4              
5              
6             our $AUTHORITY = 'cpan:TOBYINK';
7             our $VERSION = '0.006';
8              
9             use parent qw(Benchmark::Featureset::ParamCheck::Base);
10 4     4   20 use Ref::Util::XS 0.116 qw(is_blessed_ref is_plain_hashref is_plain_arrayref is_ref);
  4         10  
  4         25  
11 4     4   270 use namespace::autoclean;
  4         84  
  4         344  
12 4     4   25  
  4         10  
  4         40  
13             use constant long_name => 'Pure Perl Implementation with Ref::Util::XS';
14 4     4   258 use constant short_name => 'RefUtilXS';
  4         12  
  4         225  
15 4     4   21  
  4         10  
  4         2176  
16             state $check = sub {
17             my %args = (@_==1 && ref($_[0]) eq 'HASH') ? %{$_[0]} : @_;
18             die 'invalid key' if grep !/\A(integer|object|hashes)\z/, keys %args;
19 400018 100 66 400018   1164528
  400009         1125838  
20 400018 100       1815021 die 'bad integer' unless
21             defined($args{integer})
22             && !is_ref($args{integer})
23             && $args{integer} =~ /\A-?[0-9]+\z/;
24            
25 400016 100 66     1762212 die 'bad object' unless
      100        
26             is_blessed_ref($args{object})
27             && $args{object}->can('print')
28             && $args{object}->can('close');
29            
30 400012 100 100     1844582 die 'bad hashes' unless
      66        
31             is_plain_arrayref($args{hashes});
32             for my $arr (@{ $args{hashes} }) {
33 400008 100       790601 die 'bad hashes' unless is_plain_hashref($arr);
34 400006         557071 }
  400006         709864  
35 2000026 100       3354518
36             \%args;
37             };
38 400004         1265965 }
39 58     58 0 171  
40             state $check = sub {
41             die 'wrong number of parameters' unless @_==3;
42            
43             die 'bad integer' unless
44 400007 100   400007   674997 defined($_[0])
45             && !is_ref($_[0])
46 400005 100 33     1539934 && $_[0] =~ /\A-?[0-9]+\z/;
      66        
47            
48             die 'bad object' unless
49             is_blessed_ref($_[2])
50             && $_[2]->can('print')
51 400004 100 66     1758748 && $_[2]->can('close');
      66        
52            
53             die 'bad hashes' unless
54             is_plain_arrayref($_[1]);
55             for my $arr (@{ $_[1] }) {
56 400003 50       713918 die 'bad hashes' unless is_plain_hashref($arr);
57             }
58 400003         503551
  400003         639519  
59 2000013 100       3192430 @_;
60             };
61             }
62 400002         918715  
63 47     47 0 148 1;