line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package ArrayData::Test::Source::Iterator; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
4
|
|
|
|
|
|
|
our $DATE = '2021-05-10'; # DATE |
5
|
|
|
|
|
|
|
our $DIST = 'ArrayDataRoles-Standard'; # DIST |
6
|
|
|
|
|
|
|
our $VERSION = '0.006'; # VERSION |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
73864
|
use 5.010001; |
|
1
|
|
|
|
|
13
|
|
9
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
10
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
11
|
1
|
|
|
1
|
|
506
|
use Role::Tiny::With; |
|
1
|
|
|
|
|
5255
|
|
|
1
|
|
|
|
|
161
|
|
12
|
|
|
|
|
|
|
with 'ArrayDataRole::Source::Iterator'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
15
|
1
|
|
|
1
|
1
|
106
|
my ($class, %args) = @_; |
16
|
1
|
|
50
|
|
|
5
|
$args{num_elems} //= 10; |
17
|
1
|
|
50
|
|
|
9
|
$args{random} //= 0; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
$class->_new( |
20
|
|
|
|
|
|
|
gen_iterator => sub { |
21
|
5
|
|
|
5
|
|
10
|
my $i = 0; |
22
|
|
|
|
|
|
|
sub { |
23
|
17
|
|
|
|
|
27
|
$i++; |
24
|
17
|
100
|
|
|
|
43
|
return undef if $i > $args{num_elems}; |
25
|
13
|
50
|
|
|
|
34
|
return $args{random} ? int(rand()*$args{num_elems} + 1) : $i; |
26
|
5
|
|
|
|
|
35
|
}; |
27
|
|
|
|
|
|
|
}, |
28
|
1
|
|
|
|
|
13
|
); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
1; |
32
|
|
|
|
|
|
|
# ABSTRACT: A test ArrayData module |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
__END__ |