| 1 | package Mock::Data::Generator; | ||||||||||
| 2 | 12 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 12 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 12 | ▶ | require MRO::Compat if "$]" < '5.009005'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 5 | 12 | require mro; | |||||||||
| 6 | 12 | mro::set_mro(__PACKAGE__, 'c3'); | |||||||||
| 7 | 12 | require Scalar::Util; | |||||||||
| 8 | 12 | require Carp; | |||||||||
| 9 | 12 | our @CARP_NOT= qw( Mock::Data Mock::Data::Util ); | |||||||||
| 10 | |||||||||||
| 11 | # ABSTRACT: Utilities and optional base class for authoring generators | ||||||||||
| 12 | 12 | our $VERSION = '0.04'; # VERSION | |||||||||
| 13 | |||||||||||
| 14 | |||||||||||
| 15 | 0 | ▶ | sub generate { Carp::croak "Unimplemented" } | ||||||||
|
Subroutine
generate: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 16 | |||||||||||
| 17 | |||||||||||
| 18 | 24 | ▶ | sub compile { | ||||||||
|
Subroutine
compile: called CC=2 SCAR=8.4
Pod
documented
| |||||||||||
| 19 | 24 | my ($self, @default_params)= @_; | |||||||||
| 20 | # If no arguments, add a simple wrapper around ->generate | ||||||||||
| 21 | 24 | ▶ | return sub { $self->generate(shift) } unless @default_params > 1; | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
| |||||||||||
| 22 | 0 | ▶ | return sub { $self->generate(shift, @default_params) }; | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 23 | } | ||||||||||
| 24 | |||||||||||
| 25 | |||||||||||
| 26 | 12 | our $_try_reverse; | |||||||||
| 27 | 0 | ▶ | sub combine_generator { | ||||||||
|
Subroutine
combine_generator: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 28 | # if already recursed, return the original default combination | ||||||||||
| 29 | 0 | ▶ | return Mock::Data::Set->new_uniform($_[1], $_[0]) if $_try_reverse; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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 | 12 | require Mock::Data::Set; | |||||||||
| 37 | 12 | 1; | |||||||||
| 38 | |||||||||||
| 39 | __END__ | ||||||||||