blib/lib/Hades/Realm/Exporter.pm

filter: Statementstmt 96.6% 289 / 299 Branchbran 73.5% 181 / 246 Conditioncond 78.1% 93 / 119 MC/DCmcdc 60.5% 43 / 71 Subroutinesub 92.3% 24 / 26 Podpod 100% 21 / 21 totaltotal 83.2% 651 / 782 SCAR 56.8
CC
180
Cov
85%
build_tests
32.6
default_export_hash
19.6
build_export_tags
19.4
CRAP 294.0
↑ Summary
1 package Hades::Realm::Exporter;
2 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use base qw/Hades/;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 our $VERSION = 0.04;
6  
7 sub new {
8 31 ▶ my ( $cls, %args ) = ( shift(), scalar @_ == 1 ? %{ $_[0] } : @_ );
Subroutine new: called CC=7 SCAR=20.4
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
scalar @_ == 1 ? : 29 2 31
9 31 my $self = $cls->SUPER::new(%args);
10 31 my %accessors = ( export => { default => {}, }, );
11 31 for my $accessor ( keys %accessors ) {
12 my $param
13 = defined $args{$accessor}
14 ? $args{$accessor}
15 31 ▶ : $accessors{$accessor}->{default};
Branch: 1 branch
BranchTrueFalseTotal
defined $args{$accessor} ? : 3 28 31
16 my $value
17 = $self->$accessor( $accessors{$accessor}->{builder}
18 31 ▶ ? $accessors{$accessor}->{builder}->( $self, $param )
Branch: 1 branch
BranchTrueFalseTotal
$accessors{$accessor}{'builder'} ? : 0 31 31
19 : $param );
20 29 ▶ unless ( !$accessors{$accessor}->{required} || defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (not $accessors{$accessor}{"required"} or defined $value) 0 29 29
Condition33%1/3
not $accessors{$accessor}{"required"} or defined $value
l!l&&r!l&&!r
2900
MC/DC0%0/2
not $accessors{$accessor}{"required"} or defined $value
not $accessors{$accessor}{"required"} defined $value
Truth table33%1/3
not(A) or B
A= not $accessors{$accessor}{"required"}B= defined $value
ABresult
1X1
011
000
21 0 die "$accessor accessor is required";
22 }
23 }
24 29 return $self;
25 }
26  
27 sub export {
28 48 ▶ my ( $self, $value ) = @_;
Subroutine export: called CC=4 SCAR=13.9
Pod documented
29 48 ▶ if ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 34 14 48
30 34 ▶ if ( ( ref($value) || "" ) ne "HASH" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $value || "") ne "HASH") 4 30 34
Condition100%2/2
ref $value || ''
l!l
322
MC/DC100%1/1
ref $value || ''
ref $value
Truth table100%2/2
A
A= ref $value
Aresult
11
00
31 4 die qq{HashRef: invalid value $value for accessor export};
32 }
33 30 $self->{export} = $value;
34 }
35 44 return $self->{export};
36 }
37  
38 sub build_self {
39 12 ▶ my ( $self, $name ) = @_;
Subroutine build_self: called CC=3 SCAR=11.0
Pod documented
40 12 ▶ if ( defined $name ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $name) 12 0 12
41 12 ▶ if ( ref $name ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $name) 2 10 12
42 2 die
43 qq{Optional[Str]: invalid value $name for variable \$name in method build_self};
44 }
45 }
46  
47 10 return qq|$name|;
48  
49 }
50  
51 sub default_export_hash {
52 11 ▶ my ( $self, $mg, $class, $export ) = @_;
Subroutine default_export_hash: called CC=19 SCAR=29.8
Pod documented
53 11 ▶ if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $mg || "") =~ /^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/) 2 9 11
Condition100%2/2
ref $mg || ''
l!l
101
MC/DC100%1/1
ref $mg || ''
ref $mg
Truth table100%2/2
A
A= ref $mg
Aresult
11
00
54 2 ▶ $mg = defined $mg ? $mg : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $mg ? : 2 0 2
55 2 die
56 qq{Object: invalid value $mg for variable \$mg in method default_export_hash};
57 }
58 9 ▶ if ( ( ref($class) || "" ) ne "HASH" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $class || "") ne "HASH") 2 7 9
Condition100%2/2
ref $class || ''
l!l
81
MC/DC100%1/1
ref $class || ''
ref $class
Truth table100%2/2
A
A= ref $class
Aresult
11
00
59 2 ▶ $class = defined $class ? $class : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $class ? : 2 0 2
60 2 die
61 qq{HashRef: invalid value $class for variable \$class in method default_export_hash};
62 }
63 7 ▶ $export = defined $export ? $export : {};
Branch: 1 branch
BranchTrueFalseTotal
defined $export ? : 2 5 7
64 7 ▶ if ( ( ref($export) || "" ) ne "HASH" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $export || "") ne "HASH") 2 5 7
Condition100%2/2
ref $export || ''
l!l
61
MC/DC100%1/1
ref $export || ''
ref $export
Truth table100%2/2
A
A= ref $export
Aresult
11
00
65 2 ▶ $export = defined $export ? $export : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $export ? : 2 0 2
66 2 die
67 qq{HashRef: invalid value $export for variable \$export in method default_export_hash};
68 }
69  
70 5 ▶ if ( $class->{CURRENT}->{BASE} || $class->{CURRENT}->{PARENT} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($class->{"CURRENT"}{"BASE"} or $class->{"CURRENT"}{"PARENT"}) 1 4 5
Condition66%2/3
$class->{"CURRENT"}{"BASE"} or $class->{"CURRENT"}{"PARENT"}
l!l&&r!l&&!r
104
MC/DC50%1/2
$class->{"CURRENT"}{"BASE"} or $class->{"CURRENT"}{"PARENT"}
$class->{"CURRENT"}{"BASE"} $class->{"CURRENT"}{"PARENT"}
Truth table66%2/3
A or B
A= $class->{"CURRENT"}{"BASE"}B= $class->{"CURRENT"}{"PARENT"}
ABresult
1X1
011
000
71 1 for my $cls (
72 1 ▶ @{ $class->{CURRENT}->{BASE} || [] },
Branch: 1 branch
BranchTrueFalseTotal
$class->{"CURRENT"}{"BASE"} or [] 0 1 1
73 1 ▶ @{ $class->{CURRENT}->{PARENT} || [] }
Branch: 1 branch
BranchTrueFalseTotal
$class->{"CURRENT"}{"PARENT"} or [] 1 0 1
74 )
75 {
76 1 ▶ if ( $self->export->{$cls} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->export->{$cls}) { } 1 0 1
77 1 my %unique;
78 1 for ( keys %{ $self->export->{$cls} } ) {
79 5 push @{ $export->{$_} },
80 39 map { $unique{$_}++; $_; }
81 5 @{ $self->export->{$cls}->{$_} };
82 }
83 1 for ( keys %unique ) {
84 13 $self->build_sub_no_arguments( $mg,
85 [ $_, "return ${cls}::$_(\@_)" ], {} );
86 }
87 }
88 else { }
89 }
90 }
91 5 return $export;
92  
93 }
94  
95 sub build_new {
96 9 ▶ my ( $self, $mg, $meta, $our ) = @_;
Subroutine build_new: called CC=15 SCAR=27.3
Pod documented
97 9 ▶ if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $mg || "") =~ /^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/) 2 7 9
Condition100%2/2
ref $mg || ''
l!l
81
MC/DC100%1/1
ref $mg || ''
ref $mg
Truth table100%2/2
A
A= ref $mg
Aresult
11
00
98 2 ▶ $mg = defined $mg ? $mg : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $mg ? : 2 0 2
99 2 die
100 qq{Object: invalid value $mg for variable \$mg in method build_new};
101 }
102 7 ▶ if ( ( ref($meta) || "" ) ne "HASH" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $meta || "") ne "HASH") 2 5 7
Condition100%2/2
ref $meta || ''
l!l
61
MC/DC100%1/1
ref $meta || ''
ref $meta
Truth table100%2/2
A
A= ref $meta
Aresult
11
00
103 2 ▶ $meta = defined $meta ? $meta : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $meta ? : 2 0 2
104 2 die
105 qq{HashRef: invalid value $meta for variable \$meta in method build_new};
106 }
107 5 ▶ $our = defined $our ? $our : q|@EXPORT, @EXPORT_OK, %EXPORT_TAGS|;
Branch: 1 branch
BranchTrueFalseTotal
defined $our ? : 0 5 5
108  
109 5 my %class = %Module::Generate::CLASS;
110 5 my $begin = '';
111 5 my $export = $self->default_export_hash( $mg, \%class );
112 5 for ( keys %{$meta} ) {
113 30 ▶ if ( $meta->{$_}->{meta} =~ m/^(ACCESSOR|METHOD)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($meta->{$_}{"meta"} =~ /^(ACCESSOR|METHOD)$/) 30 0 30
114 30 ▶ if ( $1 eq 'ACCESSOR' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($1 eq "ACCESSOR") 24 6 30
115 $begin .= $_ . q| => | . $meta->{$_}->{default} . q|, |
116 24 ▶ if $meta->{$_}->{default};
Branch: 1 branch
BranchTrueFalseTotal
if $meta->{$_}{"default"} 11 13 24
117 }
118 30 my $import = $meta->{$_}->{import};
119 30 my $now = shift @{$import};
120 30 $self->build_export_tags( $_, "${1}S", $export, $now, $import );
121 $self->build_export_tags( "has_$_", 'PREDICATES', $export, $now,
122 [] )
123 30 ▶ if $meta->{$_}->{predicate};
Branch: 1 branch
BranchTrueFalseTotal
if $meta->{$_}{"predicate"} 5 25 30
124 $self->build_export_tags( "clear_$_", 'CLEARERS', $export, $now,
125 [] )
126 30 ▶ if $meta->{$_}->{clearer};
Branch: 1 branch
BranchTrueFalseTotal
if $meta->{$_}{"clearer"} 8 22 30
127 }
128 }
129 5 $self->export->{ $class{CURRENT}{NAME} } = { %{$export} };
130 5 $mg->our( '(' . $our . ', %ACCESSORS)' );
131 5 $begin = $self->build_exporter( '%ACCESSORS = (' . $begin . ')',
132 $mg, $export, $meta );
133 5 ▶ if ( $class{CURRENT}{BEGIN} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($class{'CURRENT'}{'BEGIN'}) { } 0 5 5
134 0 ( my $code = $class{CURRENT}{BEGIN} ) =~ s/\s*\}\s*$//;
135 0 $begin = $code . $begin . "\}";
136 }
137 5 else { $begin = qq|{ $begin }|; }
138 5 $class{CURRENT}{BEGIN} = $begin;
139 5 delete $class{CURRENT}{SUBS}{new};
140  
141 }
142  
143 sub build_exporter {
144 13 ▶ my ( $self, $begin, $mg, $export, $meta ) = @_;
Subroutine build_exporter: called CC=13 SCAR=25.8
Pod documented
145 13 ▶ if ( !defined($begin) || ref $begin ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $begin or ref $begin) 2 11 13
Condition66%2/3
not defined $begin or ref $begin
l!l&&r!l&&!r
0211
MC/DC50%1/2
not defined $begin or ref $begin
not defined $begin ref $begin
Truth table66%2/3
not(A) or B
A= not defined $beginB= ref $begin
ABresult
1X1
011
000
146 2 ▶ $begin = defined $begin ? $begin : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $begin ? : 2 0 2
147 2 die
148 qq{Str: invalid value $begin for variable \$begin in method build_exporter};
149 }
150 11 ▶ if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $mg || "") =~ /^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/) 2 9 11
Condition100%2/2
ref $mg || ''
l!l
101
MC/DC100%1/1
ref $mg || ''
ref $mg
Truth table100%2/2
A
A= ref $mg
Aresult
11
00
151 2 ▶ $mg = defined $mg ? $mg : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $mg ? : 2 0 2
152 2 die
153 qq{Object: invalid value $mg for variable \$mg in method build_exporter};
154 }
155 9 ▶ if ( ( ref($export) || "" ) ne "HASH" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $export || "") ne "HASH") 2 7 9
Condition100%2/2
ref $export || ''
l!l
81
MC/DC100%1/1
ref $export || ''
ref $export
Truth table100%2/2
A
A= ref $export
Aresult
11
00
156 2 ▶ $export = defined $export ? $export : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $export ? : 2 0 2
157 2 die
158 qq{HashRef: invalid value $export for variable \$export in method build_exporter};
159 }
160 7 ▶ if ( ( ref($meta) || "" ) ne "HASH" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $meta || "") ne "HASH") 2 5 7
Condition100%2/2
ref $meta || ''
l!l
61
MC/DC100%1/1
ref $meta || ''
ref $meta
Truth table100%2/2
A
A= ref $meta
Aresult
11
00
161 2 ▶ $meta = defined $meta ? $meta : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $meta ? : 2 0 2
162 2 die
163 qq{HashRef: invalid value $meta for variable \$meta in method build_exporter};
164 }
165  
166 5 my $ex = delete $export->{EXPORT};
167 5 my $ex_ok = delete $export->{EXPORT_OK};
168 5 my $ex_tags = Module::Generate::_stringify_struct( 'undefined', $export );
169 5 $ex_tags =~ s/^{/(/;
170 5 $ex_tags =~ s/}$/);/;
171 $begin
172 = '@EXPORT = ('
173 33 . join( ', ', map {qq|'$_'|} @{$ex} ) . ');'
174 . '@EXPORT_OK = ('
175 5 . join( ', ', map {qq|'$_'|} @{$ex_ok} ) . ');'
176 . '%EXPORT_TAGS = '
177 . $ex_tags
178 . $begin;
179 5 return $begin;
180  
181 }
182  
183 sub build_export_tags {
184 53 ▶ my ( $self, $name, $type, $export, $now, $import ) = @_;
Subroutine build_export_tags: called CC=19 SCAR=29.7
Pod documented
185 53 ▶ if ( !defined($name) || ref $name ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $name or ref $name) 2 51 53
Condition66%2/3
not defined $name or ref $name
l!l&&r!l&&!r
0251
MC/DC50%1/2
not defined $name or ref $name
not defined $name ref $name
Truth table66%2/3
not(A) or B
A= not defined $nameB= ref $name
ABresult
1X1
011
000
186 2 ▶ $name = defined $name ? $name : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $name ? : 2 0 2
187 2 die
188 qq{Str: invalid value $name for variable \$name in method build_export_tags};
189 }
190 51 ▶ if ( !defined($type) || ref $type ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $type or ref $type) 2 49 51
Condition66%2/3
not defined $type or ref $type
l!l&&r!l&&!r
0249
MC/DC50%1/2
not defined $type or ref $type
not defined $type ref $type
Truth table66%2/3
not(A) or B
A= not defined $typeB= ref $type
ABresult
1X1
011
000
191 2 ▶ $type = defined $type ? $type : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $type ? : 2 0 2
192 2 die
193 qq{Str: invalid value $type for variable \$type in method build_export_tags};
194 }
195 49 ▶ if ( ( ref($export) || "" ) ne "HASH" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $export || "") ne "HASH") 2 47 49
Condition100%2/2
ref $export || ''
l!l
481
MC/DC100%1/1
ref $export || ''
ref $export
Truth table100%2/2
A
A= ref $export
Aresult
11
00
196 2 ▶ $export = defined $export ? $export : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $export ? : 2 0 2
197 2 die
198 qq{HashRef: invalid value $export for variable \$export in method build_export_tags};
199 }
200 47 ▶ if ( defined $now ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $now) 32 15 47
201 32 ▶ if ( ref $now || $now !~ m/^[-+\d]\d*$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $now or not $now =~ /^[-+\d]\d*$/) 2 30 32
Condition100%3/3
ref $now or not $now =~ /^[-+\d]\d*$/
l!l&&r!l&&!r
1130
MC/DC100%2/2
ref $now or not $now =~ /^[-+\d]\d*$/
ref $now not $now =~ /^[-+\d]\d*$/
Truth table100%3/3
A or not(B)
A= ref $nowB= not $now =~ /^[-+\d]\d*$/
ABresult
1X1
011
000
202 2 die
203 qq{Optional[Int]: invalid value $now for variable \$now in method build_export_tags};
204 }
205 }
206 45 ▶ if ( !defined($import) || ( ref($import) || "" ) ne "ARRAY" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $import or (ref $import || "") ne "ARRAY") 2 43 45
Condition80%4/5
not defined $import or (ref $import || "") ne "ARRAY"
l!l&&r!l&&!r
0243
ref $import || ''
l!l
441
MC/DC50%1/2
not defined $import or (ref $import || "") ne "ARRAY"
not defined $import ref $import
Truth table66%2/3
not(A) or B
A= not defined $importB= ref $import
ABresult
1X1
011
000
207 2 ▶ $import = defined $import ? $import : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $import ? : 2 0 2
208 2 die
209 qq{ArrayRef: invalid value $import for variable \$import in method build_export_tags};
210 }
211  
212 43 push @{ $export->{$type} }, $name;
213 43 push @{ $export->{EXPORT_OK} }, $name;
214 43 ▶ push @{ $export->{EXPORT} }, $name if $now;
Branch: 1 branch
BranchTrueFalseTotal
if $now 20 23 43
215 43 for my $i ( @{$import} ) {
216 2 $i =~ s/^\s*|\s*$//;
217 2 push @{ $export->{$i} }, $name;
218 }
219 43 return $export;
220  
221 }
222  
223 sub after_class {
224 7 ▶ my ( $self, $mg ) = @_;
Subroutine after_class: called CC=4 SCAR=13.9
Pod documented
225 7 ▶ if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $mg || "") =~ /^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/) 2 5 7
Condition100%2/2
ref $mg || ''
l!l
61
MC/DC100%1/1
ref $mg || ''
ref $mg
Truth table100%2/2
A
A= ref $mg
Aresult
11
00
226 2 ▶ $mg = defined $mg ? $mg : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $mg ? : 2 0 2
227 2 die
228 qq{Object: invalid value $mg for variable \$mg in method after_class};
229 }
230  
231 5 $mg->use(q|Exporter qw/import/|);
232  
233 }
234  
235 sub build_sub_or_accessor_attributes {
236 30 ▶ my ( $orig, $self, @params )
Subroutine build_sub_or_accessor_attributes: called CC=2 SCAR=7.0
Pod documented
237 = ( 'SUPER::build_sub_or_accessor_attributes', @_ );
238  
239 30 my @res = $self->$orig(@params);
240 unshift @res, (
241 qr/^(\:import|\:i$)/ => sub {
242 6 ▶ $params[-1]->{ $params[-3] }->{import} = [0];
Subroutine __ANON__: called CC=1 SCAR=0.0
243 },
244 qr/^(\:import|\:i)\(/ => sub {
245 14 ▶ my $value = shift;
Subroutine __ANON__: called CC=1 SCAR=0.0
246 14 $value =~ s/(\:import|\:i)\((.*)\)$/$2/sg;
247 14 $params[-1]->{ $params[-3] }->{import} = [ split /,/, $value ];
248 }
249 30 );
250  
251 30 ▶ return wantarray ? @res : $res[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 30 0 30
252 }
253  
254 sub build_accessor_no_arguments {
255 0 ▶ my ( $self, $mg, $token, $meta ) = @_;
Subroutine build_accessor_no_arguments: not called CC=1 SCAR=6.9
Pod documented
256  
257 0 $meta->{ $token->[0] }->{meta} = 'ACCESSOR';
258 $mg->accessor( $token->[0] )
259 ->code( $self->build_accessor_code( $token->[0], '', '', '' ) )
260 ->clear_tests->test(
261 $self->build_tests(
262 0 $token->[0], $meta->{ $token->[0] },
263 '', {%Module::Generate::CLASS}
264 )
265 )->pod(qq|call $token->[0] accessor function.|)
266 ->example(qq|$token->[0](\$value)|);
267 0 return $meta;
268  
269 }
270  
271 sub build_accessor_code {
272 32 ▶ my ( $self, $name, $private, $type, $trigger ) = @_;
Subroutine build_accessor_code: called CC=13 SCAR=26.5
Pod documented
273 32 ▶ if ( !defined($name) || ref $name ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $name or ref $name) 2 30 32
Condition66%2/3
not defined $name or ref $name
l!l&&r!l&&!r
0230
MC/DC50%1/2
not defined $name or ref $name
not defined $name ref $name
Truth table66%2/3
not(A) or B
A= not defined $nameB= ref $name
ABresult
1X1
011
000
274 2 ▶ $name = defined $name ? $name : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $name ? : 2 0 2
275 2 die
276 qq{Str: invalid value $name for variable \$name in method build_accessor_code};
277 }
278 30 ▶ if ( !defined($private) || ref $private ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $private or ref $private) 2 28 30
Condition66%2/3
not defined $private or ref $private
l!l&&r!l&&!r
0228
MC/DC50%1/2
not defined $private or ref $private
not defined $private ref $private
Truth table66%2/3
not(A) or B
A= not defined $privateB= ref $private
ABresult
1X1
011
000
279 2 ▶ $private = defined $private ? $private : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $private ? : 2 0 2
280 2 die
281 qq{Str: invalid value $private for variable \$private in method build_accessor_code};
282 }
283 28 ▶ if ( !defined($type) || ref $type ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $type or ref $type) 2 26 28
Condition66%2/3
not defined $type or ref $type
l!l&&r!l&&!r
0226
MC/DC50%1/2
not defined $type or ref $type
not defined $type ref $type
Truth table66%2/3
not(A) or B
A= not defined $typeB= ref $type
ABresult
1X1
011
000
284 2 ▶ $type = defined $type ? $type : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $type ? : 2 0 2
285 2 die
286 qq{Str: invalid value $type for variable \$type in method build_accessor_code};
287 }
288 26 ▶ if ( !defined($trigger) || ref $trigger ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $trigger or ref $trigger) 2 24 26
Condition66%2/3
not defined $trigger or ref $trigger
l!l&&r!l&&!r
0224
MC/DC50%1/2
not defined $trigger or ref $trigger
not defined $trigger ref $trigger
Truth table66%2/3
not(A) or B
A= not defined $triggerB= ref $trigger
ABresult
1X1
011
000
289 2 ▶ $trigger = defined $trigger ? $trigger : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $trigger ? : 2 0 2
290 2 die
291 qq{Str: invalid value $trigger for variable \$trigger in method build_accessor_code};
292 }
293  
294 24 return qq|{
295 my ( \$value ) = \@_; $private
296 if ( defined \$value ) { $type
297 \$ACCESSORS{$name} = \$value; $trigger
298 }
299 return \$ACCESSORS{$name};
300 }|;
301  
302 }
303  
304 sub build_accessor {
305 24 ▶ my ( $orig, $self, @params ) = ( 'SUPER::build_accessor', @_ );
Subroutine build_accessor: called CC=5 SCAR=16.6
Pod documented
306  
307 24 my @res = $self->$orig(@params);
308 $params[0]->clear_tests->test(
309 $self->build_tests(
310 24 $params[1], $params[2]->{ $params[1] },
311 '', {%Module::Generate::CLASS}
312 )
313 );
314 $params[0]->pod(
315 sprintf
316 q|call %s accessor function. Expects a single param to be of type %s.|,
317 $params[1],
318 $params[2]->{ $params[1] }->{type}->[0] || 'Any'
319 24 ▶ ) unless $params[2]->{ $params[1] }->{pod};
Branch: 1 branch
BranchTrueFalseTotal
unless $params[2]{$params[1]}{"pod"} 24 0 24
Condition100%2/2
$params[2]{$params[1]}{'type'}[0] || 'Any'
l!l
213
MC/DC100%1/1
$params[2]{$params[1]}{'type'}[0] || 'Any'
$params[2]{$params[1]}{'type'}[0]
Truth table100%2/2
A
A= $params[2]{$params[1]}{'type'}[0]
Aresult
11
00
320 $params[0]->example(qq|$params[1]()|)
321 24 ▶ unless $params[2]->{ $params[1] }->{example};
Branch: 1 branch
BranchTrueFalseTotal
unless $params[2]{$params[1]}{"example"} 24 0 24
322  
323 24 ▶ return wantarray ? @res : $res[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 24 24
324 }
325  
326 sub build_modify {
327 0 ▶ my ($self) = @_;
Subroutine build_modify: not called CC=1 SCAR=6.9
Pod documented
328  
329 }
330  
331 sub build_sub_no_arguments {
332 13 ▶ my ( $self, $mg, $token, $meta ) = @_;
Subroutine build_sub_no_arguments: called CC=2 SCAR=7.1
Pod documented
333  
334 13 my $name = shift @{$token};
335 $name =~ m/^(begin|unitcheck|check|init|end|new)$/
336 0 ? $mg->$name( join ' ', @{$token} )
337 : $mg->sub($name)
338 13 ▶ ->code( $self->build_sub_code( '', '', '', join( ' ', @{$token} ) ) )
Branch: 1 branch
BranchTrueFalseTotal
$name =~ /^(begin|unitcheck|check|init|end|new)$/ ? : 0 13 13
339 ->pod(qq|call $name function. Expects no params.|)
340 ->example(qq|$name()|);
341 13 return $meta;
342  
343 }
344  
345 sub build_sub_code {
346 27 ▶ my ( $self, $name, $params, $subtype, $code ) = @_;
Subroutine build_sub_code: called CC=14 SCAR=27.1
Pod documented
347 27 ▶ if ( !defined($name) || ref $name ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $name or ref $name) 2 25 27
Condition66%2/3
not defined $name or ref $name
l!l&&r!l&&!r
0225
MC/DC50%1/2
not defined $name or ref $name
not defined $name ref $name
Truth table66%2/3
not(A) or B
A= not defined $nameB= ref $name
ABresult
1X1
011
000
348 2 ▶ $name = defined $name ? $name : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $name ? : 2 0 2
349 2 die
350 qq{Str: invalid value $name for variable \$name in method build_sub_code};
351 }
352 25 ▶ if ( !defined($params) || ref $params ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $params or ref $params) 2 23 25
Condition66%2/3
not defined $params or ref $params
l!l&&r!l&&!r
0223
MC/DC50%1/2
not defined $params or ref $params
not defined $params ref $params
Truth table66%2/3
not(A) or B
A= not defined $paramsB= ref $params
ABresult
1X1
011
000
353 2 ▶ $params = defined $params ? $params : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $params ? : 2 0 2
354 2 die
355 qq{Str: invalid value $params for variable \$params in method build_sub_code};
356 }
357 23 ▶ if ( !defined($subtype) || ref $subtype ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $subtype or ref $subtype) 2 21 23
Condition66%2/3
not defined $subtype or ref $subtype
l!l&&r!l&&!r
0221
MC/DC50%1/2
not defined $subtype or ref $subtype
not defined $subtype ref $subtype
Truth table66%2/3
not(A) or B
A= not defined $subtypeB= ref $subtype
ABresult
1X1
011
000
358 2 ▶ $subtype = defined $subtype ? $subtype : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $subtype ? : 2 0 2
359 2 die
360 qq{Str: invalid value $subtype for variable \$subtype in method build_sub_code};
361 }
362 21 ▶ if ( !defined($code) || ref $code ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $code or ref $code) 2 19 21
Condition66%2/3
not defined $code or ref $code
l!l&&r!l&&!r
0219
MC/DC50%1/2
not defined $code or ref $code
not defined $code ref $code
Truth table66%2/3
not(A) or B
A= not defined $codeB= ref $code
ABresult
1X1
011
000
363 2 ▶ $code = defined $code ? $code : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $code ? : 2 0 2
364 2 die
365 qq{Str: invalid value $code for variable \$code in method build_sub_code};
366 }
367  
368 19 $params =~ s/^\s*,\s*//;
369 19 ▶ $params = qq|my ($params) = \@_;| if $params;
Branch: 1 branch
BranchTrueFalseTotal
if $params 5 14 19
370 19 return qq|{
371 $params $subtype
372 $code;
373 }|;
374  
375 }
376  
377 sub build_sub {
378 6 ▶ my ( $orig, $self, @params ) = ( 'SUPER::build_sub', @_ );
Subroutine build_sub: called CC=2 SCAR=7.0
Pod documented
379  
380 6 my @res = $self->$orig(@params);
381 $params[0]->clear_tests->test(
382 $self->build_tests(
383 6 $params[1], $params[2]->{ $params[1] },
384 '', {%Module::Generate::CLASS}
385 )
386 );
387 6 $params[0]->pod(
388 qq|call $params[1] function. Expects $params[2]->{$params[1]}->{params_explanation}|
389 );
390  
391 6 ▶ return wantarray ? @res : $res[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 6 6
392 }
393  
394 sub build_clearer {
395 14 ▶ my ( $self, $mg, $name, $meta ) = @_;
Subroutine build_clearer: called CC=10 SCAR=23.2
Pod documented
396 14 ▶ if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $mg || "") =~ /^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/) 2 12 14
Condition100%2/2
ref $mg || ''
l!l
131
MC/DC100%1/1
ref $mg || ''
ref $mg
Truth table100%2/2
A
A= ref $mg
Aresult
11
00
397 2 ▶ $mg = defined $mg ? $mg : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $mg ? : 2 0 2
398 2 die
399 qq{Object: invalid value $mg for variable \$mg in method build_clearer};
400 }
401 12 ▶ if ( !defined($name) || ref $name ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $name or ref $name) 2 10 12
Condition66%2/3
not defined $name or ref $name
l!l&&r!l&&!r
0210
MC/DC50%1/2
not defined $name or ref $name
not defined $name ref $name
Truth table66%2/3
not(A) or B
A= not defined $nameB= ref $name
ABresult
1X1
011
000
402 2 ▶ $name = defined $name ? $name : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $name ? : 2 0 2
403 2 die
404 qq{Str: invalid value $name for variable \$name in method build_clearer};
405 }
406 10 ▶ if ( ( ref($meta) || "" ) ne "HASH" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $meta || "") ne "HASH") 2 8 10
Condition100%2/2
ref $meta || ''
l!l
91
MC/DC100%1/1
ref $meta || ''
ref $meta
Truth table100%2/2
A
A= ref $meta
Aresult
11
00
407 2 ▶ $meta = defined $meta ? $meta : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $meta ? : 2 0 2
408 2 die
409 qq{HashRef: invalid value $meta for variable \$meta in method build_clearer};
410 }
411  
412 8 my %class = %Module::Generate::CLASS;
413 8 $mg->sub(qq|clear_$name|)->code(
414 qq|{
415 delete \$ACCESSORS{$name};
416 return 1;
417 }|
418 )->pod(qq|clear $name accessor function.|)
419 ->example(qq|clear_$name()|)->clear_tests->test(
420 [ 'ok', qq|$class{CURRENT}{NAME}::clear_$name| ],
421 [ 'is', qq|$class{CURRENT}{NAME}::$name|, 'undef' ]
422 );
423  
424 }
425  
426 sub build_predicate {
427 11 ▶ my ( $self, $mg, $name, $meta ) = @_;
Subroutine build_predicate: called CC=12 SCAR=25.4
Pod documented
428 11 ▶ if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $mg || "") =~ /^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/) 2 9 11
Condition100%2/2
ref $mg || ''
l!l
101
MC/DC100%1/1
ref $mg || ''
ref $mg
Truth table100%2/2
A
A= ref $mg
Aresult
11
00
429 2 ▶ $mg = defined $mg ? $mg : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $mg ? : 2 0 2
430 2 die
431 qq{Object: invalid value $mg for variable \$mg in method build_predicate};
432 }
433 9 ▶ if ( !defined($name) || ref $name ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $name or ref $name) 2 7 9
Condition66%2/3
not defined $name or ref $name
l!l&&r!l&&!r
027
MC/DC50%1/2
not defined $name or ref $name
not defined $name ref $name
Truth table66%2/3
not(A) or B
A= not defined $nameB= ref $name
ABresult
1X1
011
000
434 2 ▶ $name = defined $name ? $name : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $name ? : 2 0 2
435 2 die
436 qq{Str: invalid value $name for variable \$name in method build_predicate};
437 }
438 7 ▶ if ( ( ref($meta) || "" ) ne "HASH" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $meta || "") ne "HASH") 2 5 7
Condition100%2/2
ref $meta || ''
l!l
61
MC/DC100%1/1
ref $meta || ''
ref $meta
Truth table100%2/2
A
A= ref $meta
Aresult
11
00
439 2 ▶ $meta = defined $meta ? $meta : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $meta ? : 2 0 2
440 2 die
441 qq{HashRef: invalid value $meta for variable \$meta in method build_predicate};
442 }
443  
444 5 my %class = %Module::Generate::CLASS;
445 $mg->sub(qq|has_$name|)->code(
446 qq|{
447 return exists \$ACCESSORS{$name};
448 }|
449 )
450 ->pod(
451 qq|has_$name accessor function will return trye if $name accessor has a value.|
452 )->example(qq|has_$name()|)->clear_tests->test(
453 ( $meta->{$name}->{required} || $meta->{$name}->{default}
454 ? ( [ 'is', qq|$class{CURRENT}{NAME}::has_$name|, 1 ], )
455 : ( [ 'is', qq|$class{CURRENT}{NAME}::has_$name|, q|''| ], )
456 ),
457 5 ▶ $self->build_tests( $name, $meta->{$name}, '', \%class ),
Branch: 1 branch
BranchTrueFalseTotal
$meta->{$name}{'required'} || $meta->{$name}{'default'} ? : 5 0 5
Condition66%2/3
$meta->{$name}{"required"} or $meta->{$name}{"default"}
l!l&&r!l&&!r
410
MC/DC0%0/2
$meta->{$name}{"required"} or $meta->{$name}{"default"}
$meta->{$name}{"required"} $meta->{$name}{"default"}
Truth table66%2/3
A or B
A= $meta->{$name}{"required"}B= $meta->{$name}{"default"}
ABresult
1X1
011
000
458 [ 'is', qq|$class{CURRENT}{NAME}::has_$name|, 1 ],
459 );
460  
461 }
462  
463 sub build_coerce {
464 35 ▶ my ( $self, $name, $param, $code ) = @_;
Subroutine build_coerce: called CC=11 SCAR=25.4
Pod documented
465 35 ▶ if ( !defined($name) || ref $name ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $name or ref $name) 2 33 35
Condition66%2/3
not defined $name or ref $name
l!l&&r!l&&!r
0233
MC/DC50%1/2
not defined $name or ref $name
not defined $name ref $name
Truth table66%2/3
not(A) or B
A= not defined $nameB= ref $name
ABresult
1X1
011
000
466 2 ▶ $name = defined $name ? $name : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $name ? : 2 0 2
467 2 die
468 qq{Str: invalid value $name for variable \$name in method build_coerce};
469 }
470 33 ▶ if ( !defined($param) || ref $param ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $param or ref $param) 2 31 33
Condition66%2/3
not defined $param or ref $param
l!l&&r!l&&!r
0231
MC/DC50%1/2
not defined $param or ref $param
not defined $param ref $param
Truth table66%2/3
not(A) or B
A= not defined $paramB= ref $param
ABresult
1X1
011
000
471 2 ▶ $param = defined $param ? $param : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $param ? : 2 0 2
472 2 die
473 qq{Str: invalid value $param for variable \$param in method build_coerce};
474 }
475 31 ▶ if ( defined $code ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $code) 2 29 31
476 2 ▶ if ( ref $code ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $code) 2 0 2
477 2 die
478 qq{Optional[Str]: invalid value $code for variable \$code in method build_coerce};
479 }
480 }
481  
482 return
483 29 ▶ defined $code
Branch: 2 branches
BranchTrueFalseTotal
defined $code ? : 0 29 29
$code =~ /^\w+$/ ? : 0 0 0
484 ? $code =~ m/^\w+$/
485 ? qq|$param = $code($param);|
486 : $code
487 : q||;
488  
489 }
490  
491 sub build_trigger {
492 30 ▶ my ( $self, $name, $param, $code ) = @_;
Subroutine build_trigger: called CC=12 SCAR=27.3
Pod documented
493 30 ▶ if ( !defined($name) || ref $name ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $name or ref $name) 2 28 30
Condition66%2/3
not defined $name or ref $name
l!l&&r!l&&!r
0228
MC/DC50%1/2
not defined $name or ref $name
not defined $name ref $name
Truth table66%2/3
not(A) or B
A= not defined $nameB= ref $name
ABresult
1X1
011
000
494 2 ▶ $name = defined $name ? $name : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $name ? : 2 0 2
495 2 die
496 qq{Str: invalid value $name for variable \$name in method build_trigger};
497 }
498 28 ▶ if ( !defined($param) || ref $param ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $param or ref $param) 2 26 28
Condition66%2/3
not defined $param or ref $param
l!l&&r!l&&!r
0226
MC/DC50%1/2
not defined $param or ref $param
not defined $param ref $param
Truth table66%2/3
not(A) or B
A= not defined $paramB= ref $param
ABresult
1X1
011
000
499 2 ▶ $param = defined $param ? $param : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $param ? : 2 0 2
500 2 die
501 qq{Str: invalid value $param for variable \$param in method build_trigger};
502 }
503 26 ▶ if ( defined $code ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $code) 2 24 26
504 2 ▶ if ( ref $code ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $code) 2 0 2
505 2 die
506 qq{Optional[Str]: invalid value $code for variable \$code in method build_trigger};
507 }
508 }
509  
510 return
511 24 ▶ defined $code
Branch: 3 branches
BranchTrueFalseTotal
defined $code ? : 0 24 24
$code =~ /^1$/ ? : 0 0 0
$code =~ /^\w+$/ ? : 0 0 0
512 ? $code =~ m/^1$/
513 ? qq|_trigger_$name|
514 : $code =~ m/^\w+$/ ? qq|$code($param);|
515 : $code
516 : q||;
517  
518 }
519  
520 sub build_tests {
521 73 ▶ my ( $self, $name, $meta, $mod, $class ) = @_;
Subroutine build_tests: called CC=31 SCAR=34.8
Pod documented
522 73 ▶ if ( !defined($name) || ref $name ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $name or ref $name) 2 71 73
Condition66%2/3
not defined $name or ref $name
l!l&&r!l&&!r
0271
MC/DC50%1/2
not defined $name or ref $name
not defined $name ref $name
Truth table66%2/3
not(A) or B
A= not defined $nameB= ref $name
ABresult
1X1
011
000
523 2 ▶ $name = defined $name ? $name : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $name ? : 2 0 2
524 2 die
525 qq{Str: invalid value $name for variable \$name in method build_tests};
526 }
527 71 ▶ if ( ( ref($meta) || "" ) ne "HASH" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $meta || "") ne "HASH") 2 69 71
Condition100%2/2
ref $meta || ''
l!l
701
MC/DC100%1/1
ref $meta || ''
ref $meta
Truth table100%2/2
A
A= ref $meta
Aresult
11
00
528 2 ▶ $meta = defined $meta ? $meta : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $meta ? : 2 0 2
529 2 die
530 qq{HashRef: invalid value $meta for variable \$meta in method build_tests};
531 }
532 69 ▶ if ( defined $mod ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $mod) 37 32 69
533 37 ▶ if ( ref $mod ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $mod) 2 35 37
534 2 die
535 qq{Optional[Str]: invalid value $mod for variable \$mod in method build_tests};
536 }
537 }
538 67 ▶ if ( defined $class ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $class) 37 30 67
539 37 ▶ if ( ( ref($class) || "" ) ne "HASH" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $class || "") ne "HASH") 2 35 37
Condition100%2/2
ref $class || ''
l!l
361
MC/DC100%1/1
ref $class || ''
ref $class
Truth table100%2/2
A
A= ref $class
Aresult
11
00
540 2 die
541 qq{Optional[HashRef]: invalid value $class for variable \$class in method build_tests};
542 }
543 }
544  
545 65 my @tests;
546 65 ▶ if ($class) {
Branch: 1 branch
BranchTrueFalseTotal
if ($class) 35 30 65
547 35 my $cls = $class->{CURRENT}->{NAME};
548 35 ▶ if ( $meta->{meta} eq 'ACCESSOR' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($meta->{'meta'} eq 'ACCESSOR') { } 29 6 35
elsif ($meta->{'meta'} eq 'METHOD') { } 6 0 6
549 $meta->{private}
550 ? do {
551 8 push @tests,
552 [
553 'eval',
554 qq|${cls}::${name}()|,
555 'private method|private attribute'
556 ];
557 }
558 29 ▶ : do {
Branch: 1 branch
BranchTrueFalseTotal
$meta->{'private'} ? : 8 21 29
559 push @tests, [ 'is', qq|${cls}::${name}()|, 'undef' ]
560 21 ▶ if !$meta->{required} && !$meta->{default};
Branch: 1 branch
BranchTrueFalseTotal
unless $meta->{"required"} or $meta->{"default"} 12 9 21
Condition100%3/3
$meta->{"required"} or $meta->{"default"}
l!l&&r!l&&!r
3612
MC/DC100%2/2
$meta->{"required"} or $meta->{"default"}
$meta->{"required"} $meta->{"default"}
Truth table100%3/3
A or B
A= $meta->{"required"}B= $meta->{"default"}
ABresult
1X1
011
000
561 21 push @tests, [ 'eval', qq|${cls}::${name}()|, q|^$| ];
562 my (@test_cases)
563 21 ▶ = $self->build_test_data( $meta->{type}->[0] || 'Any',
Condition100%2/2
$meta->{'type'}[0] || 'Any'
l!l
183
MC/DC100%1/1
$meta->{'type'}[0] || 'Any'
$meta->{'type'}[0]
Truth table100%2/2
A
A= $meta->{'type'}[0]
Aresult
11
00
564 $name );
565 21 ▶ if ( scalar @test_cases > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @test_cases > 1) 18 3 21
566 18 my $valid = shift @test_cases;
567 18 push @tests,
568 [ 'deep', qq|${cls}::${name}($valid)|, $valid ];
569 18 ▶ unless ( $meta->{coerce} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($meta->{"coerce"}) 18 0 18
570 18 for (@test_cases) {
571 95 push @tests,
572 [
573 'eval', qq|${cls}::${name}($_)|,
574 'invalid|value|type|constraint|greater|atleast'
575 ];
576 }
577 }
578 18 push @tests, [ 'deep', qq|${cls}::${name}|, $valid ];
579 }
580 };
581 }
582 elsif ( $meta->{meta} eq 'METHOD' ) {
583 $meta->{private}
584 ? do {
585 0 ▶ push @tests,
Condition66%2/3
$meta->{"param"} and do {
!ll&&!rl&&r
150
MC/DC0%0/2
$meta->{"param"} and do { my(%test_data) = map({$_, [$self->build_test_data($meta->{"params_map"}{$_}{"type"} || "Any", $name), !(($meta->{"params_map"}{$_}{"type"} || "Any") =~ /^(|Optional|Any|Item)/) ? "undef" : ()];} @{$$meta{"param"};}); foreach my $key (@{$$meta{"param"};}) { foreach my $ah (splice @{$test_data{$key};}, 1) { push @tests, ["eval", sprintf('%s::%s(%s)', $cls, $name, join(", ", map({$key eq $_ ? $ah : $test_data{$_}[0];} @{$$meta{"param"};}))), "invalid|value|type|constraint|greater|atleast"]; } ; } }
$meta->{"param"} do { my(%test_data) = map({$_, [$self->build_test_data($meta->{"params_map"}{$_}{"type"} || "Any", $name), !(($meta->{"params_map"}{$_}{"type"} || "Any") =~ /^(|Optional|Any|Item)/) ? "undef" : ()];} @{$$meta{"param"};}); foreach my $key (@{$$meta{"param"};}) { foreach my $ah (splice @{$test_data{$key};}, 1) { push @tests, ["eval", sprintf('%s::%s(%s)', $cls, $name, join(", ", map({$key eq $_ ? $ah : $test_data{$_}[0];} @{$$meta{"param"};}))), "invalid|value|type|constraint|greater|atleast"]; } ; } }
Truth table66%2/3
A and B
A= $meta->{"param"}B= do { my(%test_data) = map({$_, [$self->build_test_data($meta->{"params_map"}{$_}{"type"} || "Any", $name), !(($meta->{"params_map"}{$_}{"type"} || "Any") =~ /^(|Optional|Any|Item)/) ? "undef" : ()];} @{$$meta{"param"};}); foreach my $key (@{$$meta{"param"};}) { foreach my $ah (splice @{$test_data{$key};}, 1) { push @tests, ["eval", sprintf('%s::%s(%s)', $cls, $name, join(", ", map({$key eq $_ ? $ah : $test_data{$_}[0];} @{$$meta{"param"};}))), "invalid|value|type|constraint|greater|atleast"]; } ; } }
ABresult
0X0
100
111
586 [ 'eval', qq|${cls}::${name}()|, 'private method' ];
587 }
588 6 ▶ : $meta->{param} && do {
Branch: 1 branch
BranchTrueFalseTotal
$meta->{'private'} ? : 0 6 6
589 my %test_data = map {
590 $_ => [
591 $self->build_test_data(
592 $meta->{params_map}->{$_}->{type} || 'Any', $name
593 ),
594 5 ▶ ( $meta->{params_map}->{$_}->{type} || 'Any' )
Branch: 1 branch
BranchTrueFalseTotal
!(($meta->{'params_map'}{$_}{'type'} || 'Any') =~ /^(|Optional|Any|Item)/) ? : 0 5 5
Condition50%2/4
$meta->{'params_map'}{$_}{'type'} || 'Any'
l!l
50
$meta->{'params_map'}{$_}{'type'} || 'Any'
l!l
50
MC/DC0%0/1
$meta->{'params_map'}{$_}{'type'} || 'Any'
$meta->{'params_map'}{$_}{'type'}
MC/DC0%0/1
$meta->{'params_map'}{$_}{'type'} || 'Any'
$meta->{'params_map'}{$_}{'type'}
Truth table50%1/2
A
A= $meta->{'params_map'}{$_}{'type'}
Aresult
11
00
Truth table50%1/2
A
A= $meta->{'params_map'}{$_}{'type'}
Aresult
11
00
595 !~ m/^(|Optional|Any|Item)/ ? q|undef| : ()
596 ]
597 5 } @{ $meta->{param} };
598 5 for my $key ( @{ $meta->{param} } ) {
599 5 for my $ah ( splice @{ $test_data{$key} }, 1 ) {
600 push @tests,
601 [
602 'eval',
603 sprintf(
604 q|%s::%s(%s)|,
605 $cls, $name,
606 join ', ',
607 10 ▶ map { $key eq $_ ? $ah : $test_data{$_}->[0] }
Branch: 1 branch
BranchTrueFalseTotal
$key eq $_ ? : 10 0 10
608 10 @{ $meta->{param} }
609 ),
610 'invalid|value|type|constraint|greater|atleast'
611 ];
612 }
613 }
614 }
615 }
616 }
617 65 ▶ push @tests, @{ $meta->{test} } if $meta->{test};
Branch: 1 branch
BranchTrueFalseTotal
if $meta->{"test"} 2 63 65
618 65 return @tests;
619  
620 }
621  
622 6 1;
623  
624 __END__
625  
626 =head1 NAME
627  
628 Hades::Realm::Exporter - Hades realm for Exporter
629  
630 =head1 VERSION
631  
632 Version 0.01
633  
634 =cut
635  
636 =head1 SYNOPSIS
637  
638 Quick summary of what the module does:
639  
640 Hades->run({
641 eval => 'Kosmos {
642 [curae penthos] :t(Int) :d(2) :p :pr :c :r :i(1, GROUP)
643 geras $nosoi :t(Int) :d(5) :i { if (penthos() == $nosoi) { return curae; } }
644 }',
645 realm => 'Exporter',
646 });
647  
648 ... generates ...
649  
650 package Kosmos;
651 use strict;
652 use warnings;
653 use Exporter qw/import/;
654 our $VERSION = 0.01;
655 our ( @EXPORT, @EXPORT_OK, %EXPORT_TAGS, %ACCESSORS );
656  
657 BEGIN {
658 @EXPORT = (
659 'curae', 'has_curae', 'clear_curae', 'penthos',
660 'has_penthos', 'clear_penthos'
661 );
662 @EXPORT_OK = (
663 'curae', 'has_curae', 'clear_curae', 'penthos',
664 'has_penthos', 'clear_penthos', 'geras'
665 );
666 %EXPORT_TAGS = (
667 'METHODS' => ['geras'],
668 'CLEARERS' => [ 'clear_curae', 'clear_penthos' ],
669 'GROUP' => [ 'curae', 'penthos' ],
670 'PREDICATES' => [ 'has_curae', 'has_penthos' ],
671 'ACCESSORS' => [ 'curae', 'penthos' ]
672 );
673 %ACCESSORS = ( curae => 2, penthos => 2, );
674 }
675  
676 sub curae {
677 my ($value) = @_;
678 my $private_caller = caller();
679 if ( $private_caller ne __PACKAGE__ ) {
680 die "cannot call private method curae from $private_caller";
681 }
682 if ( defined $value ) {
683 if ( ref $value || $value !~ m/^[-+\d]\d*$/ ) {
684 die qq{Int: invalid value $value for accessor curae};
685 }
686 $ACCESSORS{curae} = $value;
687 }
688 return $ACCESSORS{curae};
689 }
690  
691 sub has_curae {
692 return exists $ACCESSORS{curae};
693 }
694  
695 sub clear_curae {
696 delete $ACCESSORS{curae};
697 return 1;
698 }
699  
700 sub penthos {
701 my ($value) = @_;
702 my $private_caller = caller();
703 if ( $private_caller ne __PACKAGE__ ) {
704 die "cannot call private method penthos from $private_caller";
705 }
706 if ( defined $value ) {
707 if ( ref $value || $value !~ m/^[-+\d]\d*$/ ) {
708 die qq{Int: invalid value $value for accessor penthos};
709 }
710 $ACCESSORS{penthos} = $value;
711 }
712 return $ACCESSORS{penthos};
713 }
714  
715 sub has_penthos {
716 return exists $ACCESSORS{penthos};
717 }
718  
719 sub clear_penthos {
720 delete $ACCESSORS{penthos};
721 return 1;
722 }
723  
724 sub geras {
725 my ($nosoi) = @_;
726 $nosoi = defined $nosoi ? $nosoi : 5;
727 if ( !defined($nosoi) || ref $nosoi || $nosoi !~ m/^[-+\d]\d*$/ ) {
728 $nosoi = defined $nosoi ? $nosoi : 'undef';
729 die
730 qq{Int: invalid value $nosoi for variable \$nosoi in method geras};
731 }
732 if ( penthos() == $nosoi ) { return curae(); }
733 }
734  
735 1;
736  
737 __END__
738  
739 =head1 SUBROUTINES/METHODS
740  
741 =head2 new
742  
743 Instantiate a new Hades::Realm::Exporter object.
744  
745 Hades::Realm::Exporter->new
746  
747 =head2 build_self
748  
749 call build_self method. Expects param $name to be a Optional[Str].
750  
751 $obj->build_self($name)
752  
753 =head2 default_export_hash
754  
755 call default_export_hash method. Expects param $mg to be a Object, param $class to be a HashRef, param $export to be a HashRef.
756  
757 $obj->default_export_hash($mg, $class, $export)
758  
759 =head2 build_new
760  
761 call build_new method. Expects param $mg to be a Object, param $meta to be a HashRef, param $our to be any value including undef.
762  
763 $obj->build_new($mg, $meta, $our)
764  
765 =head2 build_exporter
766  
767 call build_exporter method. Expects param $begin to be a Str, param $mg to be a Object, param $export to be a HashRef, param $meta to be a HashRef.
768  
769 $obj->build_exporter($begin, $mg, $export, $meta)
770  
771 =head2 build_export_tags
772  
773 call build_export_tags method. Expects param $name to be a Str, param $type to be a Str, param $export to be a HashRef, param $now to be a Optional[Int], param $import to be a ArrayRef.
774  
775 $obj->build_export_tags($name, $type, $export, $now, $import)
776  
777 =head2 after_class
778  
779 call after_class method. Expects param $mg to be a Object.
780  
781 $obj->after_class($mg)
782  
783 =head2 build_sub_or_accessor_attributes
784  
785 call build_sub_or_accessor_attributes method.
786  
787 =head2 build_accessor_no_arguments
788  
789 call build_accessor_no_arguments method. Expects param $mg to be any value including undef, param $token to be any value including undef, param $meta to be any value including undef.
790  
791 $obj->build_accessor_no_arguments($mg, $token, $meta)
792  
793 =head2 build_accessor_code
794  
795 call build_accessor_code method. Expects param $name to be a Str, param $private to be a Str, param $type to be a Str, param $trigger to be a Str.
796  
797 $obj->build_accessor_code($name, $private, $type, $trigger)
798  
799 =head2 build_accessor
800  
801 call build_accessor method.
802  
803 =head2 build_modify
804  
805 call build_modify method. Expects no params.
806  
807 $obj->build_modify()
808  
809 =head2 build_sub_no_arguments
810  
811 call build_sub_no_arguments method. Expects param $mg to be any value including undef, param $token to be any value including undef, param $meta to be any value including undef.
812  
813 $obj->build_sub_no_arguments($mg, $token, $meta)
814  
815 =head2 build_sub_code
816  
817 call build_sub_code method. Expects param $name to be a Str, param $params to be a Str, param $subtype to be a Str, param $code to be a Str.
818  
819 $obj->build_sub_code($name, $params, $subtype, $code)
820  
821 =head2 build_sub
822  
823 call build_sub method.
824  
825 =head2 build_clearer
826  
827 call build_clearer method. Expects param $mg to be a Object, param $name to be a Str, param $meta to be a HashRef.
828  
829 $obj->build_clearer($mg, $name, $meta)
830  
831 =head2 build_predicate
832  
833 call build_predicate method. Expects param $mg to be a Object, param $name to be a Str, param $meta to be a HashRef.
834  
835 $obj->build_predicate($mg, $name, $meta)
836  
837 =head2 build_coerce
838  
839 call build_coerce method. Expects param $name to be a Str, param $param to be a Str, param $code to be a Optional[Str].
840  
841 $obj->build_coerce($name, $param, $code)
842  
843 =head2 build_trigger
844  
845 call build_trigger method. Expects param $name to be a Str, param $param to be a Str, param $code to be a Optional[Str].
846  
847 $obj->build_trigger($name, $param, $code)
848  
849 =head2 build_tests
850  
851 call build_tests method. Expects param $name to be a Str, param $meta to be a HashRef, param $mod to be a Optional[Str], param $class to be a Optional[HashRef].
852  
853 $obj->build_tests($name, $meta, $mod, $class)
854  
855 =head1 ACCESSORS
856  
857 =head2 export
858  
859 get or set export.
860  
861 $obj->export;
862  
863 $obj->export($value);
864  
865 =head1 AUTHOR
866  
867 LNATION, C<< <email at lnation.org> >>
868  
869 =head1 BUGS
870  
871 Please report any bugs or feature requests to C<bug-hades::realm::exporter at rt.cpan.org>, or through
872 the web interface at L<https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Hades-Realm-Exporter>. I will be notified, and then you'll
873 automatically be notified of progress on your bug as I make changes.
874  
875 =head1 SUPPORT
876  
877 You can find documentation for this module with the perldoc command.
878  
879 perldoc Hades::Realm::Exporter
880  
881 You can also look for information at:
882  
883 =over 4
884  
885 =item * RT: CPAN's request tracker (report bugs here)
886  
887 L<https://rt.cpan.org/NoAuth/Bugs.html?Dist=Hades-Realm-Exporter>
888  
889 =item * AnnoCPAN: Annotated CPAN documentation
890  
891 L<http://annocpan.org/dist/Hades-Realm-Exporter>
892  
893 =item * CPAN Ratings
894  
895 L<https://cpanratings.perl.org/d/Hades-Realm-Exporter>
896  
897 =item * Search CPAN
898  
899 L<https://metacpan.org/release/Hades-Realm-Exporter>
900  
901 =back
902  
903 =head1 ACKNOWLEDGEMENTS
904  
905 =head1 LICENSE AND COPYRIGHT
906  
907 This software is Copyright (c) 2020 by LNATION.
908  
909 This is free software, licensed under:
910  
911 The Artistic License 2.0 (GPL Compatible)
912  
913 =cut
914  
915
↑ Summary