line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::RandomCheck::Types::List; |
2
|
4
|
|
|
4
|
|
14
|
use strict; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
89
|
|
3
|
4
|
|
|
4
|
|
13
|
use warnings; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
78
|
|
4
|
4
|
|
|
4
|
|
10
|
use parent "Test::RandomCheck::Types"; |
|
4
|
|
|
|
|
54
|
|
|
4
|
|
|
|
|
23
|
|
5
|
4
|
|
|
4
|
|
191
|
use Class::Accessor::Lite (ro => [qw(min max type)]); |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
19
|
|
6
|
4
|
|
|
4
|
|
249
|
use Exporter qw(import); |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
86
|
|
7
|
4
|
|
|
4
|
|
12
|
use Test::RandomCheck::ProbMonad; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
1172
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @EXPORT = qw(list); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub list ($;$$) { |
12
|
0
|
|
|
0
|
0
|
|
my $type = shift; |
13
|
0
|
|
|
|
|
|
my ($min, $max) = @_; |
14
|
0
|
|
0
|
|
|
|
$min //= 0; |
15
|
0
|
|
0
|
|
|
|
$max //= 9; |
16
|
0
|
|
|
|
|
|
Test::RandomCheck::Types::List->new( |
17
|
|
|
|
|
|
|
type => $type, min => $min, max => $max |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub arbitrary { |
22
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
23
|
0
|
|
|
|
|
|
my ($min, $max) = ($self->min, $self->max); |
24
|
0
|
|
|
|
|
|
my $generator = $self->type->arbitrary; |
25
|
|
|
|
|
|
|
gen { |
26
|
0
|
|
|
0
|
|
|
my ($rand, $size) = @_; |
27
|
0
|
|
|
|
|
|
my $width = int (($max - $min) * $size / 100); |
28
|
0
|
|
|
|
|
|
$rand->next_int($min, $min + $width); |
29
|
|
|
|
|
|
|
}->flat_map(sub { |
30
|
0
|
|
|
0
|
|
|
my $n = shift; |
31
|
|
|
|
|
|
|
gen { |
32
|
0
|
|
|
|
|
|
my ($rand, $size) = @_; |
33
|
0
|
|
|
|
|
|
map { $generator->pick($rand, $size) } 1 .. $n; |
|
0
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
}; |
35
|
0
|
|
|
|
|
|
}); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub memoize_key { |
39
|
0
|
|
|
0
|
0
|
|
my ($self, @xs) = @_; |
40
|
0
|
|
|
|
|
|
join '\0', map { $self->type->memoize_key($_) } @xs; |
|
0
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |