Hades/Macro/Dolos.pm

filter: Statementstmt 81.7% 233 / 285 Branchbran 61.7% 168 / 272 Conditioncond 63.6% 100 / 157 MC/DCmcdc 40.4% 38 / 94 Subroutinesub 100% 29 / 29 Podpod 100% 26 / 26 totaltotal 68.8% 594 / 863 CC 199 SCAR 28.4
CC
199
Cov
70%
delete
63.1
export
30.0
for_keys
14.5
CRAP 17.1
« Hades.pm ↑ Summary Hades/Macro/FH.pm »
1 package Hades::Macro::Dolos;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use base qw/Hades::Macro/;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 our $VERSION = 0.03;
6  
7 sub new {
8 32 ▶ my ( $cls, %args ) = ( shift(), scalar @_ == 1 ? %{ $_[0] } : @_ );
Subroutine new: called CC=7 SCAR=20.4
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
scalar @_ == 1 ? : 30 2 32
9 32 my $self = $cls->SUPER::new(%args);
10 30 my %accessors = (
11 macro => {
12 default => [
13 qw/
14 autoload_cb
15 caller
16 clear_unless_keys
17 call_sub
18 call_sub_my
19 delete
20 die_unless_keys
21 else
22 elsif
23 export
24 for
25 foreach
26 for_keys
27 for_key_exists_and_return
28 grep
29 grep_map
30 if
31 map
32 map_grep
33 maybe
34 merge_hash_refs
35 require
36 unless
37 while
38 /
39 ],
40 },
41 );
42 30 for my $accessor ( keys %accessors ) {
43 my $param
44 = defined $args{$accessor}
45 ? $args{$accessor}
46 30 ▶ : $accessors{$accessor}->{default};
Branch: 1 branch
BranchTrueFalseTotal
defined $args{$accessor} ? : 1 29 30
47 my $value
48 = $self->$accessor( $accessors{$accessor}->{builder}
49 30 ▶ ? $accessors{$accessor}->{builder}->( $self, $param )
Branch: 1 branch
BranchTrueFalseTotal
$accessors{$accessor}{'builder'} ? : 0 30 30
50 : $param );
51 30 ▶ unless ( !$accessors{$accessor}->{required} || defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (not $accessors{$accessor}{"required"} or defined $value) 0 30 30
Condition33%1/3
not $accessors{$accessor}{"required"} or defined $value
l!l&&r!l&&!r
3000
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
52 0 die "$accessor accessor is required";
53 }
54 }
55 30 return $self;
56 }
57  
58 sub macro {
59 67 ▶ my ( $self, $value ) = @_;
Subroutine macro: called CC=4 SCAR=13.9
Pod documented
60 67 ▶ if ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 65 2 67
61 65 ▶ if ( ( ref($value) || "" ) ne "ARRAY" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $value || "") ne "ARRAY") 4 61 65
Condition100%2/2
ref $value || ''
l!l
632
MC/DC100%1/1
ref $value || ''
ref $value
Truth table100%2/2
A
A= ref $value
Aresult
11
00
62 4 die qq{ArrayRef: invalid value $value for accessor macro};
63 }
64 61 $self->{macro} = $value;
65 }
66 63 return $self->{macro};
67 }
68  
69 sub autoload_cb {
70 4 ▶ my ( $self, $mg, $cb ) = @_;
Subroutine autoload_cb: called CC=7 SCAR=21.0
Pod documented
71 4 ▶ if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $mg || "") =~ /^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/) 2 2 4
Condition100%2/2
ref $mg || ''
l!l
31
MC/DC100%1/1
ref $mg || ''
ref $mg
Truth table100%2/2
A
A= ref $mg
Aresult
11
00
72 2 ▶ $mg = defined $mg ? $mg : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $mg ? : 2 0 2
73 2 die
74 qq{Object: invalid value $mg for variable \$mg in method autoload_cb};
75 }
76 2 ▶ if ( !defined($cb) || ref $cb ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $cb or ref $cb) 2 0 2
Condition33%1/3
not defined $cb or ref $cb
l!l&&r!l&&!r
020
MC/DC0%0/2
not defined $cb or ref $cb
not defined $cb ref $cb
Truth table33%1/3
not(A) or B
A= not defined $cbB= ref $cb
ABresult
1X1
011
000
77 2 ▶ $cb = defined $cb ? $cb : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $cb ? : 2 0 2
78 2 die
79 qq{Str: invalid value $cb for variable \$cb in method autoload_cb};
80 }
81  
82 0 return qq|
83 my (\$cls, \$vn) = (ref \$_[0], q{[^:'[:cntrl:]]{0,1024}});
84 our \$AUTOLOAD =~ /^\${cls}::(\$vn)\$/;
85 return ${cb}(\$1) if \$1;
86 |;
87  
88 }
89  
90 sub caller {
91 4 ▶ my ( $self, $mg, $variable ) = @_;
Subroutine caller: called CC=8 SCAR=22.6
Pod documented
92 4 ▶ if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $mg || "") =~ /^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/) 2 2 4
Condition100%2/2
ref $mg || ''
l!l
31
MC/DC100%1/1
ref $mg || ''
ref $mg
Truth table100%2/2
A
A= ref $mg
Aresult
11
00
93 2 ▶ $mg = defined $mg ? $mg : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $mg ? : 2 0 2
94 2 die qq{Object: invalid value $mg for variable \$mg in method caller};
95 }
96 2 ▶ $variable = defined $variable ? $variable : q|$caller|;
Branch: 1 branch
BranchTrueFalseTotal
defined $variable ? : 2 0 2
97 2 ▶ if ( !defined($variable) || ref $variable ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $variable or ref $variable) 2 0 2
Condition33%1/3
not defined $variable or ref $variable
l!l&&r!l&&!r
020
MC/DC0%0/2
not defined $variable or ref $variable
not defined $variable ref $variable
Truth table33%1/3
not(A) or B
A= not defined $variableB= ref $variable
ABresult
1X1
011
000
98 2 ▶ $variable = defined $variable ? $variable : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $variable ? : 2 0 2
99 2 die
100 qq{Str: invalid value $variable for variable \$variable in method caller};
101 }
102  
103 0 return qq|my $variable = caller();|;
104  
105 }
106  
107 sub clear_unless_keys {
108 6 ▶ my ( $self, $mg, $variable, $hash ) = @_;
Subroutine clear_unless_keys: called CC=10 SCAR=24.6
Pod documented
109 6 ▶ if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $mg || "") =~ /^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/) 2 4 6
Condition100%2/2
ref $mg || ''
l!l
51
MC/DC100%1/1
ref $mg || ''
ref $mg
Truth table100%2/2
A
A= ref $mg
Aresult
11
00
110 2 ▶ $mg = defined $mg ? $mg : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $mg ? : 2 0 2
111 2 die
112 qq{Object: invalid value $mg for variable \$mg in method clear_unless_keys};
113 }
114 4 ▶ if ( !defined($variable) || ref $variable ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $variable or ref $variable) 2 2 4
Condition66%2/3
not defined $variable or ref $variable
l!l&&r!l&&!r
022
MC/DC50%1/2
not defined $variable or ref $variable
not defined $variable ref $variable
Truth table66%2/3
not(A) or B
A= not defined $variableB= ref $variable
ABresult
1X1
011
000
115 2 ▶ $variable = defined $variable ? $variable : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $variable ? : 2 0 2
116 2 die
117 qq{Str: invalid value $variable for variable \$variable in method clear_unless_keys};
118 }
119 2 ▶ if ( !defined($hash) || ref $hash ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $hash or ref $hash) 2 0 2
Condition33%1/3
not defined $hash or ref $hash
l!l&&r!l&&!r
020
MC/DC0%0/2
not defined $hash or ref $hash
not defined $hash ref $hash
Truth table33%1/3
not(A) or B
A= not defined $hashB= ref $hash
ABresult
1X1
011
000
120 2 ▶ $hash = defined $hash ? $hash : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $hash ? : 2 0 2
121 2 die
122 qq{Str: invalid value $hash for variable \$hash in method clear_unless_keys};
123 }
124  
125 return
126 0 qq|$variable = undef if (! ref $hash \|\| ! scalar keys \%{$hash});|;
127  
128 }
129  
130 sub call_sub {
131 2 ▶ my ( $self, $mg, $sub, @params ) = @_;
Subroutine call_sub: called CC=4 SCAR=15.2
Pod documented
132 2 ▶ if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $mg || "") =~ /^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/) 2 0 2
Condition100%2/2
ref $mg || ''
l!l
11
MC/DC100%1/1
ref $mg || ''
ref $mg
Truth table100%2/2
A
A= ref $mg
Aresult
11
00
133 2 ▶ $mg = defined $mg ? $mg : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $mg ? : 2 0 2
134 2 die
135 qq{Object: invalid value $mg for variable \$mg in method call_sub};
136 }
137  
138 0 my $p = join ", ", @params;
139 0 return qq|${sub}($p);|;
140  
141 }
142  
143 sub call_sub_my {
144 4 ▶ my ( $self, $mg, $my, $sub, @params ) = @_;
Subroutine call_sub_my: called CC=7 SCAR=21.5
Pod documented
145 4 ▶ if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $mg || "") =~ /^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/) 2 2 4
Condition100%2/2
ref $mg || ''
l!l
31
MC/DC100%1/1
ref $mg || ''
ref $mg
Truth table100%2/2
A
A= ref $mg
Aresult
11
00
146 2 ▶ $mg = defined $mg ? $mg : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $mg ? : 2 0 2
147 2 die
148 qq{Object: invalid value $mg for variable \$mg in method call_sub_my};
149 }
150 2 ▶ if ( !defined($my) || ref $my ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $my or ref $my) 2 0 2
Condition33%1/3
not defined $my or ref $my
l!l&&r!l&&!r
020
MC/DC0%0/2
not defined $my or ref $my
not defined $my ref $my
Truth table33%1/3
not(A) or B
A= not defined $myB= ref $my
ABresult
1X1
011
000
151 2 ▶ $my = defined $my ? $my : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $my ? : 2 0 2
152 2 die
153 qq{Str: invalid value $my for variable \$my in method call_sub_my};
154 }
155  
156 0 my $p = join ", ", @params;
157 0 return qq|my (${my}) = ${sub}($p);|;
158  
159 }
160  
161 sub delete {
162 12 ▶ my ( $self, $mg, $hash, $key, $variable, $or, $list ) = @_;
Subroutine delete: called CC=24 SCAR=41.4
Pod documented
163 12 ▶ if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $mg || "") =~ /^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/) 2 10 12
Condition100%2/2
ref $mg || ''
l!l
111
MC/DC100%1/1
ref $mg || ''
ref $mg
Truth table100%2/2
A
A= ref $mg
Aresult
11
00
164 2 ▶ $mg = defined $mg ? $mg : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $mg ? : 2 0 2
165 2 die qq{Object: invalid value $mg for variable \$mg in method delete};
166 }
167 10 ▶ if ( !defined($hash) || ref $hash ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $hash or ref $hash) 2 8 10
Condition66%2/3
not defined $hash or ref $hash
l!l&&r!l&&!r
028
MC/DC50%1/2
not defined $hash or ref $hash
not defined $hash ref $hash
Truth table66%2/3
not(A) or B
A= not defined $hashB= ref $hash
ABresult
1X1
011
000
168 2 ▶ $hash = defined $hash ? $hash : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $hash ? : 2 0 2
169 2 die qq{Str: invalid value $hash for variable \$hash in method delete};
170 }
171 8 ▶ if ( !defined($key) || ref $key ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $key or ref $key) 2 6 8
Condition66%2/3
not defined $key or ref $key
l!l&&r!l&&!r
026
MC/DC50%1/2
not defined $key or ref $key
not defined $key ref $key
Truth table66%2/3
not(A) or B
A= not defined $keyB= ref $key
ABresult
1X1
011
000
172 2 ▶ $key = defined $key ? $key : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $key ? : 2 0 2
173 2 die qq{Str: invalid value $key for variable \$key in method delete};
174 }
175 6 ▶ if ( defined $variable ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $variable) 2 4 6
176 2 ▶ if ( ref $variable ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $variable) 2 0 2
177 2 die
178 qq{Optional[Str]: invalid value $variable for variable \$variable in method delete};
179 }
180 }
181 4 ▶ if ( defined $or ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $or) 2 2 4
182 2 ▶ if ( ref $or ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $or) 2 0 2
183 2 die
184 qq{Optional[Str]: invalid value $or for variable \$or in method delete};
185 }
186 }
187 2 ▶ if ( defined $list ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $list) 2 0 2
188 2 my $ref = ref $list;
189 2 ▶ if ( ( $ref || 'SCALAR' ) ne 'SCALAR'
Branch: 2 branches
BranchTrueFalseTotal
if (($ref || "SCALAR") ne "SCALAR" or not +($ref ? $$list : $list) =~ /^(1|0)$/) 2 0 2
$ref ? : 0 0 0
Condition40%2/5
($ref || "SCALAR") ne "SCALAR" or not +($ref ? $$list : $list) =~ /^(1|0)$/
l!l&&r!l&&!r
200
$ref || 'SCALAR'
l!l
20
MC/DC0%0/2
($ref || "SCALAR") ne "SCALAR" or not +($ref ? $$list : $list) =~ /^(1|0)$/
$ref not +($ref ? $$list : $list) =~ /^(1|0)$/
Truth table33%1/3
A or not(B)
A= $refB= not +($ref ? $$list : $list) =~ /^(1|0)$/
ABresult
1X1
011
000
190 || ( $ref ? $$list : $list ) !~ m/^(1|0)$/ )
191 {
192 2 die
193 qq{Optional[Bool]: invalid value $list for variable \$list in method delete};
194 }
195 0 ▶ $list = !!( $ref ? $$list : $list ) ? 1 : 0;
Branch: 2 branches
BranchTrueFalseTotal
!!($ref ? $$list : $list) ? : 0 0 0
$ref ? : 0 0 0
196 }
197  
198 0 my $code = q||;
199 0 ▶ $code .= qq|$variable = | if $variable;
Branch: 1 branch
BranchTrueFalseTotal
if $variable 0 0 0
200 0 $code .= qq|delete $hash\->{$key}|;
201 0 ▶ $code .= qq| \|\| $or| if $or;
Branch: 1 branch
BranchTrueFalseTotal
if $or 0 0 0
202 0 ▶ $code .= $list ? q|,| : qq|;|;
Branch: 1 branch
BranchTrueFalseTotal
$list ? : 0 0 0
203 0 return $code;
204  
205 }
206  
207 sub die_unless_keys {
208 6 ▶ my ( $self, $mg, $hash, $error ) = @_;
Subroutine die_unless_keys: called CC=11 SCAR=25.8
Pod documented
209 6 ▶ if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $mg || "") =~ /^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/) 2 4 6
Condition100%2/2
ref $mg || ''
l!l
51
MC/DC100%1/1
ref $mg || ''
ref $mg
Truth table100%2/2
A
A= ref $mg
Aresult
11
00
210 2 ▶ $mg = defined $mg ? $mg : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $mg ? : 2 0 2
211 2 die
212 qq{Object: invalid value $mg for variable \$mg in method die_unless_keys};
213 }
214 4 ▶ if ( !defined($hash) || ref $hash ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $hash or ref $hash) 2 2 4
Condition66%2/3
not defined $hash or ref $hash
l!l&&r!l&&!r
022
MC/DC50%1/2
not defined $hash or ref $hash
not defined $hash ref $hash
Truth table66%2/3
not(A) or B
A= not defined $hashB= ref $hash
ABresult
1X1
011
000
215 2 ▶ $hash = defined $hash ? $hash : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $hash ? : 2 0 2
216 2 die
217 qq{Str: invalid value $hash for variable \$hash in method die_unless_keys};
218 }
219 2 ▶ $error = defined $error ? $error : "hash is empty";
Branch: 1 branch
BranchTrueFalseTotal
defined $error ? : 2 0 2
220 2 ▶ if ( !defined($error) || ref $error ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $error or ref $error) 2 0 2
Condition33%1/3
not defined $error or ref $error
l!l&&r!l&&!r
020
MC/DC0%0/2
not defined $error or ref $error
not defined $error ref $error
Truth table33%1/3
not(A) or B
A= not defined $errorB= ref $error
ABresult
1X1
011
000
221 2 ▶ $error = defined $error ? $error : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $error ? : 2 0 2
222 2 die
223 qq{Str: invalid value $error for variable \$error in method die_unless_keys};
224 }
225  
226 0 return qq|die "$error" if (! ref $hash \|\| ! scalar keys \%{$hash});|;
227  
228 }
229  
230 sub else {
231 2 ▶ my ( $self, $mg, @code ) = @_;
Subroutine else: called CC=4 SCAR=15.2
Pod documented
232 2 ▶ if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $mg || "") =~ /^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/) 2 0 2
Condition100%2/2
ref $mg || ''
l!l
11
MC/DC100%1/1
ref $mg || ''
ref $mg
Truth table100%2/2
A
A= ref $mg
Aresult
11
00
233 2 ▶ $mg = defined $mg ? $mg : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $mg ? : 2 0 2
234 2 die qq{Object: invalid value $mg for variable \$mg in method else};
235 }
236  
237 0 my $c = join "\n", @code;
238 0 return qq|else { $c }|;
239  
240 }
241  
242 sub elsif {
243 4 ▶ my ( $self, $mg, $condition, @code ) = @_;
Subroutine elsif: called CC=7 SCAR=21.5
Pod documented
244 4 ▶ if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $mg || "") =~ /^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/) 2 2 4
Condition100%2/2
ref $mg || ''
l!l
31
MC/DC100%1/1
ref $mg || ''
ref $mg
Truth table100%2/2
A
A= ref $mg
Aresult
11
00
245 2 ▶ $mg = defined $mg ? $mg : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $mg ? : 2 0 2
246 2 die qq{Object: invalid value $mg for variable \$mg in method elsif};
247 }
248 2 ▶ if ( !defined($condition) || ref $condition ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $condition or ref $condition) 2 0 2
Condition33%1/3
not defined $condition or ref $condition
l!l&&r!l&&!r
020
MC/DC0%0/2
not defined $condition or ref $condition
not defined $condition ref $condition
Truth table33%1/3
not(A) or B
A= not defined $conditionB= ref $condition
ABresult
1X1
011
000
249 2 ▶ $condition = defined $condition ? $condition : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $condition ? : 2 0 2
250 2 die
251 qq{Str: invalid value $condition for variable \$condition in method elsif};
252 }
253  
254 0 my $c = join "\n", @code;
255 0 return qq|elsif ($condition) { $c }|;
256  
257 }
258  
259 sub export {
260 10 ▶ my ( $self, $mg, $method, $code, $no_warnings, $caller ) = @_;
Subroutine export: called CC=20 SCAR=34.0
Pod documented
261 10 ▶ if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $mg || "") =~ /^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/) 2 8 10
Condition100%2/2
ref $mg || ''
l!l
91
MC/DC100%1/1
ref $mg || ''
ref $mg
Truth table100%2/2
A
A= ref $mg
Aresult
11
00
262 2 ▶ $mg = defined $mg ? $mg : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $mg ? : 2 0 2
263 2 die qq{Object: invalid value $mg for variable \$mg in method export};
264 }
265 8 ▶ if ( !defined($method) || ref $method ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $method or ref $method) 2 6 8
Condition66%2/3
not defined $method or ref $method
l!l&&r!l&&!r
026
MC/DC50%1/2
not defined $method or ref $method
not defined $method ref $method
Truth table66%2/3
not(A) or B
A= not defined $methodB= ref $method
ABresult
1X1
011
000
266 2 ▶ $method = defined $method ? $method : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $method ? : 2 0 2
267 2 die
268 qq{Str: invalid value $method for variable \$method in method export};
269 }
270 6 ▶ if ( !defined($code) || ref $code ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $code or ref $code) 2 4 6
Condition66%2/3
not defined $code or ref $code
l!l&&r!l&&!r
024
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
271 2 ▶ $code = defined $code ? $code : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $code ? : 2 0 2
272 2 die qq{Str: invalid value $code for variable \$code in method export};
273 }
274 4 ▶ $no_warnings = defined $no_warnings ? $no_warnings : 1;
Branch: 1 branch
BranchTrueFalseTotal
defined $no_warnings ? : 4 0 4
275 4 ▶ if ( !defined($no_warnings)
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $no_warnings or ref $no_warnings or not $no_warnings =~ /^[-+\d]\d*$/) 2 2 4
Condition83%5/6
not defined $no_warnings or ref $no_warnings or not $no_warnings =~ /^[-+\d]\d*$/
l!l&&r!l&&!r
112
not defined $no_warnings or ref $no_warnings
l!l&&r!l&&!r
013
MC/DC66%2/3
not defined $no_warnings or ref $no_warnings or not $no_warnings =~ /^[-+\d]\d*$/
not defined $no_warnings ref $no_warnings not $no_warnings =~ /^[-+\d]\d*$/
Truth table75%3/4
not(A) or B or not(C)
A= not defined $no_warningsB= ref $no_warningsC= not $no_warnings =~ /^[-+\d]\d*$/
ABCresult
1XX1
01X1
0011
0000
276 || ref $no_warnings
277 || $no_warnings !~ m/^[-+\d]\d*$/ )
278 {
279 2 ▶ $no_warnings = defined $no_warnings ? $no_warnings : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $no_warnings ? : 2 0 2
280 2 die
281 qq{Int: invalid value $no_warnings for variable \$no_warnings in method export};
282 }
283 2 ▶ $caller = defined $caller ? $caller : '$caller';
Branch: 1 branch
BranchTrueFalseTotal
defined $caller ? : 2 0 2
284 2 ▶ if ( !defined($caller) || ref $caller ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $caller or ref $caller) 2 0 2
Condition33%1/3
not defined $caller or ref $caller
l!l&&r!l&&!r
020
MC/DC0%0/2
not defined $caller or ref $caller
not defined $caller ref $caller
Truth table33%1/3
not(A) or B
A= not defined $callerB= ref $caller
ABresult
1X1
011
000
285 2 ▶ $caller = defined $caller ? $caller : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $caller ? : 2 0 2
286 2 die
287 qq{Str: invalid value $caller for variable \$caller in method export};
288 }
289  
290 0 ▶ my $c
Branch: 1 branch
BranchTrueFalseTotal
$no_warnings ? : 0 0 0
291 = $no_warnings
292 ? qq|no strict "refs"; no warnings "redefine";|
293 : q||;
294 0 $caller =~ s/\$([^: ]+)/\${$1}/g;
295 0 $method =~ s/\$([^: ]+)/\${$1}/g;
296 0 return $c . qq|*{ "${caller}::${method}" } = sub { $code };|;
297  
298 }
299  
300 sub for {
301 4 ▶ my ( $self, $mg, $condition, @code ) = @_;
Subroutine for: called CC=7 SCAR=21.5
Pod documented
302 4 ▶ if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $mg || "") =~ /^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/) 2 2 4
Condition100%2/2
ref $mg || ''
l!l
31
MC/DC100%1/1
ref $mg || ''
ref $mg
Truth table100%2/2
A
A= ref $mg
Aresult
11
00
303 2 ▶ $mg = defined $mg ? $mg : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $mg ? : 2 0 2
304 2 die qq{Object: invalid value $mg for variable \$mg in method for};
305 }
306 2 ▶ if ( !defined($condition) || ref $condition ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $condition or ref $condition) 2 0 2
Condition33%1/3
not defined $condition or ref $condition
l!l&&r!l&&!r
020
MC/DC0%0/2
not defined $condition or ref $condition
not defined $condition ref $condition
Truth table33%1/3
not(A) or B
A= not defined $conditionB= ref $condition
ABresult
1X1
011
000
307 2 ▶ $condition = defined $condition ? $condition : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $condition ? : 2 0 2
308 2 die
309 qq{Str: invalid value $condition for variable \$condition in method for};
310 }
311  
312 0 my $c = join "\n", @code;
313 0 return qq|for ($condition) { $c }|;
314  
315 }
316  
317 sub foreach {
318 4 ▶ my ( $self, $mg, $condition, @code ) = @_;
Subroutine foreach: called CC=7 SCAR=21.5
Pod documented
319 4 ▶ if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $mg || "") =~ /^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/) 2 2 4
Condition100%2/2
ref $mg || ''
l!l
31
MC/DC100%1/1
ref $mg || ''
ref $mg
Truth table100%2/2
A
A= ref $mg
Aresult
11
00
320 2 ▶ $mg = defined $mg ? $mg : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $mg ? : 2 0 2
321 2 die qq{Object: invalid value $mg for variable \$mg in method foreach};
322 }
323 2 ▶ if ( !defined($condition) || ref $condition ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $condition or ref $condition) 2 0 2
Condition33%1/3
not defined $condition or ref $condition
l!l&&r!l&&!r
020
MC/DC0%0/2
not defined $condition or ref $condition
not defined $condition ref $condition
Truth table33%1/3
not(A) or B
A= not defined $conditionB= ref $condition
ABresult
1X1
011
000
324 2 ▶ $condition = defined $condition ? $condition : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $condition ? : 2 0 2
325 2 die
326 qq{Str: invalid value $condition for variable \$condition in method foreach};
327 }
328  
329 0 my $c = join "\n", @code;
330 0 return qq|foreach ($condition) { $c }|;
331  
332 }
333  
334 sub for_keys {
335 6 ▶ my ( $self, $mg, $hash, $key, @code ) = @_;
Subroutine for_keys: called CC=11 SCAR=26.7
Pod documented
336 6 ▶ if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $mg || "") =~ /^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/) 2 4 6
Condition100%2/2
ref $mg || ''
l!l
51
MC/DC100%1/1
ref $mg || ''
ref $mg
Truth table100%2/2
A
A= ref $mg
Aresult
11
00
337 2 ▶ $mg = defined $mg ? $mg : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $mg ? : 2 0 2
338 2 die
339 qq{Object: invalid value $mg for variable \$mg in method for_keys};
340 }
341 4 ▶ if ( !defined($hash) || ref $hash ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $hash or ref $hash) 2 2 4
Condition66%2/3
not defined $hash or ref $hash
l!l&&r!l&&!r
022
MC/DC50%1/2
not defined $hash or ref $hash
not defined $hash ref $hash
Truth table66%2/3
not(A) or B
A= not defined $hashB= ref $hash
ABresult
1X1
011
000
342 2 ▶ $hash = defined $hash ? $hash : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $hash ? : 2 0 2
343 2 die
344 qq{Str: invalid value $hash for variable \$hash in method for_keys};
345 }
346 2 ▶ $key = defined $key ? $key : $key;
Branch: 1 branch
BranchTrueFalseTotal
defined $key ? : 2 0 2
347 2 ▶ if ( !defined($key) || ref $key ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $key or ref $key) 2 0 2
Condition33%1/3
not defined $key or ref $key
l!l&&r!l&&!r
020
MC/DC0%0/2
not defined $key or ref $key
not defined $key ref $key
Truth table33%1/3
not(A) or B
A= not defined $keyB= ref $key
ABresult
1X1
011
000
348 2 ▶ $key = defined $key ? $key : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $key ? : 2 0 2
349 2 die qq{Str: invalid value $key for variable \$key in method for_keys};
350 }
351  
352 0 $hash =~ s/^\$([^\(\{\-\:\ ]+)$/\%{\$$1}/;
353 0 my $c = join "\n", @code;
354 0 return qq|for my $key (keys $hash) { $c }|;
355  
356 }
357  
358 sub for_key_exists_and_return {
359 6 ▶ my ( $self, $mg, $hash, $for ) = @_;
Subroutine for_key_exists_and_return: called CC=10 SCAR=24.6
Pod documented
360 6 ▶ if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $mg || "") =~ /^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/) 2 4 6
Condition100%2/2
ref $mg || ''
l!l
51
MC/DC100%1/1
ref $mg || ''
ref $mg
Truth table100%2/2
A
A= ref $mg
Aresult
11
00
361 2 ▶ $mg = defined $mg ? $mg : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $mg ? : 2 0 2
362 2 die
363 qq{Object: invalid value $mg for variable \$mg in method for_key_exists_and_return};
364 }
365 4 ▶ if ( !defined($hash) || ref $hash ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $hash or ref $hash) 2 2 4
Condition66%2/3
not defined $hash or ref $hash
l!l&&r!l&&!r
022
MC/DC50%1/2
not defined $hash or ref $hash
not defined $hash ref $hash
Truth table66%2/3
not(A) or B
A= not defined $hashB= ref $hash
ABresult
1X1
011
000
366 2 ▶ $hash = defined $hash ? $hash : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $hash ? : 2 0 2
367 2 die
368 qq{Str: invalid value $hash for variable \$hash in method for_key_exists_and_return};
369 }
370 2 ▶ if ( !defined($for) || ref $for ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $for or ref $for) 2 0 2
Condition33%1/3
not defined $for or ref $for
l!l&&r!l&&!r
020
MC/DC0%0/2
not defined $for or ref $for
not defined $for ref $for
Truth table33%1/3
not(A) or B
A= not defined $forB= ref $for
ABresult
1X1
011
000
371 2 ▶ $for = defined $for ? $for : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $for ? : 2 0 2
372 2 die
373 qq{Str: invalid value $for for variable \$for in method for_key_exists_and_return};
374 }
375  
376 0 return qq|\$_ && exists ${hash}->{\$_} and return ${hash}->{\$_}
377 for ($for);|;
378  
379 }
380  
381 sub grep {
382 4 ▶ my ( $self, $mg, $condition, @code ) = @_;
Subroutine grep: called CC=7 SCAR=21.5
Pod documented
383 4 ▶ if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $mg || "") =~ /^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/) 2 2 4
Condition100%2/2
ref $mg || ''
l!l
31
MC/DC100%1/1
ref $mg || ''
ref $mg
Truth table100%2/2
A
A= ref $mg
Aresult
11
00
384 2 ▶ $mg = defined $mg ? $mg : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $mg ? : 2 0 2
385 2 die qq{Object: invalid value $mg for variable \$mg in method grep};
386 }
387 2 ▶ if ( !defined($condition) || ref $condition ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $condition or ref $condition) 2 0 2
Condition33%1/3
not defined $condition or ref $condition
l!l&&r!l&&!r
020
MC/DC0%0/2
not defined $condition or ref $condition
not defined $condition ref $condition
Truth table33%1/3
not(A) or B
A= not defined $conditionB= ref $condition
ABresult
1X1
011
000
388 2 ▶ $condition = defined $condition ? $condition : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $condition ? : 2 0 2
389 2 die
390 qq{Str: invalid value $condition for variable \$condition in method grep};
391 }
392  
393 0 my $c = join "\n", @code;
394 0 return qq|grep { $c } $condition|;
395  
396 }
397  
398 sub grep_map {
399 6 ▶ my ( $self, $mg, $condition, $grep_code, @map_code ) = @_;
Subroutine grep_map: called CC=10 SCAR=25.0
Pod documented
400 6 ▶ if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $mg || "") =~ /^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/) 2 4 6
Condition100%2/2
ref $mg || ''
l!l
51
MC/DC100%1/1
ref $mg || ''
ref $mg
Truth table100%2/2
A
A= ref $mg
Aresult
11
00
401 2 ▶ $mg = defined $mg ? $mg : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $mg ? : 2 0 2
402 2 die
403 qq{Object: invalid value $mg for variable \$mg in method grep_map};
404 }
405 4 ▶ if ( !defined($condition) || ref $condition ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $condition or ref $condition) 2 2 4
Condition66%2/3
not defined $condition or ref $condition
l!l&&r!l&&!r
022
MC/DC50%1/2
not defined $condition or ref $condition
not defined $condition ref $condition
Truth table66%2/3
not(A) or B
A= not defined $conditionB= ref $condition
ABresult
1X1
011
000
406 2 ▶ $condition = defined $condition ? $condition : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $condition ? : 2 0 2
407 2 die
408 qq{Str: invalid value $condition for variable \$condition in method grep_map};
409 }
410 2 ▶ if ( !defined($grep_code) || ref $grep_code ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $grep_code or ref $grep_code) 2 0 2
Condition33%1/3
not defined $grep_code or ref $grep_code
l!l&&r!l&&!r
020
MC/DC0%0/2
not defined $grep_code or ref $grep_code
not defined $grep_code ref $grep_code
Truth table33%1/3
not(A) or B
A= not defined $grep_codeB= ref $grep_code
ABresult
1X1
011
000
411 2 ▶ $grep_code = defined $grep_code ? $grep_code : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $grep_code ? : 2 0 2
412 2 die
413 qq{Str: invalid value $grep_code for variable \$grep_code in method grep_map};
414 }
415  
416 0 my $mc = join "\n", @map_code;
417 0 return qq|map { $mc } grep { $grep_code } $condition|;
418  
419 }
420  
421 sub if {
422 4 ▶ my ( $self, $mg, $condition, @code ) = @_;
Subroutine if: called CC=7 SCAR=21.5
Pod documented
423 4 ▶ if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $mg || "") =~ /^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/) 2 2 4
Condition100%2/2
ref $mg || ''
l!l
31
MC/DC100%1/1
ref $mg || ''
ref $mg
Truth table100%2/2
A
A= ref $mg
Aresult
11
00
424 2 ▶ $mg = defined $mg ? $mg : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $mg ? : 2 0 2
425 2 die qq{Object: invalid value $mg for variable \$mg in method if};
426 }
427 2 ▶ if ( !defined($condition) || ref $condition ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $condition or ref $condition) 2 0 2
Condition33%1/3
not defined $condition or ref $condition
l!l&&r!l&&!r
020
MC/DC0%0/2
not defined $condition or ref $condition
not defined $condition ref $condition
Truth table33%1/3
not(A) or B
A= not defined $conditionB= ref $condition
ABresult
1X1
011
000
428 2 ▶ $condition = defined $condition ? $condition : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $condition ? : 2 0 2
429 2 die
430 qq{Str: invalid value $condition for variable \$condition in method if};
431 }
432  
433 0 my $c = join "\n", @code;
434 0 return qq|if ($condition) { $c }|;
435  
436 }
437  
438 sub map {
439 4 ▶ my ( $self, $mg, $condition, @code ) = @_;
Subroutine map: called CC=7 SCAR=21.5
Pod documented
440 4 ▶ if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $mg || "") =~ /^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/) 2 2 4
Condition100%2/2
ref $mg || ''
l!l
31
MC/DC100%1/1
ref $mg || ''
ref $mg
Truth table100%2/2
A
A= ref $mg
Aresult
11
00
441 2 ▶ $mg = defined $mg ? $mg : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $mg ? : 2 0 2
442 2 die qq{Object: invalid value $mg for variable \$mg in method map};
443 }
444 2 ▶ if ( !defined($condition) || ref $condition ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $condition or ref $condition) 2 0 2
Condition33%1/3
not defined $condition or ref $condition
l!l&&r!l&&!r
020
MC/DC0%0/2
not defined $condition or ref $condition
not defined $condition ref $condition
Truth table33%1/3
not(A) or B
A= not defined $conditionB= ref $condition
ABresult
1X1
011
000
445 2 ▶ $condition = defined $condition ? $condition : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $condition ? : 2 0 2
446 2 die
447 qq{Str: invalid value $condition for variable \$condition in method map};
448 }
449  
450 0 my $c = join "\n", @code;
451 0 return qq|map { $c } $condition|;
452  
453 }
454  
455 sub map_grep {
456 6 ▶ my ( $self, $mg, $condition, $grep_code, @map_code ) = @_;
Subroutine map_grep: called CC=10 SCAR=25.0
Pod documented
457 6 ▶ if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $mg || "") =~ /^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/) 2 4 6
Condition100%2/2
ref $mg || ''
l!l
51
MC/DC100%1/1
ref $mg || ''
ref $mg
Truth table100%2/2
A
A= ref $mg
Aresult
11
00
458 2 ▶ $mg = defined $mg ? $mg : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $mg ? : 2 0 2
459 2 die
460 qq{Object: invalid value $mg for variable \$mg in method map_grep};
461 }
462 4 ▶ if ( !defined($condition) || ref $condition ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $condition or ref $condition) 2 2 4
Condition66%2/3
not defined $condition or ref $condition
l!l&&r!l&&!r
022
MC/DC50%1/2
not defined $condition or ref $condition
not defined $condition ref $condition
Truth table66%2/3
not(A) or B
A= not defined $conditionB= ref $condition
ABresult
1X1
011
000
463 2 ▶ $condition = defined $condition ? $condition : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $condition ? : 2 0 2
464 2 die
465 qq{Str: invalid value $condition for variable \$condition in method map_grep};
466 }
467 2 ▶ if ( !defined($grep_code) || ref $grep_code ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $grep_code or ref $grep_code) 2 0 2
Condition33%1/3
not defined $grep_code or ref $grep_code
l!l&&r!l&&!r
020
MC/DC0%0/2
not defined $grep_code or ref $grep_code
not defined $grep_code ref $grep_code
Truth table33%1/3
not(A) or B
A= not defined $grep_codeB= ref $grep_code
ABresult
1X1
011
000
468 2 ▶ $grep_code = defined $grep_code ? $grep_code : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $grep_code ? : 2 0 2
469 2 die
470 qq{Str: invalid value $grep_code for variable \$grep_code in method map_grep};
471 }
472  
473 0 my $mc = join "\n", @map_code;
474 0 return qq|grep { $grep_code } map { $mc } $condition|;
475  
476 }
477  
478 sub maybe {
479 6 ▶ my ( $self, $mg, $key, $variable ) = @_;
Subroutine maybe: called CC=10 SCAR=24.6
Pod documented
480 6 ▶ if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $mg || "") =~ /^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/) 2 4 6
Condition100%2/2
ref $mg || ''
l!l
51
MC/DC100%1/1
ref $mg || ''
ref $mg
Truth table100%2/2
A
A= ref $mg
Aresult
11
00
481 2 ▶ $mg = defined $mg ? $mg : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $mg ? : 2 0 2
482 2 die qq{Object: invalid value $mg for variable \$mg in method maybe};
483 }
484 4 ▶ if ( !defined($key) || ref $key ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $key or ref $key) 2 2 4
Condition66%2/3
not defined $key or ref $key
l!l&&r!l&&!r
022
MC/DC50%1/2
not defined $key or ref $key
not defined $key ref $key
Truth table66%2/3
not(A) or B
A= not defined $keyB= ref $key
ABresult
1X1
011
000
485 2 ▶ $key = defined $key ? $key : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $key ? : 2 0 2
486 2 die qq{Str: invalid value $key for variable \$key in method maybe};
487 }
488 2 ▶ if ( !defined($variable) || ref $variable ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $variable or ref $variable) 2 0 2
Condition33%1/3
not defined $variable or ref $variable
l!l&&r!l&&!r
020
MC/DC0%0/2
not defined $variable or ref $variable
not defined $variable ref $variable
Truth table33%1/3
not(A) or B
A= not defined $variableB= ref $variable
ABresult
1X1
011
000
489 2 ▶ $variable = defined $variable ? $variable : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $variable ? : 2 0 2
490 2 die
491 qq{Str: invalid value $variable for variable \$variable in method maybe};
492 }
493  
494 0 return qq|(defined $variable ? ( $key => $variable ) : ())|;
495  
496 }
497  
498 sub merge_hash_refs {
499 2 ▶ my ( $self, $mg, @hashes ) = @_;
Subroutine merge_hash_refs: called CC=4 SCAR=16.6
Pod documented
500 2 ▶ if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $mg || "") =~ /^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/) 2 0 2
Condition100%2/2
ref $mg || ''
l!l
11
MC/DC100%1/1
ref $mg || ''
ref $mg
Truth table100%2/2
A
A= ref $mg
Aresult
11
00
501 2 ▶ $mg = defined $mg ? $mg : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $mg ? : 2 0 2
502 2 die
503 qq{Object: invalid value $mg for variable \$mg in method merge_hash_refs};
504 }
505  
506 0 my $base = $hashes[0];
507 0 my $merge = join ', ', map { '%{' . $_ . '}' } @hashes;
508 0 return qq|$base = { $merge };|;
509  
510 }
511  
512 sub require {
513 4 ▶ my ( $self, $mg, $variable ) = @_;
Subroutine require: called CC=7 SCAR=21.0
Pod documented
514 4 ▶ if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $mg || "") =~ /^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/) 2 2 4
Condition100%2/2
ref $mg || ''
l!l
31
MC/DC100%1/1
ref $mg || ''
ref $mg
Truth table100%2/2
A
A= ref $mg
Aresult
11
00
515 2 ▶ $mg = defined $mg ? $mg : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $mg ? : 2 0 2
516 2 die qq{Object: invalid value $mg for variable \$mg in method require};
517 }
518 2 ▶ if ( !defined($variable) || ref $variable ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $variable or ref $variable) 2 0 2
Condition33%1/3
not defined $variable or ref $variable
l!l&&r!l&&!r
020
MC/DC0%0/2
not defined $variable or ref $variable
not defined $variable ref $variable
Truth table33%1/3
not(A) or B
A= not defined $variableB= ref $variable
ABresult
1X1
011
000
519 2 ▶ $variable = defined $variable ? $variable : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $variable ? : 2 0 2
520 2 die
521 qq{Str: invalid value $variable for variable \$variable in method require};
522 }
523  
524 0 return qq|eval "require ${variable}";|;
525  
526 }
527  
528 sub unless {
529 4 ▶ my ( $self, $mg, $condition, @code ) = @_;
Subroutine unless: called CC=7 SCAR=21.5
Pod documented
530 4 ▶ if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $mg || "") =~ /^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/) 2 2 4
Condition100%2/2
ref $mg || ''
l!l
31
MC/DC100%1/1
ref $mg || ''
ref $mg
Truth table100%2/2
A
A= ref $mg
Aresult
11
00
531 2 ▶ $mg = defined $mg ? $mg : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $mg ? : 2 0 2
532 2 die qq{Object: invalid value $mg for variable \$mg in method unless};
533 }
534 2 ▶ if ( !defined($condition) || ref $condition ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $condition or ref $condition) 2 0 2
Condition33%1/3
not defined $condition or ref $condition
l!l&&r!l&&!r
020
MC/DC0%0/2
not defined $condition or ref $condition
not defined $condition ref $condition
Truth table33%1/3
not(A) or B
A= not defined $conditionB= ref $condition
ABresult
1X1
011
000
535 2 ▶ $condition = defined $condition ? $condition : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $condition ? : 2 0 2
536 2 die
537 qq{Str: invalid value $condition for variable \$condition in method unless};
538 }
539  
540 0 my $c = join "\n", @code;
541 0 return qq|unless ($condition) { $c }|;
542  
543 }
544  
545 sub while {
546 4 ▶ my ( $self, $mg, $condition, @code ) = @_;
Subroutine while: called CC=7 SCAR=21.5
Pod documented
547 4 ▶ if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $mg || "") =~ /^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/) 2 2 4
Condition100%2/2
ref $mg || ''
l!l
31
MC/DC100%1/1
ref $mg || ''
ref $mg
Truth table100%2/2
A
A= ref $mg
Aresult
11
00
548 2 ▶ $mg = defined $mg ? $mg : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $mg ? : 2 0 2
549 2 die qq{Object: invalid value $mg for variable \$mg in method while};
550 }
551 2 ▶ if ( !defined($condition) || ref $condition ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $condition or ref $condition) 2 0 2
Condition33%1/3
not defined $condition or ref $condition
l!l&&r!l&&!r
020
MC/DC0%0/2
not defined $condition or ref $condition
not defined $condition ref $condition
Truth table33%1/3
not(A) or B
A= not defined $conditionB= ref $condition
ABresult
1X1
011
000
552 2 ▶ $condition = defined $condition ? $condition : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $condition ? : 2 0 2
553 2 die
554 qq{Str: invalid value $condition for variable \$condition in method while};
555 }
556  
557 0 my $c = join "\n", @code;
558 0 return qq|while ($condition) { $c }|;
559  
560 }
561  
562 1 1;
563  
564 __END__
565  
566 =head1 NAME
567  
568 Hades::Macro::Dolos - Hades macro helpers for Dolos
569  
570 =head1 VERSION
571  
572 Version 0.01
573  
574 =cut
575  
576 =head1 SYNOPSIS
577  
578 Quick summary of what the module does:
579  
580 Hades->run({
581 eval => q|
582 macro {
583 Dolos
584 }
585 Kosmos {
586 psyche $dolos :t(Int) $eros :t(HashRef) $psyche :t(HashRef) {
587 €if($dolos,€if($dolos > 10, return $eros;);, €elsif($dolos > 5, €merge_hash_refs($eros, $psyche););,
588 €else(return $psyche;););
589 return undef;
590 }
591 }
592 |;
593 });
594  
595 =head1 SUBROUTINES/METHODS
596  
597 =head2 new
598  
599 Instantiate a new Hades::Macro::Dolos object.
600  
601 Hades::Macro::Dolos->new
602  
603 =head2 autoload_cb
604  
605 call autoload_cb method. Expects param $mg to be a Object, param $cb to be a Str.
606  
607 $obj->autoload_cb($mg, $cb)
608  
609 =head2 caller
610  
611 call caller method. Expects param $mg to be a Object, param $variable to be a Str.
612  
613 $obj->caller($mg, $variable)
614  
615 =head2 clear_unless_keys
616  
617 call clear_unless_keys method. Expects param $mg to be a Object, param $variable to be a Str, param $hash to be a Str.
618  
619 $obj->clear_unless_keys($mg, $variable, $hash)
620  
621 =head2 call_sub
622  
623 call call_sub method. Expects param $mg to be a Object, param $sub to be any value including undef, param @params to be any value including undef.
624  
625 $obj->call_sub($mg, $sub, @params)
626  
627 =head2 call_sub_my
628  
629 call call_sub_my method. Expects param $mg to be a Object, param $my to be a Str, param $sub to be any value including undef, param @params to be any value including undef.
630  
631 $obj->call_sub_my($mg, $my, $sub, @params)
632  
633 =head2 delete
634  
635 call delete method. Expects param $mg to be a Object, param $hash to be a Str, param $key to be a Str, param $variable to be a Optional[Str], param $or to be a Optional[Str], param $list to be a Optional[Bool].
636  
637 $obj->delete($mg, $hash, $key, $variable, $or, $list)
638  
639 =head2 die_unless_keys
640  
641 call die_unless_keys method. Expects param $mg to be a Object, param $hash to be a Str, param $error to be a Str.
642  
643 $obj->die_unless_keys($mg, $hash, $error)
644  
645 =head2 else
646  
647 call else method. Expects param $mg to be a Object, param @code to be any value including undef.
648  
649 $obj->else($mg, @code)
650  
651 =head2 elsif
652  
653 call elsif method. Expects param $mg to be a Object, param $condition to be a Str, param @code to be any value including undef.
654  
655 $obj->elsif($mg, $condition, @code)
656  
657 =head2 export
658  
659 call export method. Expects param $mg to be a Object, param $method to be a Str, param $code to be a Str, param $no_warnings to be a Int, param $caller to be a Str.
660  
661 $obj->export($mg, $method, $code, $no_warnings, $caller)
662  
663 =head2 for
664  
665 call for method. Expects param $mg to be a Object, param $condition to be a Str, param @code to be any value including undef.
666  
667 $obj->for($mg, $condition, @code)
668  
669 =head2 foreach
670  
671 call foreach method. Expects param $mg to be a Object, param $condition to be a Str, param @code to be any value including undef.
672  
673 $obj->foreach($mg, $condition, @code)
674  
675 =head2 for_keys
676  
677 call for_keys method. Expects param $mg to be a Object, param $hash to be a Str, param $key to be a Str, param @code to be any value including undef.
678  
679 $obj->for_keys($mg, $hash, $key, @code)
680  
681 =head2 for_key_exists_and_return
682  
683 call for_key_exists_and_return method. Expects param $mg to be a Object, param $hash to be a Str, param $for to be a Str.
684  
685 $obj->for_key_exists_and_return($mg, $hash, $for)
686  
687 =head2 grep
688  
689 call grep method. Expects param $mg to be a Object, param $condition to be a Str, param @code to be any value including undef.
690  
691 $obj->grep($mg, $condition, @code)
692  
693 =head2 grep_map
694  
695 call grep_map method. Expects param $mg to be a Object, param $condition to be a Str, param $grep_code to be a Str, param @map_code to be any value including undef.
696  
697 $obj->grep_map($mg, $condition, $grep_code, @map_code)
698  
699 =head2 if
700  
701 call if method. Expects param $mg to be a Object, param $condition to be a Str, param @code to be any value including undef.
702  
703 $obj->if($mg, $condition, @code)
704  
705 =head2 map
706  
707 call map method. Expects param $mg to be a Object, param $condition to be a Str, param @code to be any value including undef.
708  
709 $obj->map($mg, $condition, @code)
710  
711 =head2 map_grep
712  
713 call map_grep method. Expects param $mg to be a Object, param $condition to be a Str, param $grep_code to be a Str, param @map_code to be any value including undef.
714  
715 $obj->map_grep($mg, $condition, $grep_code, @map_code)
716  
717 =head2 maybe
718  
719 call maybe method. Expects param $mg to be a Object, param $key to be a Str, param $variable to be a Str.
720  
721 $obj->maybe($mg, $key, $variable)
722  
723 =head2 merge_hash_refs
724  
725 call merge_hash_refs method. Expects param $mg to be a Object, param @hashes to be any value including undef.
726  
727 $obj->merge_hash_refs($mg, @hashes)
728  
729 =head2 require
730  
731 call require method. Expects param $mg to be a Object, param $variable to be a Str.
732  
733 $obj->require($mg, $variable)
734  
735 =head2 unless
736  
737 call unless method. Expects param $mg to be a Object, param $condition to be a Str, param @code to be any value including undef.
738  
739 $obj->unless($mg, $condition, @code)
740  
741 =head2 while
742  
743 call while method. Expects param $mg to be a Object, param $condition to be a Str, param @code to be any value including undef.
744  
745 $obj->while($mg, $condition, @code)
746  
747 =head1 ACCESSORS
748  
749 =head2 macro
750  
751 get or set macro.
752  
753 $obj->macro;
754  
755 $obj->macro($value);
756  
757 =head1 AUTHOR
758  
759 LNATION, C<< <email at lnation.org> >>
760  
761 =head1 BUGS
762  
763 Please report any bugs or feature requests to C<bug-hades::macro::dolos at rt.cpan.org>, or through
764 the web interface at L<https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Hades-Macro-Dolos>. I will be notified, and then you'll
765 automatically be notified of progress on your bug as I make changes.
766  
767 =head1 SUPPORT
768  
769 You can find documentation for this module with the perldoc command.
770  
771 perldoc Hades::Macro::Dolos
772  
773 You can also look for information at:
774  
775 =over 4
776  
777 =item * RT: CPAN's request tracker (report bugs here)
778  
779 L<https://rt.cpan.org/NoAuth/Bugs.html?Dist=Hades-Macro-Dolos>
780  
781 =item * AnnoCPAN: Annotated CPAN documentation
782  
783 L<http://annocpan.org/dist/Hades-Macro-Dolos>
784  
785 =item * CPAN Ratings
786  
787 L<https://cpanratings.perl.org/d/Hades-Macro-Dolos>
788  
789 =item * Search CPAN
790  
791 L<https://metacpan.org/release/Hades-Macro-Dolos>
792  
793 =back
794  
795 =head1 ACKNOWLEDGEMENTS
796  
797 =head1 LICENSE AND COPYRIGHT
798  
799 This software is Copyright (c) 2020 by LNATION.
800  
801 This is free software, licensed under:
802  
803 The Artistic License 2.0 (GPL Compatible)
804  
805 =cut
806  
807
« Hades.pm ↑ Summary Hades/Macro/FH.pm »