line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mock::Data::Generator; |
2
|
9
|
|
|
9
|
|
66
|
use strict; |
|
9
|
|
|
|
|
24
|
|
|
9
|
|
|
|
|
278
|
|
3
|
9
|
|
|
9
|
|
48
|
use warnings; |
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
3123
|
|
4
|
|
|
|
|
|
|
require MRO::Compat if "$]" < '5.009005'; |
5
|
|
|
|
|
|
|
require mro; |
6
|
|
|
|
|
|
|
mro::set_mro(__PACKAGE__, 'c3'); |
7
|
|
|
|
|
|
|
require Scalar::Util; |
8
|
|
|
|
|
|
|
require Carp; |
9
|
|
|
|
|
|
|
our @CARP_NOT= qw( Mock::Data Mock::Data::Util ); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# ABSTRACT: Utilities and optional base class for authoring generators |
12
|
|
|
|
|
|
|
our $VERSION = '0.01'; # VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
0
|
1
|
0
|
sub generate { Carp::croak "Unimplemented" } |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub compile { |
19
|
20
|
|
|
20
|
1
|
64
|
my ($self, @default_params)= @_; |
20
|
|
|
|
|
|
|
# If no arguments, add a simple wrapper around ->generate |
21
|
20
|
50
|
|
160
|
|
200
|
return sub { $self->generate(shift) } unless @default_params > 1; |
|
160
|
|
|
|
|
59767
|
|
22
|
0
|
|
|
0
|
|
|
return sub { $self->generate(shift, @default_params) }; |
|
0
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
our $_try_reverse; |
27
|
|
|
|
|
|
|
sub combine_generator { |
28
|
|
|
|
|
|
|
# if already recursed, return the original default combination |
29
|
0
|
0
|
|
0
|
1
|
|
return Mock::Data::Set->new_uniform($_[1], $_[0]) if $_try_reverse; |
30
|
|
|
|
|
|
|
# Call the peer's combine_generator in case it is overridden |
31
|
0
|
|
|
|
|
|
local $_try_reverse= 1; |
32
|
0
|
|
|
|
|
|
return $_[1]->combine_generator($_[0]); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
require Mock::Data::Set; |
37
|
|
|
|
|
|
|
1; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
__END__ |