blib/lib/Z.pm

filter: Statementstmt 52.9% 63 / 119 Branchbran 13.0% 6 / 46 Conditioncond 18.7% 3 / 16 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 46.6% 14 / 30 Podpod 0.0% 0 / 3 totaltotal 38.3% 86 / 224 CC 33 SCAR 28.2
CC
33
Cov
40%
also
66.8
__ANON__
20.0
__ANON__
12.0
CRAP 16.8
↑ Summary
1 1 ▶use 5.008008;
Subroutine BEGIN: called CC=1 SCAR=0.0
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  
5 package Z;
6  
7 1 our $AUTHORITY = 'cpan:TOBYINK';
8 1 our $VERSION = '0.008';
9  
10 1 ▶use Import::Into ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use IO::Handle ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Module::Runtime qw( use_module );
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Zydeco::Lite qw( true false );
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=7.6
16 1 ▶ *PERL_IS_MODERN = ( $] ge '5.014' ) ? \&true : \&false;
Branch: 1 branch
BranchTrueFalseTotal
$] ge '5.014' ? : 1 0 1
17 }
18  
19 1 my $STRICT = 0;
20 1 ▶$ENV{$_} && ++$STRICT && last for qw(
Branch: 1 branch
BranchTrueFalseTotal
$ENV{$_} and ++$STRICT and last 1 0 1
Condition33%1/3
$ENV{$_} and ++$STRICT
!ll&&!rl&&r
001
MC/DC0%0/2
$ENV{$_} and ++$STRICT
$ENV{$_} ++$STRICT
Truth table33%1/3
A and B
A= $ENV{$_}B= ++$STRICT
ABresult
0X0
100
111
21 EXTENDED_TESTING
22 AUTHOR_TESTING
23 RELEASE_TESTING
24 PERL_STRICT
25 );
26  
27 1 ▶sub import {
Subroutine import: called CC=7 SCAR=20.8
28 1 my ( $target, $class ) = ( scalar caller, shift );
29
30 1 my $mode = '-modern';
31 1 ▶ ( $_[0] || '' ) =~ /^-/ and $mode = shift;
Branch: 1 branch
BranchTrueFalseTotal
($_[0] || "") =~ /^-/ and $mode = shift() 1 0 1
Condition50%1/2
$_[0] || ''
l!l
10
MC/DC0%0/1
$_[0] || ''
$_[0]
Truth table50%1/2
A
A= $_[0]
Aresult
11
00
32
33 1 my $collection = 'modules';
34
35 1 if ( PERL_IS_MODERN ) {
36 1 ▶ $collection = 'compat_modules' if $mode eq '-compat';
Branch: 1 branch
BranchTrueFalseTotal
if $mode eq "-compat" 1 0 1
37 }
38 else {
39 $collection = 'compat_modules';
40
41 if ( $mode eq '-modern' ) {
42 require Carp;
43 return Carp::croak( "$target requires Perl v5.14 or above; stopping" );
44 }
45 elsif ( $mode eq '-detect' ) {
46 require Carp;
47 Carp::carp(
48 "$target may require Perl v5.14 or above; attempting compatibility mode" );
49 }
50 } #/ else [ if ( PERL_IS_MODERN ) ]
51
52 1 for my $modules ( $class->$collection ) {
53 12 my ( $name, $version, @args ) = @$modules;
54 12 use_module( $name, $version )->import::into( $target, @args );
55 }
56
57 eval {
58 1 require indirect;
59 1 'indirect'->unimport::out_of( $target );
60 1 1;
61 }
62 or !$STRICT
63 1 ▶ or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { require indirect; "indirect"->unimport::out_of($target); 1 } } or not $STRICT or do { require Carp; Carp::carp("Could not load indirect.pm") } 1 0 1
Condition33%1/3
eval { do { require indirect; "indirect"->unimport::out_of($target); 1 } } or not $STRICT
l!l&&r!l&&!r
100
MC/DC0%0/2
eval { do { require indirect; "indirect"->unimport::out_of($target); 1 } } or not $STRICT
eval { do { require indirect; "indirect"->unimport::out_of($target); 1 } } not $STRICT
Truth table33%1/3
A or not(B)
A= eval { do { require indirect; "indirect"->unimport::out_of($target); 1 } }B= not $STRICT
ABresult
1X1
011
000
64 0 require Carp;
65 0 Carp::carp( "Could not load indirect.pm" );
66 };
67
68 1 $class->also( $target, @_ );
69
70 1 use_module( 'namespace::autoclean' )->import::into( $target );
71
72 1 return $class;
73 } #/ sub import
74  
75 1 ▶sub modules {
Subroutine modules: called CC=1 SCAR=0.0
Pod undocumented
76 1 my $class = shift;
77
78 return (
79 1 [ 'Syntax::Keyword::Try', '0.018', qw( try ) ],
80 [ 'Zydeco::Lite', '0.070', qw( -all ) ],
81 [ 'Types::Standard', '1.010000', qw( -types -is -assert ) ],
82 [ 'Types::Common::Numeric', '1.010000', qw( -types -is -assert ) ],
83 [ 'Types::Common::String', '1.010000', qw( -types -is -assert ) ],
84 [ 'Types::Path::Tiny', '0', qw( -types -is -assert ) ],
85 [ 'Object::Adhoc', '0.003', qw( object ) ],
86 [ 'Path::Tiny', '0.101', qw( path ) ],
87 [ 'match::simple', '0.010', qw( match ) ],
88 [ 'strict', '0', qw( refs subs vars ) ],
89 [ 'warnings', '0', qw( all ) ],
90 [ 'feature', '0', qw( say state ) ],
91 );
92 } #/ sub modules
93  
94 1 ▶sub compat_modules {
Subroutine compat_modules: called CC=2 SCAR=7.2
Pod undocumented
95 1 my $class = shift;
96
97 my @modules =
98 1 grep { my $name = $_->[0]; $name !~ /feature|Try/ } $class->modules;
99
100 1 push @modules, [ 'Try::Tiny', '0.30' ];
101
102 1 ▶ if ( $] ge '5.010' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($] ge '5.010') { } 1 0 1
103 1 push @modules, [ 'feature', '0', qw( say ) ];
104 }
105 else {
106 0 push @modules, [ 'Perl6::Say', '0.06' ];
107 0 push @modules, [ 'UNIVERSAL::DOES', '0.001' ];
108 }
109
110 1 return @modules;
111 } #/ sub compat_modules
112  
113 my %also = (
114 0 ▶ Dumper => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
115 0 require Data::Dumper;
116 0 ▶ return sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
117 0 local $Data::Dumper::Deparse;
118 0 Data::Dumper::Dumper( @_ );
119 0 };
120 },
121 0 ▶ croak => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
122 0 ▶ return sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
123 0 require Carp;
124 0 ▶ Carp::croak( @_ > 1 ? sprintf( shift, @_ ) : @_ );
Branch: 1 branch
BranchTrueFalseTotal
@_ > 1 ? : 0 0 0
125 0 };
126 },
127 0 ▶ carp => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
128 0 ▶ return sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
129 0 require Carp;
130 0 ▶ Carp::carp( @_ > 1 ? sprintf( shift, @_ ) : @_ );
Branch: 1 branch
BranchTrueFalseTotal
@_ > 1 ? : 0 0 0
131 0 };
132 },
133 0 ▶ cluck => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
134 0 ▶ return sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
135 0 require Carp;
136 0 ▶ Carp::cluck( @_ > 1 ? sprintf( shift, @_ ) : @_ );
Branch: 1 branch
BranchTrueFalseTotal
@_ > 1 ? : 0 0 0
137 0 };
138 },
139 0 ▶ maybe => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
140 0 ▶ if ( eval 'use PerlX::Maybe::XS 0.003 (); 1' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval "use PerlX::Maybe::XS 0.003 (); 1") 0 0 0
141 0 return \&PerlX::Maybe::XS::maybe;
142 }
143 0 ▶ return sub ($$@) {
Subroutine __ANON__: not called CC=4 SCAR=30.0
144 0 ▶ ( defined $_[0] and defined $_[1] )
Branch: 2 branches
BranchTrueFalseTotal
defined $_[0] && defined $_[1] ? : 0 0 0
@_ > 1 ? : 0 0 0
Condition0%0/3
defined $_[0] and defined $_[1]
!ll&&!rl&&r
000
MC/DC0%0/2
defined $_[0] and defined $_[1]
defined $_[0] defined $_[1]
Truth table0%0/3
A and B
A= defined $_[0]B= defined $_[1]
ABresult
0X0
100
111
145 ? @_
146 : ( ( @_ > 1 ) ? @_[ 2 .. $#_ ] : qw() );
147 0 };
148 },
149 0 ▶ provided => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
150 0 ▶ if ( eval 'use PerlX::Maybe::XS 0.003 (); 1' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval "use PerlX::Maybe::XS 0.003 (); 1") 0 0 0
151 0 return \&PerlX::Maybe::XS::provided;
152 }
153 0 ▶ return sub ($$$@) {
Subroutine __ANON__: not called CC=3 SCAR=24.8
154 ( shift )
155 0 ▶ ? @_
Branch: 2 branches
BranchTrueFalseTotal
shift() ? : 0 0 0
@_ > 1 ? : 0 0 0
156 : ( ( @_ > 1 ) ? @_[ 2 .. $#_ ] : qw() );
157 0 };
158 },
159 0 ▶ encode_json => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
160 0 ▶ if ( eval 'use JSON::MaybeXS 1.003000 (); 1' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval "use JSON::MaybeXS 1.003000 (); 1") 0 0 0
161 0 return \&JSON::MaybeXS::encode_json;
162 }
163 0 require JSON::PP;
164 0 return \&JSON::PP::encode_json;
165 },
166 0 ▶ decode_json => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
167 0 ▶ if ( eval 'use JSON::MaybeXS 1.003000 (); 1' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval "use JSON::MaybeXS 1.003000 (); 1") 0 0 0
168 0 return \&JSON::MaybeXS::decode_json;
169 }
170 0 require JSON::PP;
171 0 return \&JSON::PP::decode_json;
172 },
173 0 ▶ STRICT => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
174 0 ▶ $STRICT ? sub () { !!1 } : sub () { !!0 };
Branch: 1 branch
BranchTrueFalseTotal
$STRICT ? : 0 0 0
175 },
176 0 ▶ LAX => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
177 0 ▶ $STRICT ? sub () { !!0 } : sub () { !!1 };
Branch: 1 branch
BranchTrueFalseTotal
$STRICT ? : 0 0 0
178 },
179 1 all => q(List::Util),
180 any => q(List::Util),
181 first => q(List::Util),
182 head => q(List::Util),
183 max => q(List::Util),
184 maxstr => q(List::Util),
185 min => q(List::Util),
186 minstr => q(List::Util),
187 none => q(List::Util),
188 notall => q(List::Util),
189 pairfirst => q(List::Util),
190 pairgrep => q(List::Util),
191 pairkeys => q(List::Util),
192 pairmap => q(List::Util),
193 pairs => q(List::Util),
194 pairvalues => q(List::Util),
195 product => q(List::Util),
196 reduce => q(List::Util),
197 reductions => q(List::Util),
198 sample => q(List::Util),
199 shuffle => q(List::Util),
200 sum => q(List::Util),
201 sum0 => q(List::Util),
202 tail => q(List::Util),
203 uniq => q(List::Util),
204 uniqnum => q(List::Util),
205 uniqstr => q(List::Util),
206 unpairs => q(List::Util),
207 blessed => q(Scalar::Util),
208 dualvar => q(Scalar::Util),
209 isdual => q(Scalar::Util),
210 isvstring => q(Scalar::Util),
211 isweak => q(Scalar::Util),
212 looks_like_number => q(Scalar::Util),
213 openhandle => q(Scalar::Util),
214 readonly => q(Scalar::Util),
215 refaddr => q(Scalar::Util),
216 reftype => q(Scalar::Util),
217 set_prototype => q(Scalar::Util),
218 tainted => q(Scalar::Util),
219 unweaken => q(Scalar::Util),
220 weaken => q(Scalar::Util),
221 prototype => q(Sub::Util),
222 set_prototype => q(Sub::Util),
223 set_subname => q(Sub::Util),
224 subname => q(Sub::Util),
225 check_module_name => q(Module::Runtime),
226 check_module_spec => q(Module::Runtime),
227 compose_module_name => q(Module::Runtime),
228 is_module_name => q(Module::Runtime),
229 is_module_spec => q(Module::Runtime),
230 is_valid_module_name => q(Module::Runtime),
231 is_valid_module_spec => q(Module::Runtime),
232 module_notional_filename => q(Module::Runtime),
233 require_module => q(Module::Runtime),
234 use_module => q(Module::Runtime),
235 use_package_optimistically => q(Module::Runtime),
236 );
237  
238 1 ▶sub also {
Subroutine also: called CC=11 SCAR=42.0
Pod undocumented
239 1 my ( $class, $target ) = ( shift, shift );
240
241 1 my %imports;
242 1 for my $arg ( @_ ) {
243 0 my ( $func, $dest ) = split /:/, $arg;
244 0 ▶ $dest = $func unless $dest;
Branch: 1 branch
BranchTrueFalseTotal
unless $dest 0 0 0
245
246 0 ▶ my $source = $also{$func} or do {
Branch: 1 branch
BranchTrueFalseTotal
my $source = $also{$func} or do { require Carp; Carp::croak("Do not know where to find function $func"); next } 0 0 0
247 0 require Carp;
248 0 Carp::croak( "Do not know where to find function $func" );
249 0 next;
250 };
251
252 0 ▶ push @{ $imports{ ref( $source ) or $source } ||= [] },
Branch: 1 branch
BranchTrueFalseTotal
ref $source ? : 0 0 0
Condition0%0/5
$imports{ref $source or $source} ||= []
l!l
00
ref $source || $source
l!l&&r!l&&!r
000
MC/DC0%0/1
$imports{ref $source or $source} ||= []
$imports{ref $source or $source}
MC/DC0%0/2
ref $source || $source
ref $source $source
Truth table0%0/2
A
A= $imports{ref $source or $source}
Aresult
11
00
Truth table0%0/3
A || B
A= ref $sourceB= $source
ABresult
1X1
011
000
253 ref( $source ) ? [ $dest, $source ] : [ $dest, $func ];
254 } #/ for my $arg ( @_ )
255
256 1 for my $source ( sort keys %imports ) {
257 0 ▶ if ( $source eq 'CODE' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($source eq 'CODE') { } 0 0 0
258 0 for my $func ( @{ $imports{$source} } ) {
259 0 my ( $name, $gen ) = @$func;
260 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
261 0 *{"$target\::$name"} = $gen->();
262 }
263 }
264 else {
265 0 use_module( $source );
266 0 for my $func ( @{ $imports{$source} } ) {
267 0 my ( $name, $orig ) = @$func;
268 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
269 0 *{"$target\::$name"} = \&{"$source\::$orig"};
270 }
271 }
272 } #/ for my $source ( sort keys...)
273 } #/ sub also
274  
275 1 1;
276  
277 __END__
↑ Summary