blib/lib/Eval/TypeTiny.pm

filter: Statementstmt 97.8% 182 / 186 Branchbran 80.7% 84 / 104 Conditioncond 60.0% 45 / 75 MC/DCmcdc 37.2% 16 / 43 Subroutinesub 73.5% 27 / 34 (2 uncoverable) Podpod 100% 4 / 4 totaltotal 79.8% 358 / 446 (2 uncoverable) CC 134 SCAR 28.9
CC
134
Cov
85%
ArrayRefFromAny
31.2
JsonHash
31.2
MyHashRef
31.2
CRAP 17.9
« blib/lib/Type/Utils.pm ↑ Summary blib/lib/Types/TypeTiny.pm »
1 package Eval::TypeTiny;
2  
3 297 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 32430 ▶sub _clean_eval {
Subroutine _clean_eval: called CC=1 SCAR=0.0
6 32430 local $@;
7 32430 local $SIG{__DIE__};
8 32430 ▶ my $r = eval $_[0];
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
9 32430 my $e = $@;
10 32430 return ( $r, $e );
11 }
12  
13 297 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 297 ▶BEGIN {
Subroutine BEGIN: called CC=3 SCAR=12.0
16 297 ▶ *HAS_LEXICAL_SUBS = ( $] >= 5.018 ) ? sub () { !!1 } : sub () { !!0 };
Branch: 1 branch
BranchTrueFalseTotal
$] >= 5.018 ? : 297 0 297
17 297 ▶ *NICE_PROTOTYPES = ( $] >= 5.014 ) ? sub () { !!1 } : sub () { !!0 };
Branch: 1 branch
BranchTrueFalseTotal
$] >= 5.014 ? : 297 0 297
18 }
19  
20 280 ▶sub _pick_alternative {
Subroutine _pick_alternative: called CC=9 SCAR=22.1
21 280 my $ok = 0;
22 280 ▶ while ( @_ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 280 1 281
23 280 my ( $type, $condition, $result ) = splice @_, 0, 3;
24 280 ▶ if ( $type eq 'needs' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($type eq 'needs') { } 277 3 280
elsif ($type eq 'if') { } 3 0 3
25 277 ▶ ++$ok if eval "require $condition; 1";
Branch: 1 branch
BranchTrueFalseTotal
if eval "require $condition; 1" 277 0 277
26 }
27 elsif ( $type eq 'if' ) {
28 3 ▶ ++$ok if $condition;
Branch: 1 branch
BranchTrueFalseTotal
if $condition 2 1 3
29 }
30 280 ▶ next unless $ok;
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 1 279 280
31 279 ▶ return ref( $result ) eq 'CODE' ? $result->() : ref( $result ) eq 'SCALAR' ? eval( $$result ) : $result;
Branch: 2 branches
BranchTrueFalseTotal
ref $result eq 'CODE' ? : 0 279 279
ref $result eq 'SCALAR' ? : 277 2 279
32 }
33 1 return;
34 }
35  
36 {
37 sub IMPLEMENTATION_DEVEL_LEXALIAS () { 'Devel::LexAlias' }
38 sub IMPLEMENTATION_PADWALKER () { 'PadWalker' }
39 sub IMPLEMENTATION_TIE () { 'tie' }
40 sub IMPLEMENTATION_NATIVE () { 'perl' }
41
42 295 my $implementation;
43
44 #<<<
45 # uncoverable subroutine
46 104 ▶ sub ALIAS_IMPLEMENTATION () {
Subroutine ALIAS_IMPLEMENTATION: called (marked uncoverable but covered) CC=2 SCAR=7.2
Pod documented
47 104 ▶ $implementation ||= _pick_alternative(
Condition66%2/3
$implementation ||=
l!l&&r!l&&!r
10310
MC/DC0%0/2
$implementation ||=
$implementation
Truth table66%2/3
A ||= B
A= $implementationB=
ABresult
1X1
011
000
48 if => ( $] ge '5.022' ) => IMPLEMENTATION_NATIVE,
49 needs => 'Devel::LexAlias' => IMPLEMENTATION_DEVEL_LEXALIAS,
50 needs => 'PadWalker' => IMPLEMENTATION_PADWALKER,
51 if => !!1 => IMPLEMENTATION_TIE,
52 );
53 }
54 #>>>
55
56 5 ▶ sub _force_implementation {
Subroutine _force_implementation: called CC=1 SCAR=0.0
57 5 $implementation = shift;
58 }
59 }
60  
61 295 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=6.9
62 297 ▶ *_EXTENDED_TESTING = $ENV{EXTENDED_TESTING} ? sub() { !!1 } : sub() { !!0 };
Branch: 1 branch
BranchTrueFalseTotal
$ENV{'EXTENDED_TESTING'} ? : 294 3 297
63 }
64  
65 295 our $AUTHORITY = 'cpan:TOBYINK';
66 295 our $VERSION = '2.010001';
67 295 our @EXPORT = qw( eval_closure );
68 296 our @EXPORT_OK = qw(
69 HAS_LEXICAL_SUBS HAS_LEXICAL_VARS ALIAS_IMPLEMENTATION
70 IMPLEMENTATION_DEVEL_LEXALIAS IMPLEMENTATION_PADWALKER
71 IMPLEMENTATION_NATIVE IMPLEMENTATION_TIE
72 set_subname type_to_coderef NICE_PROTOTYPES
73 );
74  
75 296 $VERSION =~ tr/_//d;
76  
77 # See Types::TypeTiny for an explanation of this import method.
78 #
79 # uncoverable subroutine
80 285 ▶sub import {
Subroutine import: called (marked uncoverable but covered) CC=3 SCAR=11.2
81 297 ▶ no warnings "redefine";
Subroutine BEGIN: called CC=1 SCAR=0.0
82 285 our @ISA = qw( Exporter::Tiny );
83 285 require Exporter::Tiny;
84 285 my $next = \&Exporter::Tiny::import;
85 285 *import = $next;
86 285 my $class = shift;
87 0 ▶ my $opts = { ref( $_[0] ) ? %{ +shift } : () };
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 285 285
88 285 ▶ $opts->{into} ||= scalar( caller );
Condition50%1/2
$opts->{"into"} ||= scalar caller
l!l
0285
MC/DC0%0/1
$opts->{"into"} ||= scalar caller
$opts->{"into"}
Truth table50%1/2
A
A= $opts->{"into"}
Aresult
11
00
89 285 return $class->$next( $opts, @_ );
90 } #/ sub import
91  
92 {
93 296 my $subname;
94 296 my %already; # prevent renaming established functions
95 72617 ▶ sub set_subname ($$) {
Subroutine set_subname: called CC=4 SCAR=13.9
Pod documented
96 72617 ▶ $subname = _pick_alternative(
Branch: 1 branch
BranchTrueFalseTotal
unless defined $subname 277 72340 72617
97 needs => 'Sub::Util' => \ q{ \&Sub::Util::set_subname },
98 needs => 'Sub::Name' => \ q{ \&Sub::Name::subname },
99 if => !!1 => 0,
100 ) unless defined $subname;
101 72617 ▶ $subname and !$already{$_[1]}++ and return &$subname;
Branch: 1 branch
BranchTrueFalseTotal
$subname and not $already{$_[1]}++ and return &$subname 50354 22263 72617
Condition66%2/3
$subname and not $already{$_[1]}++
!ll&&!rl&&r
02226350354
MC/DC50%1/2
$subname and not $already{$_[1]}++
$subname not $already{$_[1]}++
Truth table66%2/3
A and not(B)
A= $subnameB= not $already{$_[1]}++
ABresult
0X0
100
111
102 22263 $_[1];
103 } #/ sub set_subname ($$)
104 }
105  
106 296 ▶sub type_to_coderef {
Subroutine type_to_coderef: called CC=7 SCAR=22.7
Pod documented
107 15884 my ( $type, %args ) = @_;
108 15884 ▶ my $post_method = $args{post_method} || q();
Condition50%1/2
$args{'post_method'} || ''
l!l
015884
MC/DC0%0/1
$args{'post_method'} || ''
$args{'post_method'}
Truth table50%1/2
A
A= $args{'post_method'}
Aresult
11
00
109
110 15884 my ( $coderef, $qualified_name );
111
112 15884 ▶ if ( ! defined $type ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $type) { } 1039 14845 15884
113 1039 my $library = $args{type_library};
114 1039 my $name = $args{type_name};
115
116 1039 $qualified_name = "$library\::$name";
117 531 ▶ $coderef = sub (;@) {
Subroutine __ANON__: called CC=12 SCAR=34.4
118 531 my $params;
119 531 ▶ $params = shift if ref( $_[0] ) eq "ARRAY";
Branch: 2 branches
BranchTrueFalseTotal
if ref $_[0] eq "ARRAY" 0 531 531
if ref $_[0] eq "ARRAY" 1 12 13
120
121 531 ▶ $type ||= do {
Condition33%1/3
$type ||= do { $library->can("get_type") or require Error::TypeTiny and Error::TypeTiny::croak("Expected $library to be a type library, but it doesn't seem to be"); $library->get_type($name) }
l!l&&r!l&&!r
00531
MC/DC0%0/2
$type ||= do { $library->can("get_type") or require Error::TypeTiny and Error::TypeTiny::croak("Expected $library to be a type library, but it doesn't seem to be"); $library->get_type($name) }
$type do { $library->can("get_type") or require Error::TypeTiny and Error::TypeTiny::croak("Expected $library to be a type library, but it doesn't seem to be"); $library->get_type($name) }
Truth table33%1/3
A ||= B
A= $typeB= do { $library->can("get_type") or require Error::TypeTiny and Error::TypeTiny::croak("Expected $library to be a type library, but it doesn't seem to be"); $library->get_type($name) }
ABresult
1X1
011
000
122 531 ▶ $library->can( 'get_type' )
Branch: 1 branch
BranchTrueFalseTotal
$library->can("get_type") or require Error::TypeTiny and Error::TypeTiny::croak("Expected $library to be a type library, but it doesn't seem to be") 531 0 531
Condition20%1/5
$library->can('get_type') || require Error::TypeTiny && Error::TypeTiny::croak("Expected $library to be a type library, but it doesn't seem to be")
l!l&&r!l&&!r
53100
require Error::TypeTiny and Error::TypeTiny::croak("Expected $library to be a type library, but it doesn't seem to be")
!ll
00
MC/DC0%0/2
$library->can('get_type') || require Error::TypeTiny && Error::TypeTiny::croak("Expected $library to be a type library, but it doesn't seem to be")
$library->can('get_type') require Error::TypeTiny
Truth table33%1/3
A || B
A= $library->can('get_type')B= require Error::TypeTiny
ABresult
1X1
011
000
123 or require Error::TypeTiny
124 && Error::TypeTiny::croak( "Expected $library to be a type library, but it doesn't seem to be" );
125 531 $library->get_type( $name );
126 };
127
128 531 my $t;
129 531 ▶ if ( $type ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type) { } 0 531 531
130 0 ▶ $t = $params ? $type->parameterize( @$params ) : $type;
Branch: 1 branch
BranchTrueFalseTotal
$params ? : 0 0 0
131 0 ▶ $t = $t->$post_method if $post_method;
Branch: 1 branch
BranchTrueFalseTotal
if $post_method 0 0 0
132 }
133 else {
134 531 ▶ require Error::TypeTiny && Error::TypeTiny::croak( "Cannot parameterize a non-existant type" )
Branch: 1 branch
BranchTrueFalseTotal
if $params 0 531 531
Condition20%1/5
$params && (require Error::TypeTiny && Error::TypeTiny::croak('Cannot parameterize a non-existant type'))
!ll&&!rl&&r
53100
require Error::TypeTiny and Error::TypeTiny::croak("Cannot parameterize a non-existant type")
!ll
00
MC/DC0%0/2
$params && (require Error::TypeTiny && Error::TypeTiny::croak('Cannot parameterize a non-existant type'))
$params require Error::TypeTiny
Truth table33%1/3
A && B
A= $paramsB= require Error::TypeTiny
ABresult
0X0
100
111
135 if $params;
136 531 require Type::Tiny::_DeclaredType;
137 531 $t = Type::Tiny::_DeclaredType->new( library => $library, name => $name );
138 }
139
140 531 ▶ @_ && wantarray ? return ( $t, @_ ) : return $t;
Branch: 1 branch
BranchTrueFalseTotal
@_ && wantarray ? : 0 531 531
Condition33%1/3
@_ and wantarray
!ll&&!rl&&r
53100
MC/DC0%0/2
@_ and wantarray
@_ wantarray
Truth table33%1/3
A and B
A= @_B= wantarray
ABresult
0X0
100
111
141 1039 };
142
143 1039 ▶ require Scalar::Util && &Scalar::Util::set_prototype( $coderef, ';$' )
Branch: 1 branch
BranchTrueFalseTotal
require Scalar::Util and &Scalar::Util::set_prototype($coderef, ";\$") 1039 0 1039
144 if Eval::TypeTiny::NICE_PROTOTYPES;
145 }
146 else {
147
148 #<<<
149 14845 ▶ my $source = $type->is_parameterizable ?
Branch: 1 branch
BranchTrueFalseTotal
$type->is_parameterizable ? : 6710 8135 14845
150 sprintf(
151 q{
152 sub (%s) {
153 if (ref($_[0]) eq 'Type::Tiny::_HalfOp') {
154 my $complete_type = shift->complete($type);
155 @_ && wantarray ? return($complete_type, @_) : return $complete_type;
156 }
157 my $params; $params = shift if ref($_[0]) eq q(ARRAY);
158 my $t = $params ? $type->parameterize(@$params) : $type;
159 @_ && wantarray ? return($t%s, @_) : return $t%s;
160 }
161 },
162 NICE_PROTOTYPES ? q(;$) : q(;@),
163 $post_method,
164 $post_method,
165 ) :
166 sprintf( q{ sub () { $type%s if $] } }, $post_method );
167 #>>>
168
169 14845 $qualified_name = $type->qualified_name;
170 $coderef = eval_closure(
171 source => $source,
172 14845 ▶ description => $args{description} || sprintf( "exportable function '%s'", $qualified_name ),
Condition50%1/2
$args{'description'} || sprintf(q[exportable function '%s'], $qualified_name)
l!l
014845
MC/DC0%0/1
$args{'description'} || sprintf(q[exportable function '%s'], $qualified_name)
$args{'description'}
Truth table50%1/2
A
A= $args{'description'}
Aresult
11
00
173 environment => { '$type' => \$type },
174 );
175 }
176
177 15884 ▶ $args{anonymous} ? $coderef : set_subname( $qualified_name, $coderef );
Branch: 1 branch
BranchTrueFalseTotal
$args{'anonymous'} ? : 0 15884 15884
178 }
179  
180 32431 ▶sub eval_closure {
Subroutine eval_closure: called CC=27 SCAR=33.0
Pod documented
181 32431 my ( %args ) = @_;
182 my $src =
183 ref $args{source} eq "ARRAY"
184 2 ? join( "\n", @{ $args{source} } )
185 32431 ▶ : $args{source};
Branch: 1 branch
BranchTrueFalseTotal
ref $args{'source'} eq 'ARRAY' ? : 2 32429 32431
186
187 32431 ▶ $args{alias} = 0 unless defined $args{alias};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"alias"} 32415 16 32431
188 32431 ▶ $args{line} = 1 unless defined $args{line};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"line"} 32429 2 32431
189 $args{description} =~ s/[^\w .:-\[\]\(\)\{\}\']//g
190 32431 ▶ if defined $args{description};
Branch: 1 branch
BranchTrueFalseTotal
if defined $args{"description"} 32366 65 32431
191 $src = qq{#line $args{line} "$args{description}"\n$src}
192 32431 ▶ if defined $args{description} && !( $^P & 0x10 );
Branch: 1 branch
BranchTrueFalseTotal
if defined $args{"description"} and not $^P & 16 32366 65 32431
Condition66%2/3
defined $args{"description"} and not $^P & 16
!ll&&!rl&&r
65032366
MC/DC50%1/2
defined $args{"description"} and not $^P & 16
defined $args{"description"} not $^P & 16
Truth table66%2/3
A and not(B)
A= defined $args{"description"}B= not $^P & 16
ABresult
0X0
100
111
193 32431 ▶ $args{environment} ||= {};
Condition100%2/2
$args{"environment"} ||= {}
l!l
1545116980
MC/DC100%1/1
$args{"environment"} ||= {}
$args{"environment"}
Truth table100%2/2
A
A= $args{"environment"}
Aresult
11
00
194
195 32431 if ( _EXTENDED_TESTING ) {
196 32431 require Scalar::Util;
197 32431 for my $k ( sort keys %{ $args{environment} } ) {
198 next
199 if $k =~ /^\$/
200 15648 ▶ && Scalar::Util::reftype( $args{environment}{$k} ) =~ /^(SCALAR|REF)$/;
Branch: 1 branch
BranchTrueFalseTotal
if $k =~ /^\$/ and builtin::reftype($args{"environment"}{$k}) =~ /^(SCALAR|REF)$/ 15369 279 15648
Condition66%2/3
$k =~ /^\$/ and builtin::reftype($args{"environment"}{$k}) =~ /^(SCALAR|REF)$/
!ll&&!rl&&r
543015105
MC/DC50%1/2
$k =~ /^\$/ and builtin::reftype($args{"environment"}{$k}) =~ /^(SCALAR|REF)$/
$k =~ /^\$/ builtin::reftype($args{"environment"}{$k}) =~ /^(SCALAR|REF)$/
Truth table66%2/3
A and B
A= $k =~ /^\$/B= builtin::reftype($args{"environment"}{$k}) =~ /^(SCALAR|REF)$/
ABresult
0X0
100
111
201 next
202 if $k =~ /^\@/
203 543 ▶ && Scalar::Util::reftype( $args{environment}{$k} ) eq q(ARRAY);
Branch: 1 branch
BranchTrueFalseTotal
if $k =~ /^\@/ and builtin::reftype($args{"environment"}{$k}) eq "ARRAY" 269 274 543
Condition66%2/3
$k =~ /^\@/ and builtin::reftype($args{"environment"}{$k}) eq "ARRAY"
!ll&&!rl&&r
2740269
MC/DC50%1/2
$k =~ /^\@/ and builtin::reftype($args{"environment"}{$k}) eq "ARRAY"
$k =~ /^\@/ builtin::reftype($args{"environment"}{$k}) eq "ARRAY"
Truth table66%2/3
A and B
A= $k =~ /^\@/B= builtin::reftype($args{"environment"}{$k}) eq "ARRAY"
ABresult
0X0
100
111
204 next
205 if $k =~ /^\%/
206 274 ▶ && Scalar::Util::reftype( $args{environment}{$k} ) eq q(HASH);
Branch: 1 branch
BranchTrueFalseTotal
if $k =~ /^\%/ and builtin::reftype($args{"environment"}{$k}) eq "HASH" 7 267 274
Condition100%3/3
$k =~ /^\%/ and builtin::reftype($args{"environment"}{$k}) eq "HASH"
!ll&&!rl&&r
26617
MC/DC100%2/2
$k =~ /^\%/ and builtin::reftype($args{"environment"}{$k}) eq "HASH"
$k =~ /^\%/ builtin::reftype($args{"environment"}{$k}) eq "HASH"
Truth table100%3/3
A and B
A= $k =~ /^\%/B= builtin::reftype($args{"environment"}{$k}) eq "HASH"
ABresult
0X0
100
111
207 next
208 if $k =~ /^\&/
209 267 ▶ && Scalar::Util::reftype( $args{environment}{$k} ) eq q(CODE);
Branch: 1 branch
BranchTrueFalseTotal
if $k =~ /^\&/ and builtin::reftype($args{"environment"}{$k}) eq "CODE" 2 1 3
Condition66%2/3
$k =~ /^\&/ and builtin::reftype($args{"environment"}{$k}) eq "CODE"
!ll&&!rl&&r
102
MC/DC50%1/2
$k =~ /^\&/ and builtin::reftype($args{"environment"}{$k}) eq "CODE"
$k =~ /^\&/ builtin::reftype($args{"environment"}{$k}) eq "CODE"
Truth table66%2/3
A and B
A= $k =~ /^\&/B= builtin::reftype($args{"environment"}{$k}) eq "CODE"
ABresult
0X0
100
111
210
211 1 require Error::TypeTiny;
212 Error::TypeTiny::croak(
213 "Expected a variable name and ref; got %s => %s", $k,
214 265 $args{environment}{$k}
215 );
216 } #/ for my $k ( sort keys %...)
217 } #/ if ( _EXTENDED_TESTING)
218
219 32430 my $sandpkg = 'Eval::TypeTiny::Sandbox';
220 32166 ▶ my $alias = exists( $args{alias} ) ? $args{alias} : 0;
Branch: 1 branch
BranchTrueFalseTotal
exists $args{'alias'} ? : 32166 264 32430
221 32166 my @keys = sort keys %{ $args{environment} };
222 32166 my $i = 0;
223 32430 my $source = join "\n" => (
224 "package $sandpkg;",
225 "sub {",
226 map( _make_lexical_assignment( $_, $i++, $alias ), @keys ),
227 $src,
228 "}",
229 );
230
231 32430 ▶ if ( $alias and ALIAS_IMPLEMENTATION eq IMPLEMENTATION_TIE ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($alias and &ALIAS_IMPLEMENTATION() eq "tie") 5 32425 32430
Condition100%3/3
$alias and &ALIAS_IMPLEMENTATION() eq "tie"
!ll&&!rl&&r
32150115
MC/DC100%2/2
$alias and &ALIAS_IMPLEMENTATION() eq "tie"
$alias &ALIAS_IMPLEMENTATION() eq "tie"
Truth table100%3/3
A and B
A= $aliasB= &ALIAS_IMPLEMENTATION() eq "tie"
ABresult
0X0
100
111
232 269 _manufacture_ties();
233 }
234
235 32430 my ( $compiler, $e ) = _clean_eval( $source );
236 32166 ▶ if ( $e ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($e) 4 32162 32166
237 4 chomp $e;
238 268 require Error::TypeTiny::Compilation;
239 "Error::TypeTiny::Compilation"->throw(
240 code => (
241 1 ref $args{source} eq "ARRAY" ? join( "\n", @{ $args{source} } ) : $args{source}
242 ),
243 errstr => $e,
244 environment => $args{environment},
245 4 ▶ );
Branch: 1 branch
BranchTrueFalseTotal
ref $args{'source'} eq 'ARRAY' ? : 1 3 4
246 } #/ if ( $e )
247
248 32162 my $code = $compiler->( @{ $args{environment} }{@keys} );
249 32162 undef( $compiler );
250
251 32162 ▶ if ( $alias and ALIAS_IMPLEMENTATION eq IMPLEMENTATION_DEVEL_LEXALIAS ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($alias and &ALIAS_IMPLEMENTATION() eq "Devel::LexAlias") 3 32159 32162
Condition100%3/3
$alias and &ALIAS_IMPLEMENTATION() eq "Devel::LexAlias"
!ll&&!rl&&r
32146133
MC/DC100%2/2
$alias and &ALIAS_IMPLEMENTATION() eq "Devel::LexAlias"
$alias &ALIAS_IMPLEMENTATION() eq "Devel::LexAlias"
Truth table100%3/3
A and B
A= $aliasB= &ALIAS_IMPLEMENTATION() eq "Devel::LexAlias"
ABresult
0X0
100
111
252 3 require Devel::LexAlias;
253 Devel::LexAlias::lexalias( $code, $_ => $args{environment}{$_} )
254 3 for grep !/^\&/, @keys;
255 }
256
257 32162 ▶ if ( $alias and ALIAS_IMPLEMENTATION eq IMPLEMENTATION_PADWALKER ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($alias and &ALIAS_IMPLEMENTATION() eq "PadWalker") 3 32159 32162
Condition100%3/3
$alias and &ALIAS_IMPLEMENTATION() eq "PadWalker"
!ll&&!rl&&r
32146133
MC/DC100%2/2
$alias and &ALIAS_IMPLEMENTATION() eq "PadWalker"
$alias &ALIAS_IMPLEMENTATION() eq "PadWalker"
Truth table100%3/3
A and B
A= $aliasB= &ALIAS_IMPLEMENTATION() eq "PadWalker"
ABresult
0X0
100
111
258 3 require PadWalker;
259 3 my %env = map +( $_ => $args{environment}{$_} ), grep !/^\&/, @keys;
260 3 PadWalker::set_closed_over( $code, \%env );
261 }
262
263 32162 return $code;
264 } #/ sub eval_closure
265  
266 299 my $tmp;
267  
268 15503 ▶sub _make_lexical_assignment {
Subroutine _make_lexical_assignment: called CC=6 SCAR=17.9
269 15503 my ( $key, $index, $alias ) = @_;
270 15503 my $name = substr( $key, 1 );
271
272 15503 ▶ if ( HAS_LEXICAL_SUBS and $key =~ /^\&/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($key =~ /^\&/) 2 15501 15503
273 2 $tmp++;
274 2 my $tmpname = '$__LEXICAL_SUB__' . $tmp;
275 return
276 2 "no warnings 'experimental::lexical_subs';"
277 . "use feature 'lexical_subs';"
278 . "my $tmpname = \$_[$index];"
279 . "my sub $name { goto $tmpname };";
280 }
281
282 15501 ▶ if ( !$alias ) {
Branch: 4 branches
BranchTrueFalseTotal
if (not $alias) { } 15477 24 15501
elsif (&ALIAS_IMPLEMENTATION() eq 'perl') { } 7 17 24
elsif (&ALIAS_IMPLEMENTATION() eq 'Devel::LexAlias') { } 5 12 17
elsif (&ALIAS_IMPLEMENTATION() eq 'PadWalker') { } 5 7 12
283 15477 my $sigil = substr( $key, 0, 1 );
284 15477 return "my $key = $sigil\{ \$_[$index] };";
285 }
286 elsif ( ALIAS_IMPLEMENTATION eq IMPLEMENTATION_NATIVE ) {
287 return
288 7 "no warnings 'experimental::refaliasing';"
289 . "use feature 'refaliasing';"
290 . "my $key; \\$key = \$_[$index];";
291 }
292 elsif ( ALIAS_IMPLEMENTATION eq IMPLEMENTATION_DEVEL_LEXALIAS ) {
293 5 return "my $key;";
294 }
295 elsif ( ALIAS_IMPLEMENTATION eq IMPLEMENTATION_PADWALKER ) {
296 5 return "my $key;";
297 }
298 else {
299 my $tieclass = {
300 '@' => 'Eval::TypeTiny::_TieArray',
301 '%' => 'Eval::TypeTiny::_TieHash',
302 '$' => 'Eval::TypeTiny::_TieScalar',
303 7 }->{ substr( $key, 0, 1 ) };
304
305 7 return sprintf(
306 'tie(my(%s), "%s", $_[%d]);',
307 $key,
308 $tieclass,
309 $index,
310 );
311 } #/ else [ if ( !$alias ) ]
312 } #/ sub _make_lexical_assignment
313  
314 {
315 299 my $tie;
316
317 5 ▶ sub _manufacture_ties {
Subroutine _manufacture_ties: called CC=2 SCAR=7.2
318 0 ▶ $tie ||= eval <<'FALLBACK'; } }
Subroutine BEGIN: not called CC=1 SCAR=0.2
Subroutine BEGIN: not called CC=1 SCAR=0.2
Subroutine AUTOLOAD: not called CC=3 SCAR=11.4
Subroutine AUTOLOAD: not called CC=3 SCAR=11.4
Subroutine AUTOLOAD: not called CC=3 SCAR=11.4
Subroutine TIEARRAY: not called CC=1 SCAR=0.2
Subroutine TIEHASH: not called CC=1 SCAR=0.2
Subroutine TIESCALAR: called CC=1 SCAR=0.2
Branch: 6 branches
BranchTrueFalseTotal
defined tied @$self and return tied(@$self)->$method(@_) 0 13 13
unless $method eq "DESTROY" 11 0 11
defined tied %$self and return tied(%$self)->$method(@_) 3 11 14
unless $method eq "DESTROY" 0 4 4
defined tied $$self and return tied($$self)->$method(@_) 3 4 7
unless $method eq "DESTROY" 1 10 11
Condition57%12/21
$tie ||= eval "no warnings qw(void once uninitialized numeric);\nuse Type::Tiny ();\n\n{\n\tpackage #\n\t\tEval::TypeTiny::_TieArray;\n\trequire Tie::Array;\n\tour \@ISA = qw( Tie::StdArray );\n\tsub TIEARRAY {\n\t\tmy \$class = shift;\n\t\tbless \$_[0] => \$class;\n\t}\n\tsub AUTOLOAD {\n\t\tmy \$self = shift;\n\t\tmy (\$method) = (our \$AUTOLOAD =~ /(\\w+)\$/);\n\t\tdefined tied(\@\$self) and return tied(\@\$self)->\$method(\@_);\n\t\trequire Carp;\n\t\tCarp::croak(qq[Can't call method \"\$method\" on an undefined value]) unless \$method eq 'DESTROY';\n\t}\n\tsub can {\n\t\tmy \$self = shift;\n\t\tmy \$code = \$self->SUPER::can(\@_)\n\t\t\t|| (defined tied(\@\$self) and tied(\@\$self)->can(\@_));\n\t\treturn \$code;\n\t}\n\t__PACKAGE__->Type::Tiny::_install_overloads(\n\t\tq[bool] => sub { !! tied \@{\$_[0]} },\n\t\tq[\"\"] => sub { '' . tied \@{\$_[0]} },\n\t\tq[0+] => sub { 0 + tied \@{\$_[0]} },\n\t);\n}\n{\n\tpackage #\n\t\tEval::TypeTiny::_TieHash;\n\trequire Tie::Hash;\n\tour \@ISA = qw( Tie::StdHash );\n\tsub TIEHASH {\n\t\tmy \$class = shift;\n\t\tbless \$_[0] => \$class;\n\t}\n\tsub AUTOLOAD {\n\t\tmy \$self = shift;\n\t\tmy (\$method) = (our \$AUTOLOAD =~ /(\\w+)\$/);\n\t\tdefined tied(%\$self) and return tied(%\$self)->\$method(\@_);\n\t\trequire Carp;\n\t\tCarp::croak(qq[Can't call method \"\$method\" on an undefined value]) unless \$method eq 'DESTROY';\n\t}\n\tsub can {\n\t\tmy \$self = shift;\n\t\tmy \$code = \$self->SUPER::can(\@_)\n\t\t\t|| (defined tied(%\$self) and tied(%\$self)->can(\@_));\n\t\treturn \$code;\n\t}\n\t__PACKAGE__->Type::Tiny::_install_overloads(\n\t\tq[bool] => sub { !! tied %{\$_[0]} },\n\t\tq[\"\"] => sub { '' . tied %{\$_[0]} },\n\t\tq[0+] => sub { 0 + tied %{\$_[0]} },\n\t);\n}\n{\n\tpackage #\n\t\tEval::TypeTiny::_TieScalar;\n\trequire Tie::Scalar;\n\tour \@ISA = qw( Tie::StdScalar );\n\tsub TIESCALAR {\n\t\tmy \$class = shift;\n\t\tbless \$_[0] => \$class;\n\t}\n\tsub AUTOLOAD {\n\t\tmy \$self = shift;\n\t\tmy (\$method) = (our \$AUTOLOAD =~ /(\\w+)\$/);\n\t\tdefined tied(\$\$self) and return tied(\$\$self)->\$method(\@_);\n\t\trequire Carp;\n\t\tCarp::croak(qq[Can't call method \"\$method\" on an undefined value]) unless \$method eq 'DESTROY';\n\t}\n\tsub can {\n\t\tmy \$self = shift;\n\t\tmy \$code = \$self->SUPER::can(\@_)\n\t\t\t|| (defined tied(\$\$self) and tied(\$\$self)->can(\@_));\n\t\treturn \$code;\n\t}\n\t__PACKAGE__->Type::Tiny::_install_overloads(\n\t\tq[bool] => sub { !! tied \${\$_[0]} },\n\t\tq[\"\"] => sub { '' . tied \${\$_[0]} },\n\t\tq[0+] => sub { 0 + tied \${\$_[0]} },\n\t);\n}\n\n1;\n"
l!l&&r!l&&!r
320
$self->SUPER::can(@_) || defined tied @$self && tied(@$self)->can(@_)
l!l&&r!l&&!r
2110
defined tied @$self and tied(@$self)->can(@_)
!ll&&!rl&&r
1100
$self->SUPER::can(@_) || defined tied %$self && tied(%$self)->can(@_)
l!l&&r!l&&!r
000
defined tied %$self and tied(%$self)->can(@_)
!ll&&!rl&&r
1000
$self->SUPER::can(@_) || defined tied $$self && tied($$self)->can(@_)
l!l&&r!l&&!r
012
defined tied $$self and tied($$self)->can(@_)
!ll&&!rl&&r
1312
MC/DC0%0/2
$tie ||= eval "no warnings qw(void once uninitialized numeric);\nuse Type::Tiny ();\n\n{\n\tpackage #\n\t\tEval::TypeTiny::_TieArray;\n\trequire Tie::Array;\n\tour \@ISA = qw( Tie::StdArray );\n\tsub TIEARRAY {\n\t\tmy \$class = shift;\n\t\tbless \$_[0] => \$class;\n\t}\n\tsub AUTOLOAD {\n\t\tmy \$self = shift;\n\t\tmy (\$method) = (our \$AUTOLOAD =~ /(\\w+)\$/);\n\t\tdefined tied(\@\$self) and return tied(\@\$self)->\$method(\@_);\n\t\trequire Carp;\n\t\tCarp::croak(qq[Can't call method \"\$method\" on an undefined value]) unless \$method eq 'DESTROY';\n\t}\n\tsub can {\n\t\tmy \$self = shift;\n\t\tmy \$code = \$self->SUPER::can(\@_)\n\t\t\t|| (defined tied(\@\$self) and tied(\@\$self)->can(\@_));\n\t\treturn \$code;\n\t}\n\t__PACKAGE__->Type::Tiny::_install_overloads(\n\t\tq[bool] => sub { !! tied \@{\$_[0]} },\n\t\tq[\"\"] => sub { '' . tied \@{\$_[0]} },\n\t\tq[0+] => sub { 0 + tied \@{\$_[0]} },\n\t);\n}\n{\n\tpackage #\n\t\tEval::TypeTiny::_TieHash;\n\trequire Tie::Hash;\n\tour \@ISA = qw( Tie::StdHash );\n\tsub TIEHASH {\n\t\tmy \$class = shift;\n\t\tbless \$_[0] => \$class;\n\t}\n\tsub AUTOLOAD {\n\t\tmy \$self = shift;\n\t\tmy (\$method) = (our \$AUTOLOAD =~ /(\\w+)\$/);\n\t\tdefined tied(%\$self) and return tied(%\$self)->\$method(\@_);\n\t\trequire Carp;\n\t\tCarp::croak(qq[Can't call method \"\$method\" on an undefined value]) unless \$method eq 'DESTROY';\n\t}\n\tsub can {\n\t\tmy \$self = shift;\n\t\tmy \$code = \$self->SUPER::can(\@_)\n\t\t\t|| (defined tied(%\$self) and tied(%\$self)->can(\@_));\n\t\treturn \$code;\n\t}\n\t__PACKAGE__->Type::Tiny::_install_overloads(\n\t\tq[bool] => sub { !! tied %{\$_[0]} },\n\t\tq[\"\"] => sub { '' . tied %{\$_[0]} },\n\t\tq[0+] => sub { 0 + tied %{\$_[0]} },\n\t);\n}\n{\n\tpackage #\n\t\tEval::TypeTiny::_TieScalar;\n\trequire Tie::Scalar;\n\tour \@ISA = qw( Tie::StdScalar );\n\tsub TIESCALAR {\n\t\tmy \$class = shift;\n\t\tbless \$_[0] => \$class;\n\t}\n\tsub AUTOLOAD {\n\t\tmy \$self = shift;\n\t\tmy (\$method) = (our \$AUTOLOAD =~ /(\\w+)\$/);\n\t\tdefined tied(\$\$self) and return tied(\$\$self)->\$method(\@_);\n\t\trequire Carp;\n\t\tCarp::croak(qq[Can't call method \"\$method\" on an undefined value]) unless \$method eq 'DESTROY';\n\t}\n\tsub can {\n\t\tmy \$self = shift;\n\t\tmy \$code = \$self->SUPER::can(\@_)\n\t\t\t|| (defined tied(\$\$self) and tied(\$\$self)->can(\@_));\n\t\treturn \$code;\n\t}\n\t__PACKAGE__->Type::Tiny::_install_overloads(\n\t\tq[bool] => sub { !! tied \${\$_[0]} },\n\t\tq[\"\"] => sub { '' . tied \${\$_[0]} },\n\t\tq[0+] => sub { 0 + tied \${\$_[0]} },\n\t);\n}\n\n1;\n"
$tie eval "no warnings qw(void once uninitialized numeric);\nuse Type::Tiny ();\n\n{\n\tpackage #\n\t\tEval::TypeTiny::_TieArray;\n\trequire Tie::Array;\n\tour \@ISA = qw( Tie::StdArray );\n\tsub TIEARRAY {\n\t\tmy \$class = shift;\n\t\tbless \$_[0] => \$class;\n\t}\n\tsub AUTOLOAD {\n\t\tmy \$self = shift;\n\t\tmy (\$method) = (our \$AUTOLOAD =~ /(\\w+)\$/);\n\t\tdefined tied(\@\$self) and return tied(\@\$self)->\$method(\@_);\n\t\trequire Carp;\n\t\tCarp::croak(qq[Can't call method \"\$method\" on an undefined value]) unless \$method eq 'DESTROY';\n\t}\n\tsub can {\n\t\tmy \$self = shift;\n\t\tmy \$code = \$self->SUPER::can(\@_)\n\t\t\t|| (defined tied(\@\$self) and tied(\@\$self)->can(\@_));\n\t\treturn \$code;\n\t}\n\t__PACKAGE__->Type::Tiny::_install_overloads(\n\t\tq[bool] => sub { !! tied \@{\$_[0]} },\n\t\tq[\"\"] => sub { '' . tied \@{\$_[0]} },\n\t\tq[0+] => sub { 0 + tied \@{\$_[0]} },\n\t);\n}\n{\n\tpackage #\n\t\tEval::TypeTiny::_TieHash;\n\trequire Tie::Hash;\n\tour \@ISA = qw( Tie::StdHash );\n\tsub TIEHASH {\n\t\tmy \$class = shift;\n\t\tbless \$_[0] => \$class;\n\t}\n\tsub AUTOLOAD {\n\t\tmy \$self = shift;\n\t\tmy (\$method) = (our \$AUTOLOAD =~ /(\\w+)\$/);\n\t\tdefined tied(%\$self) and return tied(%\$self)->\$method(\@_);\n\t\trequire Carp;\n\t\tCarp::croak(qq[Can't call method \"\$method\" on an undefined value]) unless \$method eq 'DESTROY';\n\t}\n\tsub can {\n\t\tmy \$self = shift;\n\t\tmy \$code = \$self->SUPER::can(\@_)\n\t\t\t|| (defined tied(%\$self) and tied(%\$self)->can(\@_));\n\t\treturn \$code;\n\t}\n\t__PACKAGE__->Type::Tiny::_install_overloads(\n\t\tq[bool] => sub { !! tied %{\$_[0]} },\n\t\tq[\"\"] => sub { '' . tied %{\$_[0]} },\n\t\tq[0+] => sub { 0 + tied %{\$_[0]} },\n\t);\n}\n{\n\tpackage #\n\t\tEval::TypeTiny::_TieScalar;\n\trequire Tie::Scalar;\n\tour \@ISA = qw( Tie::StdScalar );\n\tsub TIESCALAR {\n\t\tmy \$class = shift;\n\t\tbless \$_[0] => \$class;\n\t}\n\tsub AUTOLOAD {\n\t\tmy \$self = shift;\n\t\tmy (\$method) = (our \$AUTOLOAD =~ /(\\w+)\$/);\n\t\tdefined tied(\$\$self) and return tied(\$\$self)->\$method(\@_);\n\t\trequire Carp;\n\t\tCarp::croak(qq[Can't call method \"\$method\" on an undefined value]) unless \$method eq 'DESTROY';\n\t}\n\tsub can {\n\t\tmy \$self = shift;\n\t\tmy \$code = \$self->SUPER::can(\@_)\n\t\t\t|| (defined tied(\$\$self) and tied(\$\$self)->can(\@_));\n\t\treturn \$code;\n\t}\n\t__PACKAGE__->Type::Tiny::_install_overloads(\n\t\tq[bool] => sub { !! tied \${\$_[0]} },\n\t\tq[\"\"] => sub { '' . tied \${\$_[0]} },\n\t\tq[0+] => sub { 0 + tied \${\$_[0]} },\n\t);\n}\n\n1;\n"
MC/DC0%0/3
$self->SUPER::can(@_) || defined tied @$self && tied(@$self)->can(@_)
$self->SUPER::can(@_) defined tied @$self tied(@$self)->can(@_)
MC/DC0%0/3
$self->SUPER::can(@_) || defined tied %$self && tied(%$self)->can(@_)
$self->SUPER::can(@_) defined tied %$self tied(%$self)->can(@_)
MC/DC66%2/3
$self->SUPER::can(@_) || defined tied $$self && tied($$self)->can(@_)
$self->SUPER::can(@_) defined tied $$self tied($$self)->can(@_)
Truth table66%2/3
A ||= B
A= $tieB= eval "no warnings qw(void once uninitialized numeric);\nuse Type::Tiny ();\n\n{\n\tpackage #\n\t\tEval::TypeTiny::_TieArray;\n\trequire Tie::Array;\n\tour \@ISA = qw( Tie::StdArray );\n\tsub TIEARRAY {\n\t\tmy \$class = shift;\n\t\tbless \$_[0] => \$class;\n\t}\n\tsub AUTOLOAD {\n\t\tmy \$self = shift;\n\t\tmy (\$method) = (our \$AUTOLOAD =~ /(\\w+)\$/);\n\t\tdefined tied(\@\$self) and return tied(\@\$self)->\$method(\@_);\n\t\trequire Carp;\n\t\tCarp::croak(qq[Can't call method \"\$method\" on an undefined value]) unless \$method eq 'DESTROY';\n\t}\n\tsub can {\n\t\tmy \$self = shift;\n\t\tmy \$code = \$self->SUPER::can(\@_)\n\t\t\t|| (defined tied(\@\$self) and tied(\@\$self)->can(\@_));\n\t\treturn \$code;\n\t}\n\t__PACKAGE__->Type::Tiny::_install_overloads(\n\t\tq[bool] => sub { !! tied \@{\$_[0]} },\n\t\tq[\"\"] => sub { '' . tied \@{\$_[0]} },\n\t\tq[0+] => sub { 0 + tied \@{\$_[0]} },\n\t);\n}\n{\n\tpackage #\n\t\tEval::TypeTiny::_TieHash;\n\trequire Tie::Hash;\n\tour \@ISA = qw( Tie::StdHash );\n\tsub TIEHASH {\n\t\tmy \$class = shift;\n\t\tbless \$_[0] => \$class;\n\t}\n\tsub AUTOLOAD {\n\t\tmy \$self = shift;\n\t\tmy (\$method) = (our \$AUTOLOAD =~ /(\\w+)\$/);\n\t\tdefined tied(%\$self) and return tied(%\$self)->\$method(\@_);\n\t\trequire Carp;\n\t\tCarp::croak(qq[Can't call method \"\$method\" on an undefined value]) unless \$method eq 'DESTROY';\n\t}\n\tsub can {\n\t\tmy \$self = shift;\n\t\tmy \$code = \$self->SUPER::can(\@_)\n\t\t\t|| (defined tied(%\$self) and tied(%\$self)->can(\@_));\n\t\treturn \$code;\n\t}\n\t__PACKAGE__->Type::Tiny::_install_overloads(\n\t\tq[bool] => sub { !! tied %{\$_[0]} },\n\t\tq[\"\"] => sub { '' . tied %{\$_[0]} },\n\t\tq[0+] => sub { 0 + tied %{\$_[0]} },\n\t);\n}\n{\n\tpackage #\n\t\tEval::TypeTiny::_TieScalar;\n\trequire Tie::Scalar;\n\tour \@ISA = qw( Tie::StdScalar );\n\tsub TIESCALAR {\n\t\tmy \$class = shift;\n\t\tbless \$_[0] => \$class;\n\t}\n\tsub AUTOLOAD {\n\t\tmy \$self = shift;\n\t\tmy (\$method) = (our \$AUTOLOAD =~ /(\\w+)\$/);\n\t\tdefined tied(\$\$self) and return tied(\$\$self)->\$method(\@_);\n\t\trequire Carp;\n\t\tCarp::croak(qq[Can't call method \"\$method\" on an undefined value]) unless \$method eq 'DESTROY';\n\t}\n\tsub can {\n\t\tmy \$self = shift;\n\t\tmy \$code = \$self->SUPER::can(\@_)\n\t\t\t|| (defined tied(\$\$self) and tied(\$\$self)->can(\@_));\n\t\treturn \$code;\n\t}\n\t__PACKAGE__->Type::Tiny::_install_overloads(\n\t\tq[bool] => sub { !! tied \${\$_[0]} },\n\t\tq[\"\"] => sub { '' . tied \${\$_[0]} },\n\t\tq[0+] => sub { 0 + tied \${\$_[0]} },\n\t);\n}\n\n1;\n"
ABresult
1X1
011
000
Truth table0%0/4
A || B and C
A= $self->SUPER::can(@_)B= defined tied @$selfC= tied(@$self)->can(@_)
ABCresult
1XX1
0111
00X0
0100
Truth table0%0/4
A || B and C
A= $self->SUPER::can(@_)B= defined tied %$selfC= tied(%$self)->can(@_)
ABCresult
1XX1
0111
00X0
0100
Truth table75%3/4
A || B and C
A= $self->SUPER::can(@_)B= defined tied $$selfC= tied($$self)->can(@_)
ABCresult
1XX1
0111
00X0
0100
319 no warnings qw(void once uninitialized numeric);
320 use Type::Tiny ();
321  
322 {
323 package #
324 Eval::TypeTiny::_TieArray;
325 require Tie::Array;
326 our @ISA = qw( Tie::StdArray );
327 sub TIEARRAY {
328 my $class = shift;
329 bless $_[0] => $class;
330 }
331 sub AUTOLOAD {
332 my $self = shift;
333 my ($method) = (our $AUTOLOAD =~ /(\w+)$/);
334 defined tied(@$self) and return tied(@$self)->$method(@_);
335 require Carp;
336 Carp::croak(qq[Can't call method "$method" on an undefined value]) unless $method eq 'DESTROY';
337 }
338 sub can {
339 my $self = shift;
340 my $code = $self->SUPER::can(@_)
341 || (defined tied(@$self) and tied(@$self)->can(@_));
342 return $code;
343 }
344 __PACKAGE__->Type::Tiny::_install_overloads(
345 q[bool] => sub { !! tied @{$_[0]} },
346 q[""] => sub { '' . tied @{$_[0]} },
347 q[0+] => sub { 0 + tied @{$_[0]} },
348 );
349 }
350 {
351 package #
352 Eval::TypeTiny::_TieHash;
353 require Tie::Hash;
354 our @ISA = qw( Tie::StdHash );
355 sub TIEHASH {
356 my $class = shift;
357 bless $_[0] => $class;
358 }
359 sub AUTOLOAD {
360 my $self = shift;
361 my ($method) = (our $AUTOLOAD =~ /(\w+)$/);
362 defined tied(%$self) and return tied(%$self)->$method(@_);
363 require Carp;
364 Carp::croak(qq[Can't call method "$method" on an undefined value]) unless $method eq 'DESTROY';
365 }
366 sub can {
367 my $self = shift;
368 my $code = $self->SUPER::can(@_)
369 || (defined tied(%$self) and tied(%$self)->can(@_));
370 return $code;
371 }
372 __PACKAGE__->Type::Tiny::_install_overloads(
373 q[bool] => sub { !! tied %{$_[0]} },
374 q[""] => sub { '' . tied %{$_[0]} },
375 q[0+] => sub { 0 + tied %{$_[0]} },
376 );
377 }
378 {
379 package #
380 Eval::TypeTiny::_TieScalar;
381 require Tie::Scalar;
382 our @ISA = qw( Tie::StdScalar );
383 sub TIESCALAR {
384 my $class = shift;
385 bless $_[0] => $class;
386 }
387 sub AUTOLOAD {
388 my $self = shift;
389 my ($method) = (our $AUTOLOAD =~ /(\w+)$/);
390 defined tied($$self) and return tied($$self)->$method(@_);
391 require Carp;
392 Carp::croak(qq[Can't call method "$method" on an undefined value]) unless $method eq 'DESTROY';
393 }
394 sub can {
395 my $self = shift;
396 my $code = $self->SUPER::can(@_)
397 || (defined tied($$self) and tied($$self)->can(@_));
398 return $code;
399 }
400 __PACKAGE__->Type::Tiny::_install_overloads(
401 q[bool] => sub { !! tied ${$_[0]} },
402 q[""] => sub { '' . tied ${$_[0]} },
403 q[0+] => sub { 0 + tied ${$_[0]} },
404 );
405 }
406  
407 1;
408 FALLBACK
409  
410 299 1;
411  
412 __END__
« blib/lib/Type/Utils.pm ↑ Summary blib/lib/Types/TypeTiny.pm »