line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::RandomCheck::Types::List; |
2
|
4
|
|
|
4
|
|
11
|
use strict; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
84
|
|
3
|
4
|
|
|
4
|
|
11
|
use warnings; |
|
4
|
|
|
|
|
38
|
|
|
4
|
|
|
|
|
77
|
|
4
|
4
|
|
|
4
|
|
13
|
use parent "Test::RandomCheck::Types"; |
|
4
|
|
|
|
|
2
|
|
|
4
|
|
|
|
|
13
|
|
5
|
4
|
|
|
4
|
|
187
|
use Class::Accessor::Lite (ro => [qw(min max type)]); |
|
4
|
|
|
|
|
3
|
|
|
4
|
|
|
|
|
25
|
|
6
|
4
|
|
|
4
|
|
228
|
use Exporter qw(import); |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
81
|
|
7
|
4
|
|
|
4
|
|
11
|
use Test::RandomCheck::ProbMonad; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
1022
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @EXPORT = qw(list); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub list ($;$$) { |
12
|
21
|
|
|
21
|
0
|
146
|
my $type = shift; |
13
|
21
|
|
|
|
|
21
|
my ($min, $max) = @_; |
14
|
21
|
|
100
|
|
|
60
|
$min //= 0; |
15
|
21
|
|
100
|
|
|
48
|
$max //= 9; |
16
|
21
|
|
|
|
|
52
|
Test::RandomCheck::Types::List->new( |
17
|
|
|
|
|
|
|
type => $type, min => $min, max => $max |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub arbitrary { |
22
|
7842
|
|
|
7842
|
0
|
18196
|
my $self = shift; |
23
|
7842
|
|
|
|
|
10045
|
my ($min, $max) = ($self->min, $self->max); |
24
|
7842
|
|
|
|
|
35970
|
my $generator = $self->type->arbitrary; |
25
|
|
|
|
|
|
|
gen { |
26
|
10060
|
|
|
10060
|
|
7483
|
my ($rand, $size) = @_; |
27
|
10060
|
|
|
|
|
13898
|
my $width = int (($max - $min) * $size / 100); |
28
|
10060
|
|
|
|
|
17122
|
$rand->next_int($min, $min + $width); |
29
|
|
|
|
|
|
|
}->flat_map(sub { |
30
|
10060
|
|
|
10060
|
|
6882
|
my $n = shift; |
31
|
|
|
|
|
|
|
gen { |
32
|
10060
|
|
|
|
|
7674
|
my ($rand, $size) = @_; |
33
|
10060
|
|
|
|
|
12448
|
map { $generator->pick($rand, $size) } 1 .. $n; |
|
44221
|
|
|
|
|
58980
|
|
34
|
10060
|
|
|
|
|
25688
|
}; |
35
|
7842
|
|
|
|
|
19881
|
}); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub memoize_key { |
39
|
2424
|
|
|
2424
|
0
|
6307
|
my ($self, @xs) = @_; |
40
|
2424
|
|
|
|
|
2680
|
join '\0', map { $self->type->memoize_key($_) } @xs; |
|
4911
|
|
|
|
|
5550
|
|
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |