line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::RandomCheck; |
2
|
4
|
|
|
4
|
|
17138
|
use strict; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
87
|
|
3
|
4
|
|
|
4
|
|
9
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
80
|
|
4
|
4
|
|
|
4
|
|
69
|
use 5.010000; |
|
4
|
|
|
|
|
9
|
|
5
|
4
|
|
|
4
|
|
1980
|
use Data::Dumper; |
|
4
|
|
|
|
|
25445
|
|
|
4
|
|
|
|
|
196
|
|
6
|
4
|
|
|
4
|
|
19
|
use Exporter qw(import); |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
88
|
|
7
|
4
|
|
|
4
|
|
1320
|
use Test::RandomCheck::Generator; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
258
|
|
8
|
4
|
|
|
4
|
|
16
|
use Test::RandomCheck::PRNG; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
20
|
|
9
|
4
|
|
|
4
|
|
1637
|
use Test::More (); |
|
4
|
|
|
|
|
35229
|
|
|
4
|
|
|
|
|
99
|
|
10
|
4
|
|
|
4
|
|
16
|
use constant DEBUG => $ENV{RANDOMCHECK_DEBUG}; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
1259
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @EXPORT = qw(random_ok); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub _dump_args ($) { |
16
|
1
|
|
|
1
|
|
2
|
my $args = shift; |
17
|
1
|
|
|
|
|
9
|
my $str = Data::Dumper->new([$args])->Indent(0)->Terse(1)->Dump; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# Use the list style instead of the array-ref style |
20
|
1
|
|
|
|
|
111
|
$str =~ s/^\[/(/; |
21
|
1
|
|
|
|
|
3
|
$str =~ s/\]$/)/; |
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
|
|
7
|
"\@_ = $str"; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub random_ok (&$;@) { |
27
|
26
|
|
|
26
|
0
|
106
|
my $code = shift; |
28
|
26
|
|
|
|
|
28
|
my $type = shift; |
29
|
|
|
|
|
|
|
|
30
|
26
|
|
|
|
|
24
|
my @types; |
31
|
|
|
|
|
|
|
push @types, shift |
32
|
26
|
|
|
|
|
38
|
while eval { $_[0]->isa("Test::RandomCheck::Types") }; |
|
40
|
|
|
|
|
444
|
|
33
|
26
|
100
|
|
|
|
105
|
$type = concat ($type, @types) if @types; |
34
|
|
|
|
|
|
|
|
35
|
26
|
|
|
|
|
94
|
my %params = @_; |
36
|
26
|
|
100
|
|
|
113
|
my $shots = delete $params{shots} // 202; |
37
|
|
|
|
|
|
|
|
38
|
26
|
|
|
|
|
40
|
local $Test::Builder::Level = $Test::Builder::Level + 1; |
39
|
26
|
|
|
4856
|
|
69
|
my $generator = $type->arbitrary->map(sub { scalar $code->(@_), [@_] }); |
|
4856
|
|
|
|
|
6086
|
|
40
|
26
|
|
|
|
|
84
|
my $rand = Test::RandomCheck::PRNG->new; |
41
|
26
|
|
|
|
|
61
|
for (1 .. $shots) { |
42
|
4856
|
|
|
|
|
4400
|
my $size = ($_ - 1) % 101; |
43
|
4856
|
|
|
|
|
7173
|
my ($is_success, $args) = $generator->pick($rand, $size); |
44
|
4856
|
100
|
|
|
|
59096
|
unless ($is_success) { |
45
|
1
|
|
|
|
|
2
|
Test::More::diag("Faild by following args: " . _dump_args($args)); |
46
|
1
|
|
|
|
|
66
|
Test::More::diag( |
47
|
|
|
|
|
|
|
sprintf "Generated by size=%d", $size |
48
|
|
|
|
|
|
|
) if DEBUG; |
49
|
1
|
|
|
|
|
2
|
return Test::More::ok 0 ; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
25
|
|
|
|
|
93
|
Test::More::ok 1; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
56
|
|
|
|
|
|
|
__END__ |