File Coverage

blib/lib/HashData/Test/Source/Iterator.pm
Criterion Covered Total %
statement 23 23 100.0
branch 3 4 75.0
condition 2 4 50.0
subroutine 7 7 100.0
pod 1 1 100.0
total 36 39 92.3


line stmt bran cond sub pod time code
1             package HashData::Test::Source::Iterator;
2              
3 2     2   564563 use strict;
  2         6  
  2         81  
4 2     2   41 use 5.010001;
  2         10  
5 2     2   12 use strict;
  2         4  
  2         62  
6 2     2   12 use warnings;
  2         6  
  2         135  
7 2     2   1004 use Role::Tiny::With;
  2         13868  
  2         511  
8             with 'HashDataRole::Source::Iterator';
9              
10             our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
11             our $DATE = '2024-11-04'; # DATE
12             our $DIST = 'HashDataRoles-Standard'; # DIST
13             our $VERSION = '0.005'; # VERSION
14              
15             sub new {
16 1     1 1 583110 my ($class, %args) = @_;
17 1   50     8 $args{num_pairs} //= 10;
18 1   50     8 $args{random} //= 0;
19              
20             $class->_new(
21             gen_iterator => sub {
22 10     10   18 my $i = 0;
23             sub {
24 27         42 $i++;
25 27 100       79 return () if $i > $args{num_pairs}; ## no critic: Subroutines::ProhibitExplicitReturnUndef
26 22 50       85 return $args{random} ? ($i, int(rand()*$args{num_pairs} + 1)) : ($i, $i);
27 10         102 };
28             },
29 1         20 );
30             }
31              
32             1;
33             # ABSTRACT: A test HashData module
34              
35             __END__