blib/lib/Hades/Realm/Exporter.pm

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