TableData/Test/Source/Iterator.pm

filter: Statementstmt 100% 26 / 26 Branchbran 75.0% 3 / 4 Conditioncond 50.0% 2 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 7 / 7 Podpod 100% 1 / 1 totaltotal 88.6% 39 / 44 CC 5 SCAR 7.5
CC
5
Cov
91%
new
3.0
__ANON__
3.0
__ANON__
1.0
CRAP 2.1
« TableDataRole/Munge/Reverse.pm ↑ Summary TableDataRole/Util/CSV.pm »
1 package TableData::Test::Source::Iterator;
2  
3 2 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 ▶use Role::Tiny::With;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
10 2 our $DATE = '2024-05-14'; # DATE
11 2 our $DIST = 'TableDataRoles-Standard'; # DIST
12 2 our $VERSION = '0.025'; # VERSION
13  
14 2 with 'TableDataRole::Source::Iterator';
15  
16 1 ▶sub new {
Subroutine new: called CC=3 SCAR=11.1
Pod documented
17 1 my ($class, %args) = @_;
18 1 ▶ $args{num_rows} //= 10;
Condition50%1/2
$args{"num_rows"} //= 10
l!l
10
MC/DC0%0/1
$args{"num_rows"} //= 10
$args{"num_rows"}
Truth table50%1/2
A
A= $args{"num_rows"}
Aresult
11
00
19 1 ▶ $args{random} //= 0;
Condition50%1/2
$args{"random"} //= 0
l!l
01
MC/DC0%0/1
$args{"random"} //= 0
$args{"random"}
Truth table50%1/2
A
A= $args{"random"}
Aresult
11
00
20  
21 $class->_new(
22 4 ▶ gen_iterator => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
23 4 my $i = 0;
24 9 ▶ sub {
Subroutine __ANON__: called CC=3 SCAR=11.1
25 9 $i++;
26 9 ▶ return undef if $i > $args{num_rows}; ## no critic: Subroutines::ProhibitExplicitReturnUndef
Branch: 1 branch
BranchTrueFalseTotal
if $i > $args{"num_rows"} 1 8 9
27 8 ▶ return {i=>$args{random} ? int(rand()*$args{num_rows} + 1) : $i};
Branch: 1 branch
BranchTrueFalseTotal
$args{'random'} ? : 0 8 8
28 4 };
29 },
30 1 );
31 }
32  
33 2 1;
34 # ABSTRACT: A test table
35  
36 __END__
« TableDataRole/Munge/Reverse.pm ↑ Summary TableDataRole/Util/CSV.pm »