line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::RandomCheck::ProbMonad; |
2
|
4
|
|
|
4
|
|
13
|
use strict; |
|
4
|
|
|
|
|
16
|
|
|
4
|
|
|
|
|
84
|
|
3
|
4
|
|
|
4
|
|
10
|
use warnings; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
74
|
|
4
|
4
|
|
|
4
|
|
11
|
use Exporter qw(import); |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
1125
|
|
5
|
|
|
|
|
|
|
our @EXPORT = qw( |
6
|
|
|
|
|
|
|
gen const range elements variant |
7
|
|
|
|
|
|
|
); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub gen (&) { |
10
|
62417
|
|
|
62417
|
0
|
41175
|
my $code = shift; |
11
|
62417
|
|
|
|
|
111079
|
bless $code => __PACKAGE__; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
202
|
|
|
202
|
0
|
321
|
sub const (@) { my @args = @_; gen { @args } } |
|
1
|
|
|
1
|
|
9
|
|
|
1
|
|
|
|
|
4
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub range ($$) { |
17
|
11656
|
|
|
11656
|
0
|
17720
|
my ($min, $max) = @_; |
18
|
11656
|
|
|
42893
|
|
24420
|
gen { $_[0]->next_int($min, $max) }; |
|
42893
|
|
|
|
|
56938
|
|
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub elements (@) { |
22
|
10038
|
|
|
10038
|
0
|
15695
|
my $ref_elems = \@_; |
23
|
10038
|
|
|
40411
|
|
13792
|
(range 0, $#$ref_elems)->map(sub { $ref_elems->[shift] }); |
|
40411
|
|
|
|
|
87753
|
|
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub pick { |
27
|
146968
|
|
|
146968
|
1
|
99587
|
my ($self, $rand, $size) = @_; |
28
|
146968
|
|
|
|
|
134237
|
$self->($rand, $size); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub map { |
32
|
17907
|
|
|
17907
|
1
|
12512
|
my ($self, $f) = @_; |
33
|
17907
|
|
|
59233
|
|
28696
|
gen { $f->($self->pick(@_)) }; |
|
59233
|
|
|
|
|
56309
|
|
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub flat_map { |
37
|
7842
|
|
|
7842
|
1
|
5676
|
my ($self, $f) = @_; |
38
|
|
|
|
|
|
|
gen { |
39
|
10060
|
|
|
10060
|
|
7468
|
my ($rand, $size) = @_; |
40
|
10060
|
|
|
|
|
10673
|
$f->($self->pick($rand, $size))->pick($rand, $size); |
41
|
7842
|
|
|
|
|
13677
|
}; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
__END__ |