File Coverage

blib/lib/Benchmark/Featureset/ParamCheck/Implementation/Perl.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   5852 use v5.12;
  4         12  
2 4     4   19 use strict;
  4         8  
  4         69  
3 4     4   25 use warnings;
  4         9  
  4         198  
4              
5              
6             our $AUTHORITY = 'cpan:TOBYINK';
7             our $VERSION = '0.007';
8              
9             use parent qw(Benchmark::Featureset::ParamCheck::Base);
10 4     4   19 use Scalar::Util qw(blessed);
  4         5  
  4         19  
11 4     4   212 use namespace::autoclean;
  4         8  
  4         145  
12 4     4   18  
  4         7  
  4         29  
13             use constant long_name => 'Naive Pure Perl Implementation';
14 4     4   199 use constant short_name => 'PurePerl';
  4         7  
  4         200  
15 4     4   22  
  4         6  
  4         1797  
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 1000018 100 66 1000018   2507951
  1000009         2230094  
20 1000018 100       3962208 die 'bad integer' unless
21             defined($args{integer})
22             && !ref($args{integer})
23             && $args{integer} =~ /\A-?[0-9]+\z/;
24            
25 1000016 100 66     4137566 die 'bad object' unless
      100        
26             blessed($args{object})
27             && $args{object}->can('print')
28             && $args{object}->can('close');
29            
30 1000012 100 100     4706738 die 'bad hashes' unless
      66        
31             ref($args{hashes}) eq 'ARRAY';
32             for my $arr (@{ $args{hashes} }) {
33 1000008 100       2000973 die 'bad hashes' unless ref($arr) eq 'HASH';
34 1000006         1149863 }
  1000006         1593009  
35 5000026 100       7417305
36             \%args;
37             };
38 1000004         2708798 }
39 118     118 0 622  
40             state $check = sub {
41             die 'wrong number of parameters' unless @_==3;
42            
43             die 'bad integer' unless
44 1000007 100   1000007   1443323 defined($_[0])
45             && !ref($_[0])
46 1000005 100 33     3233981 && $_[0] =~ /\A-?[0-9]+\z/;
      66        
47            
48             die 'bad object' unless
49             blessed($_[2])
50             && $_[2]->can('print')
51 1000004 100 66     4247381 && $_[2]->can('close');
      66        
52            
53             die 'bad hashes' unless
54             ref($_[1]) eq 'ARRAY';
55             for my $arr (@{ $_[1] }) {
56 1000003 50       1844090 die 'bad hashes' unless ref($arr) eq 'HASH';
57             }
58 1000003         1087321
  1000003         1454194  
59 5000013 100       7259394 @_;
60             };
61             }
62 1000002         2011412  
63 107     107 0 329 1;