blib/lib/Zuzu/Runtime.pm

filter: Statementstmt 77.6% 3158 / 4065 Branchbran 61.3% 1616 / 2636 Conditioncond 47.1% 919 / 1949 MC/DCmcdc 20.5% 225 / 1093 Subroutinesub 88.3% 288 / 326 Podpod 42.6% 29 / 68 totaltotal 61.5% 6235 / 10137 CC 2129 SCAR 50.1
CC
2129
Cov
66%
eval_binary
1079.0
_eval_binary_op_values
1054.9
__ANON__
414.6
CRAP 149.5
« blib/lib/Zuzu/Module/Secure.pm ↑ Summary blib/lib/Zuzu/Module/CLib.pm »
1 package Zuzu::Runtime;
2  
3 69 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 69 our $VERSION = '0.007002';
6 69 our $DEBUG_LEVEL = 0;
7  
8 69 ▶use Digest::MD5 qw( md5_hex );
Subroutine BEGIN: called CC=1 SCAR=0.0
9 69 ▶use Encode qw( FB_CROAK decode );
Subroutine BEGIN: called CC=1 SCAR=0.0
10 69 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 69 ▶use File::Basename qw( dirname );
Subroutine BEGIN: called CC=1 SCAR=0.0
12 69 ▶use File::Path qw( make_path );
Subroutine BEGIN: called CC=1 SCAR=0.0
13 69 ▶use File::ShareDir qw( dist_dir );
Subroutine BEGIN: called CC=1 SCAR=0.0
14 69 ▶use File::Temp qw( tempfile );
Subroutine BEGIN: called CC=1 SCAR=0.0
15 69 ▶use Cwd ();
Subroutine BEGIN: called CC=1 SCAR=0.0
16 69 ▶use Storable qw( nstore retrieve );
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 69 ▶use Zuzu::Env;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 69 ▶use Zuzu::Error;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 69 ▶use Zuzu::Lexer;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 69 ▶use Zuzu::Parser;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 69 ▶use Zuzu::Parser::_Impl;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 69 ▶use Zuzu::Runtime::Async::Scheduler;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 69 ▶use Zuzu::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
25 69 ▶use Zuzu::AST::Expr::TypeRef;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 69 ▶use Zuzu::AST::Stmt::Class;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 69 ▶use Zuzu::Value::Array;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 69 ▶use Zuzu::Value::Class;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 69 ▶use Zuzu::Value::Dict;
Subroutine BEGIN: called CC=1 SCAR=0.0
30 69 ▶use Zuzu::Value::Function;
Subroutine BEGIN: called CC=1 SCAR=0.0
31 69 ▶use Zuzu::Value::Object;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 69 ▶use Zuzu::Value::PairList;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 69 ▶use Zuzu::Value::Regexp;
Subroutine BEGIN: called CC=1 SCAR=0.0
34 69 ▶use Zuzu::Value::Set;
Subroutine BEGIN: called CC=1 SCAR=0.0
35 69 ▶use Zuzu::Value::Bag;
Subroutine BEGIN: called CC=1 SCAR=0.0
36 69 ▶use POSIX ();
Subroutine BEGIN: called CC=1 SCAR=0.0
37 69 ▶use Zuzu::Value::Boolean;
Subroutine BEGIN: called CC=1 SCAR=0.0
38 69 ▶use Zuzu::Value::BinaryString;
Subroutine BEGIN: called CC=1 SCAR=0.0
39 69 ▶use Zuzu::Value::Task;
Subroutine BEGIN: called CC=1 SCAR=0.0
40 69 ▶use Zuzu::Value::Equality qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
41 equality_type
42 stable_value_key
43 value_equal
44 69 );
45 69 ▶use Zuzu::Value::Trait;
Subroutine BEGIN: called CC=1 SCAR=0.0
46 69 ▶use Zuzu::Weak qw( slot_value store_value );
Subroutine BEGIN: called CC=1 SCAR=0.0
47  
48 69 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
49 69 ▶use Scalar::Util qw( blessed refaddr weaken );
Subroutine BEGIN: called CC=1 SCAR=0.0
50  
51 69 ▶no warnings 'recursion';
Subroutine BEGIN: called CC=1 SCAR=0.0
52  
53 69 our %MODULE_AST_CACHE;
54 69 our %MODULE_PATH_CACHE;
55 69 our $PERSISTENT_AST_CACHE_VERSION = 4;
56 69 our $PERSISTENT_AST_CACHE_MAGIC = 'ZUZU-PERL-AST-CACHE';
57 69 our $PERSISTENT_AST_CACHE_MAX_SIZE = 100 * 1024 * 1024;
58 69 our $PERSISTENT_AST_CACHE_MAX_AGE = 30 * 24 * 60 * 60;
59 69 our $PERSISTENT_AST_CACHE_ROOT;
60 69 our $PERSISTENT_AST_CACHE_EXPIRY_RAN = 0;
61 69 our $EMPTY_HASH = {};
62 69 our $EMPTY_ARRAY = [];
63  
64 69 my $TRUE = Zuzu::Value::Boolean->new( value => 1 );
65 69 my $FALSE = Zuzu::Value::Boolean->new( value => 0 );
66 47114 ▶sub _boolify { $_[0] ? $TRUE : $FALSE }
Subroutine _boolify: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$_[0] ? : 33595 13519 47114
67 69 my @BUILTIN_COLLECTION_KINDS = qw( Array Dict PairList Set Bag );
68 69 my %ARRAY_MUTATING_METHOD = map { $_ => 1 } qw(
69 append push add push_weak pop
70 prepend unshift unshift_weak shift
71 set set_weak clear remove
72 );
73 69 my %DICT_MUTATING_METHOD = map { $_ => 1 } qw(
74 add add_weak set set_weak remove clear
75 );
76 69 my %SET_MUTATING_METHOD = map { $_ => 1 } qw(
77 add add_weak push push_weak remove clear remove_if
78 );
79 69 my %BAG_MUTATING_METHOD = map { $_ => 1 } qw(
80 add add_weak push push_weak remove remove_first clear remove_if
81 );
82  
83 237 ▶has 'lib' => ( is => 'rw', default => sub { [ @Zuzu::Runtime::DEFAULT_LIB ] } );
Subroutine __ANON__: called CC=1 SCAR=0.0
84 518 ▶has 'deny_modules' => ( is => 'rw', default => sub { [] } );
Subroutine __ANON__: called CC=1 SCAR=0.0
85 547 ▶has 'forbid' => ( is => 'rw', default => sub { [] } );
Subroutine __ANON__: called CC=1 SCAR=0.0
86 516 ▶has 'deny' => ( is => 'rw', default => sub { [] } );
Subroutine __ANON__: called CC=1 SCAR=0.0
87 69 has 'allow' => ( is => 'rw' );
88 536 ▶has 'persistent_ast_cache' => ( is => 'rw', default => sub { 1 } );
Subroutine __ANON__: called CC=1 SCAR=0.0
89 538 ▶has 'disabled_visitors' => ( is => 'rw', default => sub { [] } );
Subroutine __ANON__: called CC=1 SCAR=0.0
90 543 ▶has 'builtin' => ( is => 'rw', default => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
91 return {
92 543 'std/data/json' => 'Zuzu::Module::JSON',
93 'std/marshal' => 'Zuzu::Module::Marshal',
94 'std/archive' => 'Zuzu::Module::Archive',
95 'std/data/csv' => 'Zuzu::Module::CSV',
96 'std/data/yaml' => 'Zuzu::Module::YAML',
97 'std/math' => 'Zuzu::Module::Math',
98 'std/math/bignum' => 'Zuzu::Module::Math::BigNum',
99 'std/io' => 'Zuzu::Module::IO',
100 'std/time' => 'Zuzu::Module::Time',
101 'std/task' => 'Zuzu::Module::Task',
102 'std/worker' => 'Zuzu::Module::Worker',
103 'std/net/dns' => 'Zuzu::Module::DNS',
104 'std/net/http' => 'Zuzu::Module::HTTP',
105 'std/net/smtp' => 'Zuzu::Module::Net::SMTP',
106 'std/net/url' => 'Zuzu::Module::URL',
107 'std/proc' => 'Zuzu::Module::Proc',
108 'std/db' => 'Zuzu::Module::DB',
109 'std/clib' => 'Zuzu::Module::CLib',
110 'std/io/socks' => 'Zuzu::Module::Socks',
111 'std/string' => 'Zuzu::Module::String',
112 'std/string/base64' => 'Zuzu::Module::Base64',
113 'std/string/encode' => 'Zuzu::Module::String::Encode',
114 'std/digest/md5' => 'Zuzu::Module::DigestMD5',
115 'std/digest/sha' => 'Zuzu::Module::DigestSHA',
116 'std/secure' => 'Zuzu::Module::Secure',
117 'std/data/xml' => 'Zuzu::Module::XML',
118 'std/internals' => 'Zuzu::Module::Internals',
119 'std/tui' => 'Zuzu::Module::TUI',
120 'std/eval' => 'Zuzu::Module::Eval',
121 'std/gui/objects' => 'Zuzu::Module::GUI::Objects',
122 'perl' => 'Zuzu::Module::Perl',
123 };
124 69 } );
125  
126 69 our $INITIAL_CWD = Cwd::getcwd();
127  
128 904 ▶sub _absolute_module_path {
Subroutine _absolute_module_path: called CC=3 SCAR=12.5
129 904 my ( $path ) = @_;
130 904 ▶ return undef if !defined $path or $path eq '';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $path or $path eq "" 0 904 904
Condition33%1/3
not defined $path or $path eq ""
l!l&&r!l&&!r
00904
MC/DC0%0/2
not defined $path or $path eq ""
not defined $path $path eq ""
Truth table33%1/3
not(A) or B
A= not defined $pathB= $path eq ""
ABresult
1X1
011
000
131 904 return File::Spec->rel2abs( $path, $INITIAL_CWD );
132 }
133  
134 616 ▶sub _dedup_paths {
Subroutine _dedup_paths: called CC=3 SCAR=12.7
135 616 my ( @paths ) = @_;
136 616 my %seen;
137 return grep {
138 616 ▶ defined $_ and $_ ne '' and !$seen{$_}++
Condition33%2/6
defined $_ && $_ ne '' && !$seen{$_}++
!ll&&!rl&&r
00835
defined $_ and $_ ne ""
!ll&&!rl&&r
00835
MC/DC0%0/3
defined $_ && $_ ne '' && !$seen{$_}++
defined $_ $_ ne "" !$seen{$_}++
Truth table25%1/4
A and B && not(C)
A= defined $_B= $_ ne ""C= !$seen{$_}++
ABCresult
0XX0
10X0
1100
1111
139 } @paths;
140 }
141  
142 0 ▶sub _env_path_separator {
Subroutine _env_path_separator: not called CC=2 SCAR=17.9
143 0 ▶ return $^O eq 'MSWin32' ? ';' : ':';
Branch: 1 branch
BranchTrueFalseTotal
$^O eq 'MSWin32' ? : 0 0 0
144 }
145  
146 69 ▶sub _user_modules_dir {
Subroutine _user_modules_dir: called CC=6 SCAR=25.2
147 return _absolute_module_path(
148 File::Spec->catdir( $ENV{LOCALAPPDATA}, 'Zuzu', 'modules' )
149 69 ▶ ) if $^O eq 'MSWin32' and defined $ENV{LOCALAPPDATA} and $ENV{LOCALAPPDATA} ne '';
Branch: 1 branch
BranchTrueFalseTotal
if $^O eq "MSWin32" and defined $ENV{"LOCALAPPDATA"} and $ENV{"LOCALAPPDATA"} ne "" 0 69 69
Condition33%2/6
$^O eq "MSWin32" and defined $ENV{"LOCALAPPDATA"} and $ENV{"LOCALAPPDATA"} ne ""
!ll&&!rl&&r
6900
$^O eq "MSWin32" and defined $ENV{"LOCALAPPDATA"}
!ll&&!rl&&r
6900
MC/DC0%0/3
$^O eq "MSWin32" and defined $ENV{"LOCALAPPDATA"} and $ENV{"LOCALAPPDATA"} ne ""
$^O eq "MSWin32" defined $ENV{"LOCALAPPDATA"} $ENV{"LOCALAPPDATA"} ne ""
Truth table25%1/4
A and B and C
A= $^O eq "MSWin32"B= defined $ENV{"LOCALAPPDATA"}C= $ENV{"LOCALAPPDATA"} ne ""
ABCresult
0XX0
10X0
1100
1111
150  
151 return _absolute_module_path(
152 File::Spec->catdir( $ENV{HOME}, '.zuzu', 'modules' )
153 69 ▶ ) if defined $ENV{HOME} and $ENV{HOME} ne '';
Branch: 1 branch
BranchTrueFalseTotal
if defined $ENV{"HOME"} and $ENV{"HOME"} ne "" 69 0 69
Condition33%1/3
defined $ENV{"HOME"} and $ENV{"HOME"} ne ""
!ll&&!rl&&r
0069
MC/DC0%0/2
defined $ENV{"HOME"} and $ENV{"HOME"} ne ""
defined $ENV{"HOME"} $ENV{"HOME"} ne ""
Truth table33%1/3
A and B
A= defined $ENV{"HOME"}B= $ENV{"HOME"} ne ""
ABresult
0X0
100
111
154  
155 0 return undef;
156 }
157  
158 69 ▶sub _system_modules_dir {
Subroutine _system_modules_dir: called CC=4 SCAR=17.9
159 return _absolute_module_path(
160 File::Spec->catdir( $ENV{ProgramData}, 'Zuzu', 'modules' )
161 69 ▶ ) if $^O eq 'MSWin32' and defined $ENV{ProgramData} and $ENV{ProgramData} ne '';
Branch: 1 branch
BranchTrueFalseTotal
if $^O eq "MSWin32" and defined $ENV{"ProgramData"} and $ENV{"ProgramData"} ne "" 0 69 69
Condition33%2/6
$^O eq "MSWin32" and defined $ENV{"ProgramData"} and $ENV{"ProgramData"} ne ""
!ll&&!rl&&r
6900
$^O eq "MSWin32" and defined $ENV{"ProgramData"}
!ll&&!rl&&r
6900
MC/DC0%0/3
$^O eq "MSWin32" and defined $ENV{"ProgramData"} and $ENV{"ProgramData"} ne ""
$^O eq "MSWin32" defined $ENV{"ProgramData"} $ENV{"ProgramData"} ne ""
Truth table25%1/4
A and B and C
A= $^O eq "MSWin32"B= defined $ENV{"ProgramData"}C= $ENV{"ProgramData"} ne ""
ABCresult
0XX0
10X0
1100
1111
162  
163 69 return '/var/lib/zuzu/modules';
164 }
165  
166 69 ▶sub _dist_modules_dir {
Subroutine _dist_modules_dir: called CC=5 SCAR=20.9
167 69 my $dir = eval { dist_dir('Zuzu') };
168 69 ▶ return undef if !defined $dir or $dir eq '';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $dir or $dir eq "" 0 69 69
Condition33%1/3
not defined $dir or $dir eq ""
l!l&&r!l&&!r
0069
MC/DC0%0/2
not defined $dir or $dir eq ""
not defined $dir $dir eq ""
Truth table33%1/3
not(A) or B
A= not defined $dirB= $dir eq ""
ABresult
1X1
011
000
169 69 my $modules = File::Spec->catdir( $dir, 'modules' );
170 69 ▶ return _absolute_module_path($modules) if -d $modules;
Branch: 1 branch
BranchTrueFalseTotal
if -d $modules 69 0 69
171 0 ▶ return _absolute_module_path($dir) if -d File::Spec->catdir( $dir, 'std' );
Branch: 1 branch
BranchTrueFalseTotal
if -d "File::Spec"->catdir($dir, "std") 0 0 0
172 0 return undef;
173 }
174  
175 69 our @DEFAULT_LIB = do {
176 69 my @paths;
177  
178 69 ▶ if ( defined $ENV{ZUZULIB} and $ENV{ZUZULIB} ne '' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ENV{"ZUZULIB"} and $ENV{"ZUZULIB"} ne "") 0 69 69
Condition33%1/3
defined $ENV{"ZUZULIB"} and $ENV{"ZUZULIB"} ne ""
!ll&&!rl&&r
6900
MC/DC0%0/2
defined $ENV{"ZUZULIB"} and $ENV{"ZUZULIB"} ne ""
defined $ENV{"ZUZULIB"} $ENV{"ZUZULIB"} ne ""
Truth table33%1/3
A and B
A= defined $ENV{"ZUZULIB"}B= $ENV{"ZUZULIB"} ne ""
ABresult
0X0
100
111
179 0 my $separator = _env_path_separator();
180 push @paths, map {
181 0 _absolute_module_path($_)
182 } grep {
183 0 ▶ defined $_ and $_ ne ''
Condition0%0/3
defined $_ && $_ ne ''
!ll&&!rl&&r
000
MC/DC0%0/2
defined $_ && $_ ne ''
defined $_ $_ ne ''
Truth table0%0/3
A && B
A= defined $_B= $_ ne ''
ABresult
0X0
100
111
184 0 } split /\Q$separator\E/, $ENV{ZUZULIB};
185 }
186  
187 69 my $user_dir = _user_modules_dir();
188 69 ▶ push @paths, $user_dir if defined $user_dir and -d $user_dir;
Branch: 1 branch
BranchTrueFalseTotal
if defined $user_dir and -d $user_dir 0 69 69
Condition33%1/3
defined $user_dir and -d $user_dir
!ll&&!rl&&r
0690
MC/DC0%0/2
defined $user_dir and -d $user_dir
defined $user_dir -d $user_dir
Truth table33%1/3
A and B
A= defined $user_dirB= -d $user_dir
ABresult
0X0
100
111
189  
190 69 my $system_dir = _system_modules_dir();
191 69 ▶ push @paths, $system_dir if defined $system_dir and -d $system_dir;
Branch: 1 branch
BranchTrueFalseTotal
if defined $system_dir and -d $system_dir 0 69 69
Condition33%1/3
defined $system_dir and -d $system_dir
!ll&&!rl&&r
0690
MC/DC0%0/2
defined $system_dir and -d $system_dir
defined $system_dir -d $system_dir
Truth table33%1/3
A and B
A= defined $system_dirB= -d $system_dir
ABresult
0X0
100
111
192  
193 69 ▶ if ( defined $ENV{ZUZU_STDLIB} and $ENV{ZUZU_STDLIB} ne '' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ENV{'ZUZU_STDLIB'} and $ENV{'ZUZU_STDLIB'} ne '') { } 0 69 69
Condition33%1/3
defined $ENV{"ZUZU_STDLIB"} and $ENV{"ZUZU_STDLIB"} ne ""
!ll&&!rl&&r
6900
MC/DC0%0/2
defined $ENV{"ZUZU_STDLIB"} and $ENV{"ZUZU_STDLIB"} ne ""
defined $ENV{"ZUZU_STDLIB"} $ENV{"ZUZU_STDLIB"} ne ""
Truth table33%1/3
A and B
A= defined $ENV{"ZUZU_STDLIB"}B= $ENV{"ZUZU_STDLIB"} ne ""
ABresult
0X0
100
111
194 0 push @paths, _absolute_module_path( $ENV{ZUZU_STDLIB} );
195 }
196 else {
197 69 ▶ push @paths, ( _dist_modules_dir() // () );
Condition33%1/3
_dist_modules_dir() // ()
l!l&&r!l&&!r
6900
MC/DC0%0/2
_dist_modules_dir() // ()
_dist_modules_dir() ()
Truth table33%1/3
A // B
A= _dist_modules_dir()B= ()
ABresult
1X1
011
000
198 }
199  
200 69 _dedup_paths(@paths);
201 };
202  
203 547 ▶sub BUILD {
Subroutine BUILD: called CC=3 SCAR=11.0
Pod undocumented
204 547 my ($self, $args) = @_;
205  
206 $self->lib([
207 _dedup_paths(
208 547 ▶ map { _absolute_module_path($_) } @{ $self->lib // [] }
Condition50%1/2
$self->lib // []
l!l
5470
MC/DC0%0/1
$self->lib // []
$self->lib
Truth table50%1/2
A
A= $self->lib
Aresult
11
00
209 ),
210 ]);
211 $self->disabled_visitors([
212 Zuzu::Parser->normalize_disabled_visitors(
213 547 ▶ @{ $self->disabled_visitors // [] },
Condition50%1/2
$self->disabled_visitors // []
l!l
5470
MC/DC0%0/1
$self->disabled_visitors // []
$self->disabled_visitors
Truth table50%1/2
A
A= $self->disabled_visitors
Aresult
11
00
214 ),
215 ]);
216 547 $self->{_parser} = Zuzu::Parser->new(
217 disabled_visitors => $self->disabled_visitors,
218 );
219 547 $self->{_global} = Zuzu::Env->_new_fast(undef);
220 547 $self->{_stack} = [ $self->{_global} ];
221 547 $self->{_modules} = {}; # module => env
222 547 $self->{_module_exports} = {}; # module => { name => 1 }
223 547 $self->{_builtin_global_names} = {};
224 547 $self->{_system_readonly_refs} = {};
225 547 $self->{_regexp_cache} = {};
226 547 $self->{_module_candidate_cache} = {};
227 547 $self->{_method_candidate_cache} = {};
228 547 $self->{_bound_method_cache} = {};
229 547 $self->{_per_object_trait_class_cache} = {};
230 547 $self->{_module_builtin_aliases} = [];
231 547 $self->{_module_builtin_slot_set} = {};
232 547 $self->{_demolish_objects} = [];
233 547 $self->{_scheduler} = Zuzu::Runtime::Async::Scheduler->new(
234 runtime => $self,
235 );
236 547 $self->_normalize_policies;
237 547 $self->_install_builtins;
238 547 $self->_install_special_globals;
239 547 $self->_refresh_module_builtin_alias_cache;
240  
241 547 return;
242 }
243  
244 7 ▶sub finish {
Subroutine finish: called CC=7 SCAR=19.8
Pod documented
245 7 my ( $self ) = @_;
246  
247 7 ▶ return $self if $self->{_finishing};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_finishing"} 0 7 7
248 7 local $self->{_finishing} = 1;
249  
250 7 ▶ while ( @{ $self->{_demolish_objects} // [] } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->{"_demolish_objects"} // [];}) 2 7 9
Condition50%1/2
$self->{"_demolish_objects"} // []
l!l
90
MC/DC0%0/1
$self->{"_demolish_objects"} // []
$self->{"_demolish_objects"}
Truth table50%1/2
A
A= $self->{"_demolish_objects"}
Aresult
11
00
251 2 my $object = pop @{ $self->{_demolish_objects} };
252 next
253 2 ▶ if !blessed($object)
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($object) and $object->isa("Zuzu::Value::Object") and $object->can("run_demolish_hook") 1 1 2
Condition66%4/6
builtin::blessed($object) and $object->isa("Zuzu::Value::Object") and $object->can("run_demolish_hook")
!ll&&!rl&&r
101
builtin::blessed($object) and $object->isa("Zuzu::Value::Object")
!ll&&!rl&&r
101
MC/DC33%1/3
builtin::blessed($object) and $object->isa("Zuzu::Value::Object") and $object->can("run_demolish_hook")
builtin::blessed($object) $object->isa("Zuzu::Value::Object") $object->can("run_demolish_hook")
Truth table50%2/4
A and B and C
A= builtin::blessed($object)B= $object->isa("Zuzu::Value::Object")C= $object->can("run_demolish_hook")
ABCresult
0XX0
10X0
1100
1111
254 or !$object->isa('Zuzu::Value::Object')
255 or !$object->can('run_demolish_hook');
256 1 $object->run_demolish_hook;
257 }
258  
259 7 return $self;
260 }
261  
262 0 ▶sub DEMOLISH {
Subroutine DEMOLISH: not called CC=3 SCAR=24.8
Pod undocumented
263 0 my ( $self ) = @_;
264  
265 $self->{_scheduler}->shutdown
266 if defined $self->{_scheduler}
267 0 ▶ and $self->{_scheduler}->can('shutdown');
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"_scheduler"} and $self->{"_scheduler"}->can("shutdown") 0 0 0
Condition0%0/3
defined $self->{"_scheduler"} and $self->{"_scheduler"}->can("shutdown")
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{"_scheduler"} and $self->{"_scheduler"}->can("shutdown")
defined $self->{"_scheduler"} $self->{"_scheduler"}->can("shutdown")
Truth table0%0/3
A and B
A= defined $self->{"_scheduler"}B= $self->{"_scheduler"}->can("shutdown")
ABresult
0X0
100
111
268  
269 0 return;
270 }
271  
272 1364 ▶sub evaluate {
Subroutine evaluate: called CC=4 SCAR=14.5
Pod documented
273 1364 my ($self, $ast) = @_;
274  
275 1364 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($ast) and $ast->isa("Zuzu::AST::Program") and not $self->_env->{"slots"}{"__file__"}) 547 817 1364
Condition50%3/6
builtin::blessed($ast) and $ast->isa("Zuzu::AST::Program") and not $self->_env->{"slots"}{"__file__"}
!ll&&!rl&&r
0817547
builtin::blessed($ast) and $ast->isa("Zuzu::AST::Program")
!ll&&!rl&&r
001364
MC/DC33%1/3
builtin::blessed($ast) and $ast->isa("Zuzu::AST::Program") and not $self->_env->{"slots"}{"__file__"}
builtin::blessed($ast) $ast->isa("Zuzu::AST::Program") not $self->_env->{"slots"}{"__file__"}
Truth table50%2/4
A and B and not(C)
A= builtin::blessed($ast)B= $ast->isa("Zuzu::AST::Program")C= not $self->_env->{"slots"}{"__file__"}
ABCresult
0XX0
10X0
1100
1111
276 blessed($ast)
277 and $ast->isa('Zuzu::AST::Program')
278 and !$self->_env->{slots}{'__file__'}
279 ) {
280 547 $self->_declare_file_const( $self->_env, $ast->file, 0 );
281 }
282  
283 1364 return $ast->evaluate($self);
284 }
285  
286 41 ▶sub parse_with_current_scope {
Subroutine parse_with_current_scope: called CC=10 SCAR=23.3
Pod undocumented
287 41 my ( $self, $source, $filename ) = @_;
288  
289 41 ▶ $filename //= '<eval>';
Condition50%1/2
$filename //= "<eval>"
l!l
410
MC/DC0%0/1
$filename //= "<eval>"
$filename
Truth table50%1/2
A
A= $filename
Aresult
11
00
290  
291 41 my $ast;
292 eval {
293 41 my $lexer = Zuzu::Lexer->new( src => $source, filename => $filename );
294 41 my $parser = Zuzu::Parser::_Impl->new(
295 lexer => $lexer,
296 filename => $filename,
297 );
298  
299 41 my %visible;
300 41 my $env = $self->_env;
301 41 ▶ while ( defined $env ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $env) 55 41 96
302 55 for my $name ( CORE::keys %{ $env->slots } ) {
303 1564 ▶ next if $name eq '__wildcard_import__';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "__wildcard_import__" 0 1564 1564
304 1564 $visible{$name} = 1;
305 }
306 55 $env = $env->parent;
307 }
308  
309 41 my $scope = $parser->scopes->[0];
310 41 for my $name ( CORE::keys %visible ) {
311 1563 ▶ next if exists $scope->{$name};
Branch: 1 branch
BranchTrueFalseTotal
if exists $scope->{$name} 1377 186 1563
312 186 $scope->{$name} = {
313 kind => 'eval-visible',
314 mutable => 1,
315 };
316 }
317 41 push @{ $parser->scopes }, {};
318  
319 41 $ast = $parser->parse_program;
320 35 $self->{_parser}->apply_visitors($ast);
321 35 1;
322 41 ▶ } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { my $lexer = "Zuzu::Lexer"->new("src", $source, "filename", $filename); my $parser = "Zuzu::Parser::_Impl"->new("lexer", $lexer, "filename", $filename); my %visible; my $env = $self->_env; while (defined $env) { foreach my $name (keys %{$env->slots;}) { next if $name eq "__wildcard_import__"; $visible{$name} = 1; } ; $env = $env->parent; } ; my $scope = $parser->scopes->[0]; foreach my $name (keys %visible) { next if exists $scope->{$name}; $scope->{$name} = {"kind", "eval-visible", "mutable", 1}; } ; push @{$parser->scopes;}, {}; $ast = $parser->parse_program; $self->{"_parser"}->apply_visitors($ast); 1 } } or do { my $error = $@; die $error if ref $error and eval { do { $error->isa("Zuzu::Error") } }; die $self->{"_parser"}->_compile_error_from_parse_exception($error, $filename) } 35 6 41
323 6 my $error = $@;
324 6 ▶ die $error if ref($error) and eval { $error->isa('Zuzu::Error') };
Branch: 1 branch
BranchTrueFalseTotal
if ref $error and eval { do { $error->isa("Zuzu::Error") } } 6 0 6
Condition33%1/3
ref $error and eval { do { $error->isa("Zuzu::Error") } }
!ll&&!rl&&r
006
MC/DC0%0/2
ref $error and eval { do { $error->isa("Zuzu::Error") } }
ref $error eval { do { $error->isa("Zuzu::Error") } }
Truth table33%1/3
A and B
A= ref $errorB= eval { do { $error->isa("Zuzu::Error") } }
ABresult
0X0
100
111
325 die $self->{_parser}->_compile_error_from_parse_exception(
326 0 $error,
327 $filename,
328 );
329 };
330  
331 35 return $ast;
332 }
333  
334 41 ▶sub eval_with_current_scope {
Subroutine eval_with_current_scope: called CC=3 SCAR=11.0
Pod undocumented
335 41 my ( $self, $source, $filename ) = @_;
336  
337 41 my $ast = $self->parse_with_current_scope( $source, $filename );
338 35 my $env = Zuzu::Env->_new_fast( $self->_env );
339 35 $self->_push_env($env);
340 35 my ( $ok, $result, $error );
341 35 $ok = eval {
342 35 $result = $self->evaluate( $ast );
343 29 1;
344 };
345 35 ▶ $error = $@ if !$ok;
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 6 29 35
346 35 $self->_pop_env;
347  
348 35 ▶ die $error if !$ok;
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 6 29 35
349 29 return $result;
350 }
351  
352 23 ▶sub eval_with_current_scope_denials {
Subroutine eval_with_current_scope_denials: called CC=4 SCAR=14.2
Pod undocumented
353 23 my ( $self, $source, $filename, $extra_denials ) = @_;
354  
355 23 ▶ my @extra = grep { defined $_ and $_ ne '' } @{ $extra_denials // [] };
Condition40%2/5
defined $_ && $_ ne ''
!ll&&!rl&&r
006
$extra_denials // []
l!l
230
MC/DC0%0/2
defined $_ && $_ ne ''
defined $_ $_ ne ''
MC/DC0%0/1
$extra_denials // []
$extra_denials
Truth table33%1/3
A && B
A= defined $_B= $_ ne ''
ABresult
0X0
100
111
Truth table50%1/2
A
A= $extra_denials
Aresult
11
00
356 23 ▶ return $self->eval_with_current_scope( $source, $filename )
Branch: 1 branch
BranchTrueFalseTotal
if scalar @extra == 0 17 6 23
357 if scalar @extra == 0;
358  
359 return $self->_with_additional_denials(
360 \@extra,
361 6 ▶ sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
362 6 return $self->eval_with_current_scope( $source, $filename );
363 },
364 6 );
365 }
366  
367 6 ▶sub _with_additional_denials {
Subroutine _with_additional_denials: called CC=11 SCAR=24.9
368 6 my ( $self, $extra_denials, $code ) = @_;
369  
370 6 ▶ my @extra = grep { defined $_ and $_ ne '' } @{ $extra_denials // [] };
Condition40%2/5
defined $_ && $_ ne ''
!ll&&!rl&&r
006
$extra_denials // []
l!l
60
MC/DC0%0/2
defined $_ && $_ ne ''
defined $_ $_ ne ''
MC/DC0%0/1
$extra_denials // []
$extra_denials
Truth table33%1/3
A && B
A= defined $_B= $_ ne ''
ABresult
0X0
100
111
Truth table50%1/2
A
A= $extra_denials
Aresult
11
00
371 6 ▶ return $code->() if scalar @extra == 0;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @extra == 0 0 6 6
372  
373 6 ▶ my @current = @{ $self->deny // [] };
Condition50%1/2
$self->deny // []
l!l
60
MC/DC0%0/1
$self->deny // []
$self->deny
Truth table50%1/2
A
A= $self->deny
Aresult
11
00
374 0 my %seen = map { $_ => 1 } @current;
375 6 my @combined = ( @current, grep { !$seen{$_}++ } @extra );
376 my %restore = (
377 deny => [ @current ],
378 6 ▶ deny_modules => [ @{ $self->deny_modules // [] } ],
Condition50%1/2
$self->deny_modules // []
l!l
60
MC/DC0%0/1
$self->deny_modules // []
$self->deny_modules
Truth table50%1/2
A
A= $self->deny_modules
Aresult
11
00
379 6 ▶ forbid => [ @{ $self->forbid // [] } ],
Branch: 1 branch
BranchTrueFalseTotal
defined $self->allow ? : 0 6 6
Condition50%1/2
$self->forbid // []
l!l
60
MC/DC0%0/1
$self->forbid // []
$self->forbid
Truth table50%1/2
A
A= $self->forbid
Aresult
11
00
380 0 allow => ( defined $self->allow ? [ @{ $self->allow } ] : undef ),
381 6 ▶ deny_set => { %{ $self->{_deny_set} // {} } },
Condition50%1/2
$self->{"_deny_set"} // {}
l!l
60
MC/DC0%0/1
$self->{"_deny_set"} // {}
$self->{"_deny_set"}
Truth table50%1/2
A
A= $self->{"_deny_set"}
Aresult
11
00
382 );
383  
384 6 $self->deny( \@combined );
385 6 $self->_normalize_policies;
386 6 $self->_sync_system_policy_flags;
387  
388 6 my ( $ok, $result, $error );
389 6 $ok = eval {
390 6 $result = $code->();
391 3 1;
392 };
393 6 ▶ $error = $@ if !$ok;
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 3 3 6
394  
395 6 $self->deny( $restore{deny} );
396 6 $self->deny_modules( $restore{deny_modules} );
397 6 $self->forbid( $restore{forbid} );
398 6 $self->allow( $restore{allow} );
399 6 $self->{_deny_set} = $restore{deny_set};
400 6 $self->_sync_system_policy_flags;
401  
402 6 ▶ die $error if !$ok;
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 3 3 6
403 3 return $result;
404 }
405  
406  
407 44 ▶sub has_function {
Subroutine has_function: called CC=4 SCAR=14.5
Pod undocumented
408 44 my ($self, $name) = @_;
409  
410 44 my $ref = $self->{_global}->find_ref($name);
411 44 ▶ return 0 if !$ref;
Branch: 1 branch
BranchTrueFalseTotal
unless $ref 8 36 44
412 36 my $fn = $$ref;
413  
414 36 ▶ return ( blessed($fn) and $fn->isa('Zuzu::Value::Function') ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($fn) && $fn->isa('Zuzu::Value::Function') ? : 36 0 36
Condition33%1/3
builtin::blessed($fn) and $fn->isa("Zuzu::Value::Function")
!ll&&!rl&&r
0036
MC/DC0%0/2
builtin::blessed($fn) and $fn->isa("Zuzu::Value::Function")
builtin::blessed($fn) $fn->isa("Zuzu::Value::Function")
Truth table33%1/3
A and B
A= builtin::blessed($fn)B= $fn->isa("Zuzu::Value::Function")
ABresult
0X0
100
111
415 }
416  
417 0 ▶sub function_is_async {
Subroutine function_is_async: not called CC=2 SCAR=17.9
Pod undocumented
418 0 my ($self, $name) = @_;
419  
420 0 my $fn = $self->_global_function($name);
421 0 ▶ return $fn->is_async ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$fn->is_async ? : 0 0 0
422 }
423  
424 1704 ▶sub call {
Subroutine call: called CC=3 SCAR=11.0
Pod documented
425 1704 my ($self, $name, @args) = @_;
426  
427 1704 my $value = $self->call_unawaited($name, @args);
428 1692 ▶ return $value->await
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($value) and $value->isa("Zuzu::Value::Task") 19 1673 1692
Condition100%3/3
builtin::blessed($value) and $value->isa("Zuzu::Value::Task")
!ll&&!rl&&r
16492419
MC/DC100%2/2
builtin::blessed($value) and $value->isa("Zuzu::Value::Task")
builtin::blessed($value) $value->isa("Zuzu::Value::Task")
Truth table100%3/3
A and B
A= builtin::blessed($value)B= $value->isa("Zuzu::Value::Task")
ABresult
0X0
100
111
429 if blessed($value) and $value->isa('Zuzu::Value::Task');
430 1673 return $value;
431 }
432  
433 1704 ▶sub call_unawaited {
Subroutine call_unawaited: called CC=1 SCAR=0.0
Pod undocumented
434 1704 my ($self, $name, @args) = @_;
435  
436 1704 my $fn = $self->_global_function($name);
437 1704 return $self->_call_function(
438 $fn,
439 \@args,
440 $EMPTY_HASH,
441 $EMPTY_ARRAY,
442 '<call>',
443 0,
444 );
445 }
446  
447 1704 ▶sub _global_function {
Subroutine _global_function: called CC=4 SCAR=15.0
448 1704 my ($self, $name) = @_;
449  
450 1704 my $ref = $self->{_global}->find_ref($name);
451 1704 ▶ die Zuzu::Error->new_runtime(message => "No such function '$name'", file => '<runtime>', line => 0) if !$ref;
Branch: 1 branch
BranchTrueFalseTotal
unless $ref 0 1704 1704
452 1704 my $fn = $$ref;
453 1704 ▶ die Zuzu::Error->new_runtime(message => "'$name' is not a function", file => '<runtime>', line => 0) if !blessed($fn) or !$fn->isa('Zuzu::Value::Function');
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($fn) and $fn->isa("Zuzu::Value::Function") 0 1704 1704
Condition33%1/3
builtin::blessed($fn) and $fn->isa("Zuzu::Value::Function")
!ll&&!rl&&r
001704
MC/DC0%0/2
builtin::blessed($fn) and $fn->isa("Zuzu::Value::Function")
builtin::blessed($fn) $fn->isa("Zuzu::Value::Function")
Truth table33%1/3
A and B
A= builtin::blessed($fn)B= $fn->isa("Zuzu::Value::Function")
ABresult
0X0
100
111
454  
455 1704 return $fn;
456 }
457  
458 70100 ▶sub _env { $_[0]->{_stack}[-1] }
Subroutine _env: called CC=1 SCAR=0.0
459  
460 46478 ▶sub _var_ref_for_node {
Subroutine _var_ref_for_node: called CC=10 SCAR=24.5
461 46478 my ( $self, $node ) = @_;
462  
463 46478 my $name = $node->{name};
464 46478 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (defined $node->{"_env_depth"} and defined $node->{"_binding_name"} and $node->{"_binding_name"} eq $name) 45766 712 46478
Condition66%4/6
defined $node->{"_env_depth"} and defined $node->{"_binding_name"} and $node->{"_binding_name"} eq $name
!ll&&!rl&&r
712045766
defined $node->{"_env_depth"} and defined $node->{"_binding_name"}
!ll&&!rl&&r
712045766
MC/DC33%1/3
defined $node->{"_env_depth"} and defined $node->{"_binding_name"} and $node->{"_binding_name"} eq $name
defined $node->{"_env_depth"} defined $node->{"_binding_name"} $node->{"_binding_name"} eq $name
Truth table50%2/4
A and B and C
A= defined $node->{"_env_depth"}B= defined $node->{"_binding_name"}C= $node->{"_binding_name"} eq $name
ABCresult
0XX0
10X0
1100
1111
465 defined $node->{_env_depth}
466 and defined $node->{_binding_name}
467 and $node->{_binding_name} eq $name
468 ) {
469 45766 my $env = $self->{_stack}[-1];
470 45766 for ( 1 .. $node->{_env_depth} ) {
471 18212 ▶ last if !defined $env;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $env 0 18212 18212
472 18212 $env = $env->{parent};
473 }
474 return ( $env->{slots}{$name}, $env )
475 45766 ▶ if defined $env and exists $env->{slots}{$name};
Branch: 1 branch
BranchTrueFalseTotal
if defined $env and exists $env->{"slots"}{$name} 45766 0 45766
Condition33%1/3
defined $env and exists $env->{"slots"}{$name}
!ll&&!rl&&r
0045766
MC/DC0%0/2
defined $env and exists $env->{"slots"}{$name}
defined $env exists $env->{"slots"}{$name}
Truth table33%1/3
A and B
A= defined $envB= exists $env->{"slots"}{$name}
ABresult
0X0
100
111
476 }
477  
478 712 my $env = $self->{_stack}[-1];
479 712 ▶ while ($env) {
Branch: 1 branch
BranchTrueFalseTotal
if ($env) 1457 0 1457
480 return ( $env->{slots}{$name}, $env )
481 1457 ▶ if exists $env->{slots}{$name};
Branch: 1 branch
BranchTrueFalseTotal
if exists $env->{"slots"}{$name} 712 745 1457
482 745 $env = $env->{parent};
483 }
484  
485 0 return;
486 }
487  
488 16956 ▶sub _push_env { push @{$_[0]->{_stack}}, $_[1] }
Subroutine _push_env: called CC=1 SCAR=0.0
489  
490 16956 ▶sub _pop_env { pop @{$_[0]->{_stack}} }
Subroutine _pop_env: called CC=1 SCAR=0.0
491  
492 26036 ▶sub _capture_env {
Subroutine _capture_env: called CC=6 SCAR=18.0
493 26036 my ( $self, $env ) = @_;
494  
495 26036 ▶ return undef if !defined $env;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $env 11376 14660 26036
496  
497 14660 my $captured_parent = $self->_capture_env( $env->parent );
498 14660 my $captured = Zuzu::Env->_new_fast( $captured_parent );
499 14660 for my $name ( keys %{ $env->slots } ) {
500 $captured->alias_to_ref(
501 $name,
502 $env->slots->{$name},
503 $env->const->{$name} ? 1 : 0,
504 681858 ▶ exists $env->types->{$name} ? $env->types->{$name} : 'Any',
Branch: 2 branches
BranchTrueFalseTotal
$env->const->{$name} ? : 658764 23094 681858
exists $env->types->{$name} ? : 681858 0 681858
505 );
506 }
507 14660 for my $key ( keys %{ $env->special_props } ) {
508 0 $captured->set_special_prop( $key, $env->special_props->{$key} );
509 }
510  
511 14660 return $captured;
512 }
513  
514 0 ▶sub env_get_special_prop {
Subroutine env_get_special_prop: not called CC=2 SCAR=17.9
Pod undocumented
515 0 my ( $self, $key ) = @_;
516  
517 0 my $type = $self->_type_name( $key );
518 0 ▶ die Zuzu::Error->new_runtime(
Branch: 1 branch
BranchTrueFalseTotal
if $type ne "String" 0 0 0
519 message => "TypeException: getprop key must be String, got $type",
520 file => '<runtime>',
521 line => 0,
522 ) if $type ne 'String';
523  
524 0 return $self->_env->get_special_prop( $key );
525 }
526  
527 3 ▶sub env_set_special_prop {
Subroutine env_set_special_prop: called CC=2 SCAR=7.0
Pod undocumented
528 3 my ( $self, $key, $value ) = @_;
529  
530 3 my $type = $self->_type_name( $key );
531 3 ▶ die Zuzu::Error->new_runtime(
Branch: 1 branch
BranchTrueFalseTotal
if $type ne "String" 0 3 3
532 message => "TypeException: setprop key must be String, got $type",
533 file => '<runtime>',
534 line => 0,
535 ) if $type ne 'String';
536  
537 3 return $self->_env->set_special_prop( $key, $value );
538 }
539  
540 0 ▶sub _special_prop_env_at_level {
Subroutine _special_prop_env_at_level: not called CC=5 SCAR=34.0
541 0 my ( $self, $level, $for_name ) = @_;
542  
543 0 my $type = $self->_type_name( $level );
544 0 ▶ die Zuzu::Error->new_runtime(
Branch: 1 branch
BranchTrueFalseTotal
if $type ne "Number" 0 0 0
545 message => "TypeException: $for_name level must be Number, got $type",
546 file => '<runtime>',
547 line => 0,
548 ) if $type ne 'Number';
549  
550 0 my $int_level = int( 0 + $level );
551 0 ▶ die Zuzu::Error->new_runtime(
Branch: 1 branch
BranchTrueFalseTotal
if $int_level != $level or $int_level < 0 0 0 0
Condition0%0/3
$int_level != $level or $int_level < 0
l!l&&r!l&&!r
000
MC/DC0%0/2
$int_level != $level or $int_level < 0
$int_level != $level $int_level < 0
Truth table0%0/3
A or B
A= $int_level != $levelB= $int_level < 0
ABresult
1X1
011
000
552 message => "TypeException: $for_name level must be a non-negative integer",
553 file => '<runtime>',
554 line => 0,
555 ) if $int_level != $level or $int_level < 0;
556  
557 0 my $target_index = $#{ $self->{_stack} } - ( $int_level + 1 );
558 0 ▶ return undef if $target_index < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $target_index < 0 0 0 0
559  
560 0 return $self->{_stack}->[$target_index];
561 }
562  
563 0 ▶sub env_get_upper_special_prop {
Subroutine env_get_upper_special_prop: not called CC=3 SCAR=24.8
Pod undocumented
564 0 my ( $self, $level, $key ) = @_;
565  
566 0 my $type = $self->_type_name( $key );
567 0 ▶ die Zuzu::Error->new_runtime(
Branch: 1 branch
BranchTrueFalseTotal
if $type ne "String" 0 0 0
568 message => "TypeException: getupperprop key must be String, got $type",
569 file => '<runtime>',
570 line => 0,
571 ) if $type ne 'String';
572  
573 0 my $target_env = $self->_special_prop_env_at_level( $level, 'getupperprop' );
574 0 ▶ return undef if not defined $target_env;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $target_env 0 0 0
575  
576 0 return $target_env->get_special_prop( $key );
577 }
578  
579 0 ▶sub env_set_upper_special_prop {
Subroutine env_set_upper_special_prop: not called CC=3 SCAR=24.8
Pod undocumented
580 0 my ( $self, $level, $key, $value ) = @_;
581  
582 0 my $type = $self->_type_name( $key );
583 0 ▶ die Zuzu::Error->new_runtime(
Branch: 1 branch
BranchTrueFalseTotal
if $type ne "String" 0 0 0
584 message => "TypeException: setupperprop key must be String, got $type",
585 file => '<runtime>',
586 line => 0,
587 ) if $type ne 'String';
588  
589 0 my $target_env = $self->_special_prop_env_at_level( $level, 'setupperprop' );
590 0 ▶ return $value if not defined $target_env;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $target_env 0 0 0
591  
592 0 return $target_env->set_special_prop( $key, $value );
593 }
594  
595 553 ▶sub _normalize_policies {
Subroutine _normalize_policies: called CC=12 SCAR=36.0
596 553 my ( $self ) = @_;
597  
598 553 ▶ my @deny = grep { defined $_ and $_ ne '' } @{ $self->deny // [] };
Condition40%2/5
defined $_ && $_ ne ''
!ll&&!rl&&r
008
$self->deny // []
l!l
5530
MC/DC0%0/2
defined $_ && $_ ne ''
defined $_ $_ ne ''
MC/DC0%0/1
$self->deny // []
$self->deny
Truth table33%1/3
A && B
A= defined $_B= $_ ne ''
ABresult
0X0
100
111
Truth table50%1/2
A
A= $self->deny
Aresult
11
00
599 0 ▶ my @deny_modules = grep { defined $_ and $_ ne '' } @{ $self->deny_modules // [] };
Condition20%1/5
defined $_ && $_ ne ''
!ll&&!rl&&r
000
$self->deny_modules // []
l!l
5530
MC/DC0%0/2
defined $_ && $_ ne ''
defined $_ $_ ne ''
MC/DC0%0/1
$self->deny_modules // []
$self->deny_modules
Truth table0%0/3
A && B
A= defined $_B= $_ ne ''
ABresult
0X0
100
111
Truth table50%1/2
A
A= $self->deny_modules
Aresult
11
00
600 0 ▶ push @deny_modules, grep { defined $_ and $_ ne '' } @{ $self->forbid // [] };
Condition20%1/5
defined $_ && $_ ne ''
!ll&&!rl&&r
000
$self->forbid // []
l!l
5530
MC/DC0%0/2
defined $_ && $_ ne ''
defined $_ $_ ne ''
MC/DC0%0/1
$self->forbid // []
$self->forbid
Truth table0%0/3
A && B
A= defined $_B= $_ ne ''
ABresult
0X0
100
111
Truth table50%1/2
A
A= $self->forbid
Aresult
11
00
601 553 my @known = qw( fs net perl js proc db clib gui worker );
602 553 my %deny_set = map { $_ => 1 } @deny;
603 553 my %seen_module;
604 0 @deny_modules = grep { !$seen_module{$_}++ } @deny_modules;
605  
606 553 ▶ if ( defined $self->allow ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->allow) { } 0 553 553
607 0 ▶ my @allow = grep { defined $_ and $_ ne '' } @{ $self->allow // [] };
Condition0%0/5
defined $_ && $_ ne ''
!ll&&!rl&&r
000
$self->allow // []
l!l
00
MC/DC0%0/2
defined $_ && $_ ne ''
defined $_ $_ ne ''
MC/DC0%0/1
$self->allow // []
$self->allow
Truth table0%0/3
A && B
A= defined $_B= $_ ne ''
ABresult
0X0
100
111
Truth table0%0/2
A
A= $self->allow
Aresult
11
00
608 0 my %allow_set = map { $_ => 1 } @allow;
609 0 for my $capability ( @known ) {
610 0 ▶ next if $allow_set{$capability};
Branch: 1 branch
BranchTrueFalseTotal
if $allow_set{$capability} 0 0 0
611 0 $deny_set{$capability} = 1;
612 }
613 0 $self->allow( \@allow );
614 }
615 else {
616 553 $self->allow( undef );
617 }
618  
619 553 $self->{_deny_set} = \%deny_set;
620 553 $self->deny( \@deny );
621 553 $self->deny_modules( \@deny_modules );
622 553 $self->forbid( \@deny_modules );
623  
624 553 return;
625 }
626  
627 35357 ▶sub is_denied {
Subroutine is_denied: called CC=5 SCAR=16.7
Pod undocumented
628 35357 my ( $self, $capability ) = @_;
629  
630 35357 ▶ return 0 if !defined $capability or $capability eq '';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $capability or $capability eq "" 0 35357 35357
Condition33%1/3
not defined $capability or $capability eq ""
l!l&&r!l&&!r
0035357
MC/DC0%0/2
not defined $capability or $capability eq ""
not defined $capability $capability eq ""
Truth table33%1/3
not(A) or B
A= not defined $capabilityB= $capability eq ""
ABresult
1X1
011
000
631 35357 ▶ return 1 if $capability eq 'js';
Branch: 1 branch
BranchTrueFalseTotal
if $capability eq "js" 4177 31180 35357
632  
633 31180 ▶ return $self->{_deny_set}{$capability} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'_deny_set'}{$capability} ? : 20 31160 31180
634 }
635  
636 15 ▶sub assert_capability {
Subroutine assert_capability: called CC=5 SCAR=28.4
Pod undocumented
637 15 my ( $self, $capability, $message, $file, $line ) = @_;
638  
639 15 ▶ return if !$self->is_denied( $capability );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_denied($capability) 15 0 15
640 0 ▶ $message //= "Capability '$capability' is denied by runtime policy";
Condition0%0/2
$message //= "Capability '${capability}' is denied by runtime policy"
l!l
00
MC/DC0%0/1
$message //= "Capability '${capability}' is denied by runtime policy"
$message
Truth table0%0/2
A
A= $message
Aresult
11
00
641 0 ▶ $file //= '<runtime>';
Condition0%0/2
$file //= "<runtime>"
l!l
00
MC/DC0%0/1
$file //= "<runtime>"
$file
Truth table0%0/2
A
A= $file
Aresult
11
00
642 0 ▶ $line //= 0;
Condition0%0/2
$line //= 0
l!l
00
MC/DC0%0/1
$line //= 0
$line
Truth table0%0/2
A
A= $line
Aresult
11
00
643 0 die Zuzu::Error->new_runtime(
644 message => $message,
645 file => $file,
646 line => $line,
647 );
648 }
649  
650 547 ▶sub _install_builtins {
Subroutine _install_builtins: called CC=2 SCAR=7.3
651 547 my ($self) = @_;
652  
653 69 ▶ no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
654 my %builtin = (
655 57 ▶ say => sub {
Subroutine __ANON__: called CC=2 SCAR=7.0
656 57 ▶ my @items = map { defined($_) ? $self->_to_String($_) : '' } @_;
Branch: 1 branch
BranchTrueFalseTotal
defined $_ ? : 57 0 57
657 57 print STDOUT join( '', @items ), "\n";
658 57 return undef;
659 },
660 114 ▶ print => sub {
Subroutine __ANON__: called CC=2 SCAR=7.0
661 114 ▶ my @items = map { defined($_) ? $self->_to_String($_) : '' } @_;
Branch: 1 branch
BranchTrueFalseTotal
defined $_ ? : 114 0 114
662 114 print STDOUT join( '', @items );
663 114 return undef;
664 },
665 0 ▶ warn => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
666 0 ▶ my @items = map { defined($_) ? $self->_to_String($_) : '' } @_;
Branch: 1 branch
BranchTrueFalseTotal
defined $_ ? : 0 0 0
667 0 print STDERR join( '', @items ), "\n";
668 0 return undef;
669 },
670 0 ▶ typeof => sub { $self->_type_name($_[0]) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
671 32 ▶ to_binary => sub {
Subroutine __ANON__: called CC=2 SCAR=7.0
672 32 my ( $value ) = @_;
673 32 my $type = $self->_type_name( $value );
674 32 ▶ die Zuzu::Error->new_runtime(
Branch: 1 branch
BranchTrueFalseTotal
if $type ne "String" 0 32 32
675 message => "TypeException: to_binary expects String, got $type",
676 file => '<runtime>',
677 line => 0,
678 ) if $type ne 'String';
679  
680 32 return Zuzu::Value::BinaryString->from_utf8_string( $value );
681 },
682 14 ▶ to_string => sub {
Subroutine __ANON__: called CC=2 SCAR=7.0
683 14 my ( $value ) = @_;
684 14 my $type = $self->_type_name( $value );
685 14 ▶ die Zuzu::Error->new_runtime(
Branch: 1 branch
BranchTrueFalseTotal
if $type ne "BinaryString" 0 14 14
686 message => "TypeException: to_string expects BinaryString, got $type",
687 file => '<runtime>',
688 line => 0,
689 ) if $type ne 'BinaryString';
690  
691 14 return $value->to_utf8_string;
692 },
693 547 );
694  
695 547 for my $k (keys %builtin) {
696 3282 my $fn = Zuzu::Value::Function->new(
697 name => $k,
698 params => [],
699 vararg => '__args',
700 body => undef,
701 closure_env => undef,
702 );
703 3282 $fn->{_native} = $builtin{$k};
704 3282 $self->{_global}->declare($k, $fn, 1);
705 3282 $self->{_builtin_global_names}{$k} = 1;
706 }
707  
708 547 $self->_install_builtin_classes;
709 }
710  
711 547 ▶sub _install_special_globals {
Subroutine _install_special_globals: called CC=2 SCAR=6.9
712 547 my ( $self ) = @_;
713  
714 my $system = Zuzu::Value::Dict->new(
715 map => {
716 language_version => 0,
717 runtime => 'Zuzu::Runtime',
718 runtime_version => $Zuzu::Runtime::VERSION,
719 perl_version => sprintf( '%.6f', $] ),
720 platform => $^O,
721 inc => Zuzu::Value::Array->new(
722 547 ▶ items => [ @{ $self->lib // [] } ],
Condition50%1/2
$self->lib // []
l!l
5470
MC/DC0%0/1
$self->lib // []
$self->lib
Truth table50%1/2
A
A= $self->lib
Aresult
11
00
723 ),
724 deny_fs => _boolify( $self->is_denied( 'fs' ) ),
725 deny_net => _boolify( $self->is_denied( 'net' ) ),
726 deny_perl => _boolify( $self->is_denied( 'perl' ) ),
727 deny_js => _boolify( $self->is_denied( 'js' ) ),
728 deny_proc => _boolify( $self->is_denied( 'proc' ) ),
729 deny_db => _boolify( $self->is_denied( 'db' ) ),
730 deny_clib => _boolify( $self->is_denied( 'clib' ) ),
731 deny_gui => _boolify( $self->is_denied( 'gui' ) ),
732 deny_worker => _boolify( $self->is_denied( 'worker' ) ),
733 },
734 );
735 547 $self->_protect_system_value( $system );
736 547 $self->{_global}->declare( '__system__', $system, 1 );
737 547 $self->{_builtin_global_names}{'__system__'} = 1;
738  
739 547 my $global = Zuzu::Value::Dict->new( map => {} );
740 547 $self->{_global}->declare( '__global__', $global, 0 );
741 547 $self->{_builtin_global_names}{'__global__'} = 1;
742  
743 547 $self->{_global}->declare( 'DEBUG', 0 + $Zuzu::Runtime::DEBUG_LEVEL, 1 );
744 547 $self->{_builtin_global_names}{'DEBUG'} = 1;
745  
746 547 return;
747 }
748  
749 12 ▶sub _sync_system_policy_flags {
Subroutine _sync_system_policy_flags: called CC=5 SCAR=16.4
750 12 my ( $self ) = @_;
751  
752 12 my $global = $self->{_global};
753 12 ▶ return if !defined $global;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $global 0 12 12
754 12 my $system_ref = $global->find_ref( '__system__' );
755 12 ▶ return if !defined $system_ref;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $system_ref 0 12 12
756 12 my $system = ${ $system_ref };
757 12 ▶ return if !blessed( $system ) or !$system->isa( 'Zuzu::Value::Dict' );
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($system) and $system->isa("Zuzu::Value::Dict") 0 12 12
Condition33%1/3
builtin::blessed($system) and $system->isa("Zuzu::Value::Dict")
!ll&&!rl&&r
0012
MC/DC0%0/2
builtin::blessed($system) and $system->isa("Zuzu::Value::Dict")
builtin::blessed($system) $system->isa("Zuzu::Value::Dict")
Truth table33%1/3
A and B
A= builtin::blessed($system)B= $system->isa("Zuzu::Value::Dict")
ABresult
0X0
100
111
758  
759 12 $system->map->{deny_fs} = _boolify( $self->is_denied( 'fs' ) );
760 12 $system->map->{deny_net} = _boolify( $self->is_denied( 'net' ) );
761 12 $system->map->{deny_perl} = _boolify( $self->is_denied( 'perl' ) );
762 12 $system->map->{deny_js} = _boolify( $self->is_denied( 'js' ) );
763 12 $system->map->{deny_proc} = _boolify( $self->is_denied( 'proc' ) );
764 12 $system->map->{deny_db} = _boolify( $self->is_denied( 'db' ) );
765 12 $system->map->{deny_clib} = _boolify( $self->is_denied( 'clib' ) );
766 12 $system->map->{deny_gui} = _boolify( $self->is_denied( 'gui' ) );
767 12 $system->map->{deny_worker} = _boolify( $self->is_denied( 'worker' ) );
768  
769 12 return;
770 }
771  
772 9518 ▶sub _protect_system_value {
Subroutine _protect_system_value: called CC=14 SCAR=28.9
773 9518 my ( $self, $value ) = @_;
774  
775 9518 ▶ return if !blessed $value;
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($value) 3501 6017 9518
776  
777 6017 my $addr = refaddr( $value );
778 6017 ▶ return if !$addr or $self->{_system_readonly_refs}{$addr};
Branch: 1 branch
BranchTrueFalseTotal
if not $addr or $self->{"_system_readonly_refs"}{$addr} 3829 2188 6017
Condition66%2/3
not $addr or $self->{"_system_readonly_refs"}{$addr}
l!l&&r!l&&!r
038292188
MC/DC50%1/2
not $addr or $self->{"_system_readonly_refs"}{$addr}
not $addr $self->{"_system_readonly_refs"}{$addr}
Truth table66%2/3
not(A) or B
A= not $addrB= $self->{"_system_readonly_refs"}{$addr}
ABresult
1X1
011
000
779 2188 $self->{_system_readonly_refs}{$addr} = 1;
780  
781 2188 ▶ if ( $value->isa( 'Zuzu::Value::Dict' ) ) {
Branch: 4 branches
BranchTrueFalseTotal
if ($value->isa('Zuzu::Value::Dict')) { } 547 1641 2188
elsif ($value->isa('Zuzu::Value::Array') or $value->isa('Zuzu::Value::Set') or $value->isa('Zuzu::Value::Bag')) { } 547 1094 1641
elsif ($value->isa('Zuzu::Value::PairList')) { } 0 1094 1094
elsif ($value->isa('Zuzu::Value::Object')) { } 0 1094 1094
782 547 for my $key ( CORE::keys %{ $value->map } ) {
783 8205 $self->_protect_system_value( $value->map->{$key} );
784 }
785 }
786 ▶ elsif ( $value->isa( 'Zuzu::Value::Array' ) or $value->isa( 'Zuzu::Value::Set' ) or $value->isa( 'Zuzu::Value::Bag' ) ) {
Condition66%4/6
$value->isa("Zuzu::Value::Array") or $value->isa("Zuzu::Value::Set") or $value->isa("Zuzu::Value::Bag")
l!l&&r!l&&!r
54701094
$value->isa("Zuzu::Value::Array") or $value->isa("Zuzu::Value::Set")
l!l&&r!l&&!r
54701094
MC/DC33%1/3
$value->isa("Zuzu::Value::Array") or $value->isa("Zuzu::Value::Set") or $value->isa("Zuzu::Value::Bag")
$value->isa("Zuzu::Value::Array") $value->isa("Zuzu::Value::Set") $value->isa("Zuzu::Value::Bag")
Truth table50%2/4
A or B or C
A= $value->isa("Zuzu::Value::Array")B= $value->isa("Zuzu::Value::Set")C= $value->isa("Zuzu::Value::Bag")
ABCresult
1XX1
01X1
0011
0000
787 547 for my $item ( @{ $value->items } ) {
788 766 $self->_protect_system_value( $item );
789 }
790 }
791 elsif ( $value->isa( 'Zuzu::Value::PairList' ) ) {
792 0 for my $pair ( @{ $value->list } ) {
793 0 $self->_protect_system_value( $pair->[1] );
794 }
795 }
796 elsif ( $value->isa( 'Zuzu::Value::Object' ) ) {
797 0 for my $slot ( CORE::keys %{ $value->slots } ) {
798 0 $self->_protect_system_value( $value->slots->{$slot} );
799 }
800 }
801  
802 2188 return;
803 }
804  
805 8075 ▶sub _is_system_protected_ref {
Subroutine _is_system_protected_ref: called CC=4 SCAR=14.1
806 8075 my ( $self, $value ) = @_;
807  
808 8075 ▶ return 0 if !blessed $value;
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($value) 0 8075 8075
809 8075 my $addr = refaddr( $value );
810 8075 ▶ return 0 if !$addr;
Branch: 1 branch
BranchTrueFalseTotal
unless $addr 0 8075 8075
811  
812 8075 ▶ return $self->{_system_readonly_refs}{$addr} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'_system_readonly_refs'}{$addr} ? : 3 8072 8075
813 }
814  
815 8075 ▶sub _assert_mutable_collection {
Subroutine _assert_mutable_collection: called CC=2 SCAR=6.9
816 8075 my ( $self, $value, $file, $line ) = @_;
817  
818 8075 ▶ return if !$self->_is_system_protected_ref( $value );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_is_system_protected_ref($value) 8072 3 8075
819 3 die Zuzu::Error->new_runtime(
820 message => "Cannot modify __system__",
821 file => $file,
822 line => $line,
823 );
824 }
825  
826 547 ▶sub _install_builtin_classes {
Subroutine _install_builtin_classes: called CC=4 SCAR=16.2
827 547 my ( $self ) = @_;
828  
829 547 my %classes;
830 547 my @specs = (
831 [ 'Any', undef, undef ],
832 [ 'Null', 'Any', undef ],
833 [ 'Boolean', 'Any', undef ],
834 [ 'Number', 'Any', undef ],
835 [ 'String', 'Any', undef ],
836 [ 'BinaryString', 'Any', undef ],
837 [ 'Task', 'Any', undef ],
838 [ 'Object', 'Any', undef ],
839 [ 'Collection', 'Object', undef ],
840 [ 'Array', 'Collection', 'Array' ],
841 [ 'Set', 'Collection', 'Set' ],
842 [ 'Dict', 'Collection', 'Dict' ],
843 [ 'PairList', 'Collection', 'PairList' ],
844 [ 'Bag', 'Collection', 'Bag' ],
845 [ 'Exception', 'Object', 'Exception' ],
846 [ 'TypeException', 'Exception', 'Exception' ],
847 [ 'AssertionException', 'Exception', 'Exception' ],
848 [ 'ExhaustedException', 'Exception', 'Exception' ],
849 [ 'CancelledException', 'Exception', 'Exception' ],
850 [ 'TimeoutException', 'CancelledException', 'Exception' ],
851 [ 'ChannelClosedException', 'Exception', 'Exception' ],
852 [ 'Pair', 'Object', 'Pair' ],
853 [ 'Regexp', 'Object', undef ],
854 [ 'Function', 'Any', undef ],
855 [ 'Trait', 'Any', undef ],
856 [ 'Class', 'Any', undef ],
857 );
858  
859 547 for my $spec ( @specs ) {
860 14222 my ( $name, $parent_name, $kind ) = @{ $spec };
861 my $klass = Zuzu::Value::Class->new(
862 name => $name,
863 parent => ( defined $parent_name ? $classes{ $parent_name } : undef ),
864 traits => [],
865 field_specs => [],
866 methods => {},
867 trait_methods => {},
868 static_methods => {},
869 nested_classes => {},
870 closure_env => $self->{_global},
871 14222 ▶ builtin_kind => $kind,
Branch: 1 branch
BranchTrueFalseTotal
defined $parent_name ? : 13675 547 14222
872 );
873 14222 $classes{ $name } = $klass;
874 }
875  
876 9 ▶ $classes{Exception}->native_constructor( sub {
Subroutine __ANON__: called CC=3 SCAR=11.4
877 9 my ( $runtime, $klass, $positional, $named, $file, $line ) = @_;
878 9 ▶ my $message = exists $named->{message} ? $named->{message} : $positional->[0];
Branch: 1 branch
BranchTrueFalseTotal
exists $named->{'message'} ? : 9 0 9
879 9 ▶ $message = 'Died' if !defined $message;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $message 0 9 9
880  
881 9 return $runtime->_instantiate_builtin_object(
882 $klass,
883 {
884 message => $message,
885 file => $file,
886 line => $line,
887 },
888 );
889 547 } );
890 547 $classes{Exception}->methods->{to_String} = Zuzu::Value::Function->new(
891 name => 'to_String',
892 params => [],
893 vararg => undef,
894 body => undef,
895 closure_env => undef,
896 );
897 12 ▶ $classes{Exception}->methods->{to_String}{_native} = sub {
Subroutine __ANON__: called CC=6 SCAR=18.7
898 12 my ( $self_obj ) = @_;
899 12 ▶ my $class = $self_obj->class ? $self_obj->class->name : 'Exception';
Branch: 1 branch
BranchTrueFalseTotal
$self_obj->class ? : 12 0 12
900 12 ▶ my $message = $self_obj->slots->{message} // '';
Condition50%1/2
$self_obj->slots->{"message"} // ""
l!l
120
MC/DC0%0/1
$self_obj->slots->{"message"} // ""
$self_obj->slots->{"message"}
Truth table50%1/2
A
A= $self_obj->slots->{"message"}
Aresult
11
00
901 12 ▶ return $message
Branch: 1 branch
BranchTrueFalseTotal
if $message eq $class or $message =~ /\A\Q$class\E:/ 2 10 12
Condition66%2/3
$message eq $class or $message =~ /\A\Q$class\E:/
l!l&&r!l&&!r
0210
MC/DC50%1/2
$message eq $class or $message =~ /\A\Q$class\E:/
$message eq $class $message =~ /\A\Q$class\E:/
Truth table66%2/3
A or B
A= $message eq $classB= $message =~ /\A\Q$class\E:/
ABresult
1X1
011
000
902 if $message eq $class or $message =~ /\A\Q$class\E:/;
903 10 ▶ return $class if $message eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $message eq "" 0 10 10
904 10 return "$class: $message";
905 547 };
906 547 $classes{Exception}->methods->{to_String}{_owner_class} = $classes{Exception};
907 547 $classes{Exception}->methods->{to_String}{_method_name} = 'to_String';
908 547 $classes{Exception}->methods->{to_String}{_method_kind} = 'instance';
909 547 $classes{Exception}->methods->{message} = Zuzu::Value::Function->new(
910 name => 'message',
911 params => [],
912 vararg => undef,
913 body => undef,
914 closure_env => undef,
915 );
916 1 ▶ $classes{Exception}->methods->{message}{_native} = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
917 1 my ( $self_obj ) = @_;
918 1 return $self_obj->slots->{message};
919 547 };
920 547 $classes{Exception}->methods->{message}{_owner_class} = $classes{Exception};
921 547 $classes{Exception}->methods->{message}{_method_name} = 'message';
922 547 $classes{Exception}->methods->{message}{_method_kind} = 'instance';
923  
924 1 ▶ $classes{Array}->native_constructor( sub {
Subroutine __ANON__: called CC=5 SCAR=19.7
925 1 my ( $runtime, $klass, $positional, $named ) = @_;
926 1 ▶ my @items = @{ $positional // [] };
Condition50%1/2
$positional // []
l!l
10
MC/DC0%0/1
$positional // []
$positional
Truth table50%1/2
A
A= $positional
Aresult
11
00
927 1 ▶ if ( exists $named->{items} and blessed($named->{items}) and $named->{items}->isa('Zuzu::Value::Array') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $named->{"items"} and builtin::blessed($named->{"items"}) and $named->{"items"}->isa("Zuzu::Value::Array")) 0 1 1
Condition33%2/6
exists $named->{"items"} and builtin::blessed($named->{"items"}) and $named->{"items"}->isa("Zuzu::Value::Array")
!ll&&!rl&&r
100
exists $named->{"items"} and builtin::blessed($named->{"items"})
!ll&&!rl&&r
100
MC/DC0%0/3
exists $named->{"items"} and builtin::blessed($named->{"items"}) and $named->{"items"}->isa("Zuzu::Value::Array")
exists $named->{"items"} builtin::blessed($named->{"items"}) $named->{"items"}->isa("Zuzu::Value::Array")
Truth table25%1/4
A and B and C
A= exists $named->{"items"}B= builtin::blessed($named->{"items"})C= $named->{"items"}->isa("Zuzu::Value::Array")
ABCresult
0XX0
10X0
1100
1111
928 0 @items = @{ $named->{items}->items };
929 }
930 1 my $array = Zuzu::Value::Array->new( items => \@items );
931  
932 1 return $runtime->_wrap_builtin_if_needed( $klass, $array, 'Array' );
933 547 } );
934  
935 0 ▶ $classes{Set}->native_constructor( sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
936 0 my ( $runtime, $klass, $positional, $named ) = @_;
937 0 ▶ my @items = @{ $positional // [] };
Condition0%0/2
$positional // []
l!l
00
MC/DC0%0/1
$positional // []
$positional
Truth table0%0/2
A
A= $positional
Aresult
11
00
938 0 ▶ if ( exists $named->{items} and blessed($named->{items}) and $named->{items}->isa('Zuzu::Value::Array') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $named->{"items"} and builtin::blessed($named->{"items"}) and $named->{"items"}->isa("Zuzu::Value::Array")) 0 0 0
Condition0%0/6
exists $named->{"items"} and builtin::blessed($named->{"items"}) and $named->{"items"}->isa("Zuzu::Value::Array")
!ll&&!rl&&r
000
exists $named->{"items"} and builtin::blessed($named->{"items"})
!ll&&!rl&&r
000
MC/DC0%0/3
exists $named->{"items"} and builtin::blessed($named->{"items"}) and $named->{"items"}->isa("Zuzu::Value::Array")
exists $named->{"items"} builtin::blessed($named->{"items"}) $named->{"items"}->isa("Zuzu::Value::Array")
Truth table0%0/4
A and B and C
A= exists $named->{"items"}B= builtin::blessed($named->{"items"})C= $named->{"items"}->isa("Zuzu::Value::Array")
ABCresult
0XX0
10X0
1100
1111
939 0 @items = @{ $named->{items}->items };
940 }
941 0 my $set = Zuzu::Value::Set->new( items => [] );
942 0 $set->add( @items );
943  
944 0 return $runtime->_wrap_builtin_if_needed( $klass, $set, 'Set' );
945 547 } );
946  
947 1 ▶ $classes{Bag}->native_constructor( sub {
Subroutine __ANON__: called CC=5 SCAR=19.7
948 1 my ( $runtime, $klass, $positional, $named ) = @_;
949 1 ▶ my @items = @{ $positional // [] };
Condition50%1/2
$positional // []
l!l
10
MC/DC0%0/1
$positional // []
$positional
Truth table50%1/2
A
A= $positional
Aresult
11
00
950 1 ▶ if ( exists $named->{items} and blessed($named->{items}) and $named->{items}->isa('Zuzu::Value::Array') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $named->{"items"} and builtin::blessed($named->{"items"}) and $named->{"items"}->isa("Zuzu::Value::Array")) 0 1 1
Condition33%2/6
exists $named->{"items"} and builtin::blessed($named->{"items"}) and $named->{"items"}->isa("Zuzu::Value::Array")
!ll&&!rl&&r
100
exists $named->{"items"} and builtin::blessed($named->{"items"})
!ll&&!rl&&r
100
MC/DC0%0/3
exists $named->{"items"} and builtin::blessed($named->{"items"}) and $named->{"items"}->isa("Zuzu::Value::Array")
exists $named->{"items"} builtin::blessed($named->{"items"}) $named->{"items"}->isa("Zuzu::Value::Array")
Truth table25%1/4
A and B and C
A= exists $named->{"items"}B= builtin::blessed($named->{"items"})C= $named->{"items"}->isa("Zuzu::Value::Array")
ABCresult
0XX0
10X0
1100
1111
951 0 @items = @{ $named->{items}->items };
952 }
953 1 my $bag = Zuzu::Value::Bag->new( items => \@items );
954  
955 1 return $runtime->_wrap_builtin_if_needed( $klass, $bag, 'Bag' );
956 547 } );
957  
958 0 ▶ $classes{Dict}->native_constructor( sub {
Subroutine __ANON__: not called CC=7 SCAR=40.3
959 0 my ( $runtime, $klass, $positional, $named, $file, $line ) = @_;
960 0 my %map;
961 0 ▶ for my $pair ( @{ $positional // [] } ) {
Condition0%0/2
$positional // []
l!l
00
MC/DC0%0/1
$positional // []
$positional
Truth table0%0/2
A
A= $positional
Aresult
11
00
962 0 my $normalized = $runtime->_normalize_pair_argument( $pair, $file, $line );
963 0 my ( $k, $v ) = @{ $normalized };
964 0 $map{$k} = $v;
965 }
966 0 ▶ if ( exists $named->{pairs} and blessed($named->{pairs}) and $named->{pairs}->isa('Zuzu::Value::Array') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $named->{"pairs"} and builtin::blessed($named->{"pairs"}) and $named->{"pairs"}->isa("Zuzu::Value::Array")) 0 0 0
Condition0%0/6
exists $named->{"pairs"} and builtin::blessed($named->{"pairs"}) and $named->{"pairs"}->isa("Zuzu::Value::Array")
!ll&&!rl&&r
000
exists $named->{"pairs"} and builtin::blessed($named->{"pairs"})
!ll&&!rl&&r
000
MC/DC0%0/3
exists $named->{"pairs"} and builtin::blessed($named->{"pairs"}) and $named->{"pairs"}->isa("Zuzu::Value::Array")
exists $named->{"pairs"} builtin::blessed($named->{"pairs"}) $named->{"pairs"}->isa("Zuzu::Value::Array")
Truth table0%0/4
A and B and C
A= exists $named->{"pairs"}B= builtin::blessed($named->{"pairs"})C= $named->{"pairs"}->isa("Zuzu::Value::Array")
ABCresult
0XX0
10X0
1100
1111
967 0 for my $pair ( @{ $named->{pairs}->items } ) {
968 0 my $normalized = $runtime->_normalize_pair_argument( $pair, $file, $line );
969 0 my ( $k, $v ) = @{ $normalized };
970 0 $map{$k} = $v;
971 }
972 }
973 0 my $dict = Zuzu::Value::Dict->new( map => \%map );
974  
975 0 return $runtime->_wrap_builtin_if_needed( $klass, $dict, 'Dict' );
976 547 } );
977  
978 10 ▶ $classes{PairList}->native_constructor( sub {
Subroutine __ANON__: called CC=7 SCAR=20.2
979 10 my ( $runtime, $klass, $positional, $named, $file, $line ) = @_;
980 10 my @list;
981 10 ▶ for my $pair ( @{ $positional // [] } ) {
Condition50%1/2
$positional // []
l!l
100
MC/DC0%0/1
$positional // []
$positional
Truth table50%1/2
A
A= $positional
Aresult
11
00
982 0 my $normalized = $runtime->_normalize_pair_argument( $pair, $file, $line, 'PairList' );
983 0 push @list, $normalized;
984 }
985 10 ▶ if ( exists $named->{list} and blessed($named->{list}) and $named->{list}->isa('Zuzu::Value::Array') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $named->{"list"} and builtin::blessed($named->{"list"}) and $named->{"list"}->isa("Zuzu::Value::Array")) 1 9 10
Condition66%4/6
exists $named->{"list"} and builtin::blessed($named->{"list"}) and $named->{"list"}->isa("Zuzu::Value::Array")
!ll&&!rl&&r
901
exists $named->{"list"} and builtin::blessed($named->{"list"})
!ll&&!rl&&r
901
MC/DC33%1/3
exists $named->{"list"} and builtin::blessed($named->{"list"}) and $named->{"list"}->isa("Zuzu::Value::Array")
exists $named->{"list"} builtin::blessed($named->{"list"}) $named->{"list"}->isa("Zuzu::Value::Array")
Truth table50%2/4
A and B and C
A= exists $named->{"list"}B= builtin::blessed($named->{"list"})C= $named->{"list"}->isa("Zuzu::Value::Array")
ABCresult
0XX0
10X0
1100
1111
986 1 for my $pair ( @{ $named->{list}->items } ) {
987 3 my $normalized = $runtime->_normalize_pair_argument( $pair, $file, $line, 'PairList' );
988 3 push @list, $normalized;
989 }
990 }
991 10 my $pairlist = Zuzu::Value::PairList->new( list => \@list );
992  
993 10 return $runtime->_wrap_builtin_if_needed( $klass, $pairlist, 'PairList' );
994 547 } );
995  
996 3 ▶ $classes{Pair}->native_constructor( sub {
Subroutine __ANON__: called CC=5 SCAR=17.6
997 3 my ( $runtime, $klass, $positional, $named ) = @_;
998 3 ▶ my $pair = exists $named->{pair} ? $named->{pair} : $positional->[0];
Branch: 1 branch
BranchTrueFalseTotal
exists $named->{'pair'} ? : 3 0 3
999 3 ▶ if ( blessed($pair) and $pair->isa('Zuzu::Value::Array') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($pair) and $pair->isa("Zuzu::Value::Array")) 3 0 3
Condition33%1/3
builtin::blessed($pair) and $pair->isa("Zuzu::Value::Array")
!ll&&!rl&&r
003
MC/DC0%0/2
builtin::blessed($pair) and $pair->isa("Zuzu::Value::Array")
builtin::blessed($pair) $pair->isa("Zuzu::Value::Array")
Truth table33%1/3
A and B
A= builtin::blessed($pair)B= $pair->isa("Zuzu::Value::Array")
ABresult
0X0
100
111
1000 3 $pair = [ @{ $pair->items } ];
1001 }
1002 3 ▶ if ( ref($pair) ne 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $pair ne "ARRAY") 0 3 3
1003 0 $pair = [ undef, undef ];
1004 }
1005 3 my $pair_value = Zuzu::Value::Array->new( items => [ @{ $pair } ] );
1006 3 return $runtime->_instantiate_builtin_object(
1007 $klass,
1008 {
1009 pair => $pair_value,
1010 },
1011 );
1012 547 } );
1013  
1014 547 $classes{Pair}->methods->{key} = Zuzu::Value::Function->new(
1015 name => 'key',
1016 params => [],
1017 vararg => undef,
1018 body => undef,
1019 closure_env => undef,
1020 );
1021 3 ▶ $classes{Pair}->methods->{key}{_native} = sub {
Subroutine __ANON__: called CC=3 SCAR=12.0
1022 3 my ( $self_obj ) = @_;
1023 3 my $pair = $self_obj->slots->{pair};
1024  
1025 3 ▶ return undef if !blessed($pair) or !$pair->isa('Zuzu::Value::Array');
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($pair) and $pair->isa("Zuzu::Value::Array") 0 3 3
Condition33%1/3
builtin::blessed($pair) and $pair->isa("Zuzu::Value::Array")
!ll&&!rl&&r
003
MC/DC0%0/2
builtin::blessed($pair) and $pair->isa("Zuzu::Value::Array")
builtin::blessed($pair) $pair->isa("Zuzu::Value::Array")
Truth table33%1/3
A and B
A= builtin::blessed($pair)B= $pair->isa("Zuzu::Value::Array")
ABresult
0X0
100
111
1026 3 return $pair->items->[0];
1027 547 };
1028 547 $classes{Pair}->methods->{key}{_owner_class} = $classes{Pair};
1029 547 $classes{Pair}->methods->{key}{_method_name} = 'key';
1030 547 $classes{Pair}->methods->{key}{_method_kind} = 'instance';
1031  
1032 547 $classes{Pair}->methods->{value} = Zuzu::Value::Function->new(
1033 name => 'value',
1034 params => [],
1035 vararg => undef,
1036 body => undef,
1037 closure_env => undef,
1038 );
1039 1 ▶ $classes{Pair}->methods->{value}{_native} = sub {
Subroutine __ANON__: called CC=3 SCAR=12.0
1040 1 my ( $self_obj ) = @_;
1041 1 my $pair = $self_obj->slots->{pair};
1042  
1043 1 ▶ return undef if !blessed($pair) or !$pair->isa('Zuzu::Value::Array');
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($pair) and $pair->isa("Zuzu::Value::Array") 0 1 1
Condition33%1/3
builtin::blessed($pair) and $pair->isa("Zuzu::Value::Array")
!ll&&!rl&&r
001
MC/DC0%0/2
builtin::blessed($pair) and $pair->isa("Zuzu::Value::Array")
builtin::blessed($pair) $pair->isa("Zuzu::Value::Array")
Truth table33%1/3
A and B
A= builtin::blessed($pair)B= $pair->isa("Zuzu::Value::Array")
ABresult
0X0
100
111
1044 1 return $pair->items->[1];
1045 547 };
1046 547 $classes{Pair}->methods->{value}{_owner_class} = $classes{Pair};
1047 547 $classes{Pair}->methods->{value}{_method_name} = 'value';
1048 547 $classes{Pair}->methods->{value}{_method_kind} = 'instance';
1049  
1050 547 $self->{_builtin_classes} = \%classes;
1051 547 for my $name ( sort CORE::keys %classes ) {
1052 14222 $self->{_global}->declare( $name, $classes{$name}, 1 );
1053 14222 $self->{_builtin_global_names}{$name} = 1;
1054 }
1055 }
1056  
1057 # === AST evaluators ===
1058  
1059 1364 ▶sub eval_program {
Subroutine eval_program: called CC=2 SCAR=6.9
Pod documented
1060 1364 my ($self, $node) = @_;
1061  
1062 1364 my $v;
1063 1364 for my $s (@{$node->statements}) { $v = $s->evaluate($self); }
1064  
1065 1311 return $v;
1066 }
1067  
1068 119955 ▶sub eval_block {
Subroutine eval_block: called CC=5 SCAR=16.1
Pod documented
1069 119955 my ($self, $node) = @_;
1070  
1071 119955 my $v;
1072 119955 ▶ if ( $node->{reuse_current_env} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->{"reuse_current_env"}) 75188 44767 119955
1073 75188 for ( @{ $node->{statements} } ) { $v = $_->evaluate($self); }
1074 22457 return $v;
1075 }
1076  
1077 44767 my $env = Zuzu::Env->_new_fast( $self->{_stack}[-1] ); # inlined $self->_env
1078 44767 push @{$self->{_stack}}, $env; # inlined $self->_push_env
1079 eval {
1080 44767 for ( @{ $node->{statements} } ) { $v = $_->evaluate($self); }
1081 23520 1;
1082 44767 ▶ } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { foreach $_ (@{$$node{"statements"};}) { $v = $_->evaluate($self); } ; 1 } } or do { my $e = $@; pop @{$$self{"_stack"};}; die $e } 23520 21247 44767
1083 21247 my $e = $@;
1084 21247 pop @{$self->{_stack}}; # inlined $self->_pop_env
1085 21247 die $e;
1086 };
1087 23520 pop @{$self->{_stack}}; # inlined $self->_pop_env
1088  
1089 23520 return $v;
1090 }
1091  
1092 189 ▶sub _new_task {
Subroutine _new_task: called CC=18 SCAR=33.1
1093 189 my ( $self, %args ) = @_;
1094  
1095 my $task = Zuzu::Value::Task->new(
1096 name => $args{name} // '<task>',
1097 thunk => $args{thunk},
1098 status => $args{status} // 'pending',
1099 result => $args{result},
1100 error => $args{error},
1101 pid => $args{pid},
1102 reader => $args{reader},
1103 ready_at => $args{ready_at},
1104 poll_cb => $args{poll_cb},
1105 on_cancel => $args{on_cancel},
1106 cancel_reason => $args{cancel_reason},
1107 file => $args{file} // $self->{_native_call_file} // '<runtime>',
1108 line => $args{line} // $self->{_native_call_line} // 0,
1109 189 ▶ runtime_stack => [ @{ $args{runtime_stack} // $self->{_stack} } ],
Condition58%10/17
$args{"name"} // "<task>"
l!l
1890
$args{"status"} // "pending"
l!l
76113
($args{"file"} // $self->{"_native_call_file"}) // "<runtime>"
l!l
1890
$args{"file"} // $self->{"_native_call_file"}
l!l&&r!l&&!r
681210
($args{"line"} // $self->{"_native_call_line"}) // 0
l!l
1890
$args{"line"} // $self->{"_native_call_line"}
l!l&&r!l&&!r
681210
$args{"runtime_stack"} // $self->{"_stack"}
l!l&&r!l&&!r
01890
MC/DC0%0/1
$args{"name"} // "<task>"
$args{"name"}
MC/DC100%1/1
$args{"status"} // "pending"
$args{"status"}
MC/DC0%0/2
($args{"file"} // $self->{"_native_call_file"}) // "<runtime>"
$args{"file"} $self->{"_native_call_file"}
MC/DC0%0/2
($args{"line"} // $self->{"_native_call_line"}) // 0
$args{"line"} $self->{"_native_call_line"}
MC/DC0%0/2
$args{"runtime_stack"} // $self->{"_stack"}
$args{"runtime_stack"} $self->{"_stack"}
Truth table50%1/2
A
A= $args{"name"}
Aresult
11
00
Truth table100%2/2
A
A= $args{"status"}
Aresult
11
00
Truth table66%2/3
A // B
A= $args{"file"}B= $self->{"_native_call_file"}
ABresult
1X1
011
000
Truth table66%2/3
A // B
A= $args{"line"}B= $self->{"_native_call_line"}
ABresult
1X1
011
000
Truth table33%1/3
A // B
A= $args{"runtime_stack"}B= $self->{"_stack"}
ABresult
1X1
011
000
1110 );
1111 189 my $scheduler = $self->{_scheduler};
1112 189 ▶ $task->scheduler($scheduler) if defined $scheduler and !$args{process};
Branch: 1 branch
BranchTrueFalseTotal
if defined $scheduler and not $args{"process"} 189 0 189
Condition33%1/3
defined $scheduler and not $args{"process"}
!ll&&!rl&&r
00189
MC/DC0%0/2
defined $scheduler and not $args{"process"}
defined $scheduler not $args{"process"}
Truth table33%1/3
A and not(B)
A= defined $schedulerB= not $args{"process"}
ABresult
0X0
100
111
1113 189 ▶ if ( defined $args{group} ) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $args{'group'}) { } 15 174 189
elsif (defined $scheduler) { } 174 0 174
1114 15 $task->group( $args{group} );
1115 }
1116 elsif ( defined $scheduler ) {
1117 174 $task->group( $scheduler->current_group );
1118 }
1119 189 ▶ $task->start if $args{start};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"start"} 11 178 189
1120 $scheduler->schedule( $task, $task->group )
1121 if defined $scheduler
1122 and !$args{process}
1123 189 ▶ and ( $args{schedule} or ( $task->status // '' ) eq 'pending' );
Branch: 1 branch
BranchTrueFalseTotal
if defined $scheduler and not $args{"process"} and $args{"schedule"} || ($task->status // "") eq "pending" 113 76 189
Condition54%6/11
defined $scheduler and not $args{"process"} and $args{"schedule"} || ($task->status // "") eq "pending"
!ll&&!rl&&r
076113
defined $scheduler and not $args{"process"}
!ll&&!rl&&r
00189
$args{"schedule"} or ($task->status // "") eq "pending"
l!l&&r!l&&!r
113076
$task->status // ""
l!l
760
MC/DC0%0/4
defined $scheduler and not $args{"process"} and $args{"schedule"} || ($task->status // "") eq "pending"
defined $scheduler not $args{"process"} $args{"schedule"} $task->status
Truth table40%2/5
A and not(B) and C or D
A= defined $schedulerB= not $args{"process"}C= $args{"schedule"}D= $task->status
ABCDresult
0XXX0
10XX0
11000
111X1
11011
1124  
1125 189 return $task;
1126 }
1127  
1128 24 ▶sub _warn_blocking_operation {
Subroutine _warn_blocking_operation: called CC=9 SCAR=23.6
1129 24 my ( $self, $operation, $file, $line ) = @_;
1130  
1131 24 my $scheduler = $self->{_scheduler};
1132 return
1133 24 ▶ if !defined $scheduler
Branch: 1 branch
BranchTrueFalseTotal
if not defined $scheduler && defined $scheduler->current_task or $Zuzu::Runtime::DEBUG_LEVEL <= 0 20 4 24
Condition66%4/6
not defined $scheduler && defined $scheduler->current_task or $Zuzu::Runtime::DEBUG_LEVEL <= 0
l!l&&r!l&&!r
2004
defined $scheduler && defined $scheduler->current_task
!ll&&!rl&&r
0204
MC/DC33%1/3
not defined $scheduler && defined $scheduler->current_task or $Zuzu::Runtime::DEBUG_LEVEL <= 0
defined $scheduler defined $scheduler->current_task $Zuzu::Runtime::DEBUG_LEVEL <= 0
Truth table50%2/4
not(A && B) or C
A= defined $schedulerB= defined $scheduler->current_taskC= $Zuzu::Runtime::DEBUG_LEVEL <= 0
ABCresult
0XX1
10X1
1111
1100
1134 or !defined $scheduler->current_task
1135 or $Zuzu::Runtime::DEBUG_LEVEL <= 0;
1136 4 ▶ $file //= $self->{_native_call_file} // '<runtime>';
Condition50%2/4
$file //= $self->{"_native_call_file"} // "<runtime>"
l!l
04
$self->{"_native_call_file"} // "<runtime>"
l!l
40
MC/DC0%0/1
$file //= $self->{"_native_call_file"} // "<runtime>"
$file
Truth table50%1/2
A
A= $file
Aresult
11
00
1137 4 ▶ $line //= $self->{_native_call_line} // 0;
Condition50%2/4
$line //= $self->{"_native_call_line"} // 0
l!l
04
$self->{"_native_call_line"} // 0
l!l
40
MC/DC0%0/1
$line //= $self->{"_native_call_line"} // 0
$line
Truth table50%1/2
A
A= $line
Aresult
11
00
1138 4 my $record = $scheduler->trace_task(
1139 blocked_operation => $scheduler->current_task,
1140 {
1141 operation => $operation,
1142 file => $file,
1143 line => $line,
1144 },
1145 );
1146 4 ▶ warn "Blocking operation in async task: $operation at $file line $line\n"
Branch: 1 branch
BranchTrueFalseTotal
if $Zuzu::Runtime::DEBUG_LEVEL >= 2 0 4 4
1147 if $Zuzu::Runtime::DEBUG_LEVEL >= 2;
1148  
1149 4 return $record;
1150 }
1151  
1152 14 ▶sub _task_exception {
Subroutine _task_exception: called CC=4 SCAR=16.1
1153 14 my ( $self, $class_name, $message, $file, $line ) = @_;
1154  
1155 my $class = $self->{_builtin_classes}{$class_name}
1156 14 ▶ // $self->{_builtin_classes}{Exception};
Condition33%1/3
$self->{"_builtin_classes"}{$class_name} // $self->{"_builtin_classes"}{"Exception"}
l!l&&r!l&&!r
1400
MC/DC0%0/2
$self->{"_builtin_classes"}{$class_name} // $self->{"_builtin_classes"}{"Exception"}
$self->{"_builtin_classes"}{$class_name} $self->{"_builtin_classes"}{"Exception"}
Truth table33%1/3
A // B
A= $self->{"_builtin_classes"}{$class_name}B= $self->{"_builtin_classes"}{"Exception"}
ABresult
1X1
011
000
1157 14 ▶ return $self->_instantiate_builtin_object(
Condition50%2/4
$file // "<std/task>"
l!l
140
$line // 0
l!l
140
MC/DC0%0/1
$file // "<std/task>"
$file
MC/DC0%0/1
$line // 0
$line
Truth table50%1/2
A
A= $file
Aresult
11
00
Truth table50%1/2
A
A= $line
Aresult
11
00
1158 $class,
1159 {
1160 message => $message,
1161 file => $file // '<std/task>',
1162 line => $line // 0,
1163 },
1164 );
1165 }
1166  
1167 103 ▶sub _await_value {
Subroutine _await_value: called CC=3 SCAR=14.2
1168 103 my ( $self, $value, $file, $line ) = @_;
1169  
1170 103 ▶ return $value->await
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($value) and $value->isa("Zuzu::Value::Task") 103 0 103
Condition33%1/3
builtin::blessed($value) and $value->isa("Zuzu::Value::Task")
!ll&&!rl&&r
00103
MC/DC0%0/2
builtin::blessed($value) and $value->isa("Zuzu::Value::Task")
builtin::blessed($value) $value->isa("Zuzu::Value::Task")
Truth table33%1/3
A and B
A= builtin::blessed($value)B= $value->isa("Zuzu::Value::Task")
ABresult
0X0
100
111
1171 if blessed($value) and $value->isa('Zuzu::Value::Task');
1172  
1173 0 die Zuzu::Error->new_runtime(
1174 message => 'await block must return a Task',
1175 file => $file,
1176 line => $line,
1177 );
1178 }
1179  
1180 103 ▶sub eval_await {
Subroutine eval_await: called CC=1 SCAR=0.0
Pod undocumented
1181 103 my ( $self, $node ) = @_;
1182  
1183 103 my $value = $node->block->evaluate($self);
1184  
1185 103 return $self->_await_value( $value, $node->file, $node->line );
1186 }
1187  
1188 15 ▶sub eval_spawn {
Subroutine eval_spawn: called CC=2 SCAR=7.2
Pod undocumented
1189 15 my ( $self, $node ) = @_;
1190  
1191 15 my $captured_env = $self->_capture_env( $self->_env );
1192 15 my $block = $node->block;
1193 15 my $scheduler = $self->{_scheduler};
1194 15 ▶ my $group = $scheduler
Branch: 1 branch
BranchTrueFalseTotal
$scheduler ? : 15 0 15
1195 ? $scheduler->new_group( $scheduler->current_group )
1196 : undef;
1197 return $self->_new_task(
1198 name => '<spawn>',
1199 schedule => 1,
1200 group => $group,
1201 file => $node->file,
1202 line => $node->line,
1203 3 ▶ on_cancel => sub {
Subroutine __ANON__: called CC=7 SCAR=20.9
1204 3 my ( $task ) = @_;
1205 3 ▶ return if !defined $group;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $group 0 3 3
1206 3 for my $child ( values %{ $group->tasks } ) {
1207 6 ▶ next if !defined $child or $child == $task;
Branch: 1 branch
BranchTrueFalseTotal
if not defined $child or $child == $task 3 3 6
Condition66%2/3
not defined $child or $child == $task
l!l&&r!l&&!r
033
MC/DC50%1/2
not defined $child or $child == $task
not defined $child $child == $task
Truth table66%2/3
not(A) or B
A= not defined $childB= $child == $task
ABresult
1X1
011
000
1208 3 ▶ $child->cancel( $task->error )
Branch: 1 branch
BranchTrueFalseTotal
if $child->can("cancel") and not $child->is_done 3 0 3
Condition33%1/3
$child->can("cancel") and not $child->is_done
!ll&&!rl&&r
003
MC/DC0%0/2
$child->can("cancel") and not $child->is_done
$child->can("cancel") not $child->is_done
Truth table33%1/3
A and not(B)
A= $child->can("cancel")B= not $child->is_done
ABresult
0X0
100
111
1209 if $child->can('cancel') and !$child->is_done;
1210 }
1211 },
1212 14 ▶ thunk => sub {
Subroutine __ANON__: called CC=6 SCAR=18.8
1213 14 $self->_push_env($captured_env);
1214 14 my $ret;
1215 14 my $ok = eval {
1216 14 $ret = $block->evaluate($self);
1217 11 1;
1218 };
1219 14 ▶ my $err = $@ if !$ok;
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 3 11 14
1220 14 $self->_pop_env;
1221 14 ▶ if ( !$ok ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ok) 3 11 14
1222 3 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (ref $err and ref $err eq "Zuzu::Control" and $err->{"_control"} eq "return") 0 3 3
Condition33%2/6
ref $err and ref $err eq "Zuzu::Control" and $err->{"_control"} eq "return"
!ll&&!rl&&r
300
ref $err and ref $err eq "Zuzu::Control"
!ll&&!rl&&r
030
MC/DC0%0/3
ref $err and ref $err eq "Zuzu::Control" and $err->{"_control"} eq "return"
ref $err ref $err eq "Zuzu::Control" $err->{"_control"} eq "return"
Truth table25%1/4
A and B and C
A= ref $errB= ref $err eq "Zuzu::Control"C= $err->{"_control"} eq "return"
ABCresult
0XX0
10X0
1100
1111
1223 ref($err)
1224 and ref($err) eq 'Zuzu::Control'
1225 and $err->{_control} eq 'return'
1226 ) {
1227 0 return $err->{value};
1228 }
1229 3 die $err;
1230 }
1231 11 return $ret;
1232 },
1233 15 );
1234 }
1235  
1236 47733 ▶sub eval_let {
Subroutine eval_let: called CC=8 SCAR=20.8
Pod documented
1237 47733 my ($self, $node) = @_;
1238  
1239 47733 ▶ my $val = defined($node->init) ? $node->init->evaluate($self) : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $node->init ? : 47530 203 47733
1240 47729 ▶ my $declared_type = $node->declared_type // 'Any';
Condition50%1/2
$node->declared_type // "Any"
l!l
477290
MC/DC0%0/1
$node->declared_type // "Any"
$node->declared_type
Truth table50%1/2
A
A= $node->declared_type
Aresult
11
00
1241 47729 ▶ if ( defined $node->init ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $node->init) 47526 203 47729
1242 $self->_assert_declared_type( $declared_type, $val, $node->file, $node->line, $node->name )
1243 47526 ▶ if !$node->{_skip_type_check};
Branch: 1 branch
BranchTrueFalseTotal
unless $node->{"_skip_type_check"} 47481 45 47526
1244 }
1245 47728 ▶ my $ref = $self->{_stack}[-1]->declare( # inlined $self->_env
Branch: 2 branches
BranchTrueFalseTotal
$node->is_const ? : 1660 46068 47728
$node->is_weak_storage ? : 3 47725 47728
1246 $node->name,
1247 undef,
1248 $node->is_const ? 1 : 0,
1249 $declared_type,
1250 $node->is_weak_storage ? 1 : 0,
1251 );
1252 47728 ▶ store_value( $ref, $val, $node->is_weak_storage ? 1 : 0 );
Branch: 1 branch
BranchTrueFalseTotal
$node->is_weak_storage ? : 3 47725 47728
1253  
1254 47728 return $val;
1255 }
1256  
1257 13 ▶sub eval_let_unpack {
Subroutine eval_let_unpack: called CC=26 SCAR=35.1
Pod undocumented
1258 13 my ( $self, $node ) = @_;
1259  
1260 13 my $source = $node->init->evaluate($self);
1261 13 my $dict = $self->_unwrap_builtin_collection( $source, 'Dict' );
1262 13 my $pairlist = $self->_unwrap_builtin_collection( $source, 'PairList' );
1263 13 my $array = $self->_unwrap_builtin_collection( $source, 'Array' );
1264 13 ▶ if ( !$dict and !$pairlist and !$array ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dict or $pairlist or $array) 1 12 13
Condition83%5/6
$dict or $pairlist or $array
l!l&&r!l&&!r
1201
$dict or $pairlist
l!l&&r!l&&!r
1111
MC/DC66%2/3
$dict or $pairlist or $array
$dict $pairlist $array
Truth table75%3/4
A or B or C
A= $dictB= $pairlistC= $array
ABCresult
1XX1
01X1
0011
0000
1265 1 my $type = $self->_type_name($source);
1266 1 die Zuzu::Error->new_runtime(
1267 message => "Declaration unpacking expects Dict, PairList, or Array, got $type",
1268 file => $node->file,
1269 line => $node->line,
1270 );
1271 }
1272  
1273 12 my @resolved;
1274 12 my $index = 0;
1275 12 ▶ for my $binding ( @{ $node->bindings // [] } ) {
Condition50%1/2
$node->bindings // []
l!l
120
MC/DC0%0/1
$node->bindings // []
$node->bindings
Truth table50%1/2
A
A= $node->bindings
Aresult
11
00
1276 19 my ( $present, $value );
1277 19 ▶ if ($array) {
Branch: 1 branch
BranchTrueFalseTotal
if ($array) { } 0 19 19
1278 0 ▶ $present = $index < @{ $array->items } ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$index < @{$array->items;} ? : 0 0 0
1279 0 ▶ $value = slot_value( \$array->items->[$index] ) if $present;
Branch: 1 branch
BranchTrueFalseTotal
if $present 0 0 0
1280 }
1281 else {
1282 19 my $key = $binding->{key_expr}->evaluate($self);
1283 19 ▶ $key = defined($key) ? "$key" : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $key ? : 19 0 19
1284 19 ▶ if ($dict) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dict) { } 18 1 19
1285 18 ▶ $present = exists $dict->map->{$key} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
exists $dict->map->{$key} ? : 15 3 18
1286 18 ▶ $value = slot_value( \$dict->map->{$key} ) if $present;
Branch: 1 branch
BranchTrueFalseTotal
if $present 15 3 18
1287 }
1288 else {
1289 1 ▶ $present = $pairlist->contains_key($key) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$pairlist->contains_key($key) ? : 1 0 1
1290 1 ▶ $value = $pairlist->get($key) if $present;
Branch: 1 branch
BranchTrueFalseTotal
if $present 1 0 1
1291 }
1292 }
1293  
1294 19 ▶ if ( !$present and $binding->{has_default} ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $present and $binding->{'has_default'}) { } 2 17 19
elsif (not $present) { } 1 16 17
Condition100%3/3
not $present and $binding->{"has_default"}
!ll&&!rl&&r
1612
MC/DC100%2/2
not $present and $binding->{"has_default"}
not $present $binding->{"has_default"}
Truth table100%3/3
not(A) and B
A= not $presentB= $binding->{"has_default"}
ABresult
0X0
100
111
1295 2 $value = $binding->{default_expr}->evaluate($self);
1296 }
1297 elsif ( !$present ) {
1298 1 $value = undef;
1299 }
1300  
1301 19 ▶ my $declared_type = $binding->{declared_type} // 'Any';
Condition50%1/2
$binding->{"declared_type"} // "Any"
l!l
190
MC/DC0%0/1
$binding->{"declared_type"} // "Any"
$binding->{"declared_type"}
Truth table50%1/2
A
A= $binding->{"declared_type"}
Aresult
11
00
1302 $self->_assert_declared_type(
1303 $declared_type,
1304 $value,
1305 $binding->{file} // $node->file,
1306 $binding->{line} // $node->line,
1307 $binding->{name},
1308 19 ▶ ) if !$binding->{_skip_type_check};
Branch: 1 branch
BranchTrueFalseTotal
unless $binding->{"_skip_type_check"} 19 0 19
Condition33%2/6
$binding->{"file"} // $node->file
l!l&&r!l&&!r
1900
$binding->{"line"} // $node->line
l!l&&r!l&&!r
1900
MC/DC0%0/2
$binding->{"file"} // $node->file
$binding->{"file"} $node->file
MC/DC0%0/2
$binding->{"line"} // $node->line
$binding->{"line"} $node->line
Truth table33%1/3
A // B
A= $binding->{"file"}B= $node->file
ABresult
1X1
011
000
Truth table33%1/3
A // B
A= $binding->{"line"}B= $node->line
ABresult
1X1
011
000
1309  
1310 18 push @resolved, [ $binding, $value ];
1311 18 $index++;
1312 }
1313  
1314 11 for my $item ( @resolved ) {
1315 18 my ( $binding, $value ) = @{ $item };
1316 18 ▶ my $declared_type = $binding->{declared_type} // 'Any';
Condition50%1/2
$binding->{"declared_type"} // "Any"
l!l
180
MC/DC0%0/1
$binding->{"declared_type"} // "Any"
$binding->{"declared_type"}
Truth table50%1/2
A
A= $binding->{"declared_type"}
Aresult
11
00
1317 18 ▶ my $is_weak_storage = $binding->{is_weak_storage} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$binding->{'is_weak_storage'} ? : 1 17 18
1318 my $ref = $self->_env->declare(
1319 $binding->{name},
1320 undef,
1321 18 ▶ $node->is_const ? 1 : 0,
Branch: 1 branch
BranchTrueFalseTotal
$node->is_const ? : 1 17 18
1322 $declared_type,
1323 $is_weak_storage,
1324 );
1325 18 store_value( $ref, $value, $is_weak_storage );
1326 }
1327  
1328 11 return $source;
1329 }
1330  
1331 24192 ▶sub _target_declared_type {
Subroutine _target_declared_type: called CC=6 SCAR=18.3
1332 24192 my ( $self, $target, $name ) = @_;
1333  
1334 24192 ▶ return $target->{declared_type} if defined $target->{declared_type};
Branch: 1 branch
BranchTrueFalseTotal
if defined $target->{"declared_type"} 3 24189 24192
1335 return $target->{env}{types}{$name} // 'Any'
1336 24189 ▶ if defined $name and defined $target->{env};
Branch: 1 branch
BranchTrueFalseTotal
if defined $name and defined $target->{"env"} 23958 231 24189
Condition60%3/5
defined $name and defined $target->{"env"}
!ll&&!rl&&r
231023958
$target->{"env"}{"types"}{$name} // "Any"
l!l
239580
MC/DC50%1/2
defined $name and defined $target->{"env"}
defined $name defined $target->{"env"}
MC/DC0%0/1
$target->{"env"}{"types"}{$name} // "Any"
$target->{"env"}{"types"}{$name}
Truth table66%2/3
A and B
A= defined $nameB= defined $target->{"env"}
ABresult
0X0
100
111
Truth table50%1/2
A
A= $target->{"env"}{"types"}{$name}
Aresult
11
00
1337 231 ▶ return $self->_env->declared_type_for($name) if defined $name;
Branch: 1 branch
BranchTrueFalseTotal
if defined $name 0 231 231
1338  
1339 231 return 'Any';
1340 }
1341  
1342 24192 ▶sub _target_weak_storage {
Subroutine _target_weak_storage: called CC=3 SCAR=11.0
1343 24192 my ( $self, $target, $node ) = @_;
1344  
1345 24192 ▶ return 1 if $target->{weak_storage};
Branch: 1 branch
BranchTrueFalseTotal
if $target->{"weak_storage"} 13 24179 24192
1346 24179 ▶ return 1 if $node->is_weak_write;
Branch: 1 branch
BranchTrueFalseTotal
if $node->is_weak_write 4 24175 24179
1347  
1348 24175 return 0;
1349 }
1350  
1351 24192 ▶sub _store_target_value {
Subroutine _store_target_value: called CC=7 SCAR=19.5
1352 24192 my ( $self, $target, $node, $value ) = @_;
1353 24192 my $weak = $self->_target_weak_storage( $target, $node );
1354  
1355 24192 ▶ if ( $target->{kind} && $target->{kind} eq 'array_index' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($target->{'kind'} and $target->{'kind'} eq 'array_index') { } 6 24186 24192
elsif ($target->{'kind'} and $target->{'kind'} eq 'dict_key') { } 225 23961 24186
Condition66%2/3
$target->{"kind"} and $target->{"kind"} eq "array_index"
!ll&&!rl&&r
0241866
MC/DC50%1/2
$target->{"kind"} and $target->{"kind"} eq "array_index"
$target->{"kind"} $target->{"kind"} eq "array_index"
Truth table66%2/3
A and B
A= $target->{"kind"}B= $target->{"kind"} eq "array_index"
ABresult
0X0
100
111
1356 6 ▶ $target->{array}->weak->[ $target->{index} ] = $weak ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$weak ? : 2 4 6
1357 }
1358 ▶ elsif ( $target->{kind} && $target->{kind} eq 'dict_key' ) {
Condition66%2/3
$target->{"kind"} and $target->{"kind"} eq "dict_key"
!ll&&!rl&&r
023961225
MC/DC50%1/2
$target->{"kind"} and $target->{"kind"} eq "dict_key"
$target->{"kind"} $target->{"kind"} eq "dict_key"
Truth table66%2/3
A and B
A= $target->{"kind"}B= $target->{"kind"} eq "dict_key"
ABresult
0X0
100
111
1359 225 ▶ $target->{dict}->weak->{ $target->{dict_key} } = $weak ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$weak ? : 1 224 225
1360 }
1361  
1362 24192 return store_value( $target->{ref}, $value, $weak );
1363 }
1364  
1365 24270 ▶sub _is_path_lvalue_expr {
Subroutine _is_path_lvalue_expr: called CC=7 SCAR=21.2
1366 24270 my ( $self, $expr ) = @_;
1367  
1368 24270 ▶ return 0 if !blessed($expr) or !$expr->isa('Zuzu::AST::Expr::Binary');
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Binary") 24249 21 24270
Condition66%2/3
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Binary")
!ll&&!rl&&r
02424921
MC/DC50%1/2
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Binary")
builtin::blessed($expr) $expr->isa("Zuzu::AST::Expr::Binary")
Truth table66%2/3
A and B
A= builtin::blessed($expr)B= $expr->isa("Zuzu::AST::Expr::Binary")
ABresult
0X0
100
111
1369 21 ▶ return 1 if defined $expr->op and ( $expr->op eq '@' or $expr->op eq '@@' or $expr->op eq '@?' );
Branch: 1 branch
BranchTrueFalseTotal
if defined $expr->op and $expr->op eq "\@" || $expr->op eq "\@\@" || $expr->op eq "\@?" 21 0 21
Condition66%6/9
defined $expr->op and $expr->op eq "\@" || $expr->op eq "\@\@" || $expr->op eq "\@?"
!ll&&!rl&&r
0021
$expr->op eq "\@" or $expr->op eq "\@\@" or $expr->op eq "\@?"
l!l&&r!l&&!r
1560
$expr->op eq "\@" or $expr->op eq "\@\@"
l!l&&r!l&&!r
876
MC/DC0%0/4
defined $expr->op and $expr->op eq "\@" || $expr->op eq "\@\@" || $expr->op eq "\@?"
defined $expr->op $expr->op eq "\@" $expr->op eq "\@\@" $expr->op eq "\@?"
Truth table60%3/5
A and B or C or D
A= defined $expr->opB= $expr->op eq "\@"C= $expr->op eq "\@\@"D= $expr->op eq "\@?"
ABCDresult
0XXX0
10000
11XX1
101X1
10011
1370 0 return 0;
1371 }
1372  
1373 9 ▶sub _assert_path_ref_value {
Subroutine _assert_path_ref_value: called CC=3 SCAR=12.5
1374 9 my ( $self, $value, $file, $line, $context ) = @_;
1375  
1376 9 ▶ die Zuzu::Error->new_runtime(
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($value) and $value->isa("Zuzu::Value::Function") 0 9 9
Condition33%1/3
builtin::blessed($value) and $value->isa("Zuzu::Value::Function")
!ll&&!rl&&r
009
MC/DC0%0/2
builtin::blessed($value) and $value->isa("Zuzu::Value::Function")
builtin::blessed($value) $value->isa("Zuzu::Value::Function")
Truth table33%1/3
A and B
A= builtin::blessed($value)B= $value->isa("Zuzu::Value::Function")
ABresult
0X0
100
111
1377 message => "Path object returned invalid reference for $context",
1378 file => $file,
1379 line => $line,
1380 ) if !blessed($value) or !$value->isa('Zuzu::Value::Function');
1381  
1382 9 return $value;
1383 }
1384  
1385 6 ▶sub _call_ref_closure_get {
Subroutine _call_ref_closure_get: called CC=1 SCAR=0.0
1386 6 my ( $self, $ref_fn, $file, $line ) = @_;
1387  
1388 6 return $self->_call_function(
1389 $ref_fn,
1390 [],
1391 $EMPTY_HASH,
1392 $EMPTY_ARRAY,
1393 $file,
1394 $line,
1395 );
1396 }
1397  
1398 6 ▶sub _call_ref_closure_set {
Subroutine _call_ref_closure_set: called CC=1 SCAR=0.0
1399 6 my ( $self, $ref_fn, $value, $file, $line ) = @_;
1400  
1401 6 return $self->_call_function(
1402 $ref_fn,
1403 [ $value ],
1404 $EMPTY_HASH,
1405 $EMPTY_ARRAY,
1406 $file,
1407 $line,
1408 );
1409 }
1410  
1411 1 ▶sub _make_path_replace_callback {
Subroutine _make_path_replace_callback: called CC=1 SCAR=0.0
1412 1 my ( $self, $replace_expr ) = @_;
1413  
1414 1 my $captured_env = $self->_env;
1415 1 my $fn = Zuzu::Value::Function->new(
1416 name => '<path-regexp-replace>',
1417 params => [ 'm' ],
1418 vararg => undef,
1419 body => undef,
1420 closure_env => $captured_env,
1421 );
1422 1 ▶ $fn->{_native} = sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
1423 1 my ( $match_value ) = @_;
1424 1 my $env = Zuzu::Env->_new_fast( $captured_env );
1425 1 $self->_push_env($env);
1426 1 $env->declare( 'm', $match_value, 1, 'Any' );
1427 1 my $value;
1428 1 my $ok = eval {
1429 1 $value = $replace_expr->evaluate($self);
1430 1 1;
1431 };
1432 1 my $err = $@;
1433 1 $self->_pop_env;
1434 1 ▶ die $err if !$ok;
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 0 1 1
1435 1 return $value;
1436 1 };
1437  
1438 1 return $fn;
1439 }
1440  
1441 46745 ▶sub _resolve_lvalue_target {
Subroutine _resolve_lvalue_target: called CC=45 SCAR=49.6
1442 46745 my ($self, $expr) = @_;
1443  
1444 46745 ▶ if (blessed($expr) and $expr->isa('Zuzu::AST::Expr::Var')) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Var")) 46478 267 46745
Condition66%2/3
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Var")
!ll&&!rl&&r
026746478
MC/DC50%1/2
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Var")
builtin::blessed($expr) $expr->isa("Zuzu::AST::Expr::Var")
Truth table66%2/3
A and B
A= builtin::blessed($expr)B= $expr->isa("Zuzu::AST::Expr::Var")
ABresult
0X0
100
111
1445 46478 my ( $ref, $env ) = $self->_var_ref_for_node($expr);
1446 46478 ▶ die Zuzu::Error->new_runtime(message => "Undeclared variable '".$expr->name."'", file => $expr->file, line => $expr->line) if !$ref;
Branch: 1 branch
BranchTrueFalseTotal
unless $ref 0 46478 46478
1447  
1448 return {
1449 kind => 'scalar_ref',
1450 ref => $ref,
1451 env => $env,
1452 name => $expr->name,
1453 weak_storage => defined $env
1454 46478 ▶ ? ( $env->{weak}{ $expr->name } ? 1 : 0 )
Branch: 2 branches
BranchTrueFalseTotal
defined $env ? : 46478 0 46478
$env->{'weak'}{$expr->name} ? : 11 46467 46478
1455 : $self->_env->is_weak_slot($expr->name),
1456 file => $expr->file,
1457 line => $expr->line,
1458 };
1459 }
1460 267 ▶ if ( blessed($expr) and $expr->isa('Zuzu::AST::Expr::Index') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Index")) 6 261 267
Condition66%2/3
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Index")
!ll&&!rl&&r
02616
MC/DC50%1/2
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Index")
builtin::blessed($expr) $expr->isa("Zuzu::AST::Expr::Index")
Truth table66%2/3
A and B
A= builtin::blessed($expr)B= $expr->isa("Zuzu::AST::Expr::Index")
ABresult
0X0
100
111
1461 6 my $col = $expr->array->evaluate($self);
1462 6 ▶ my $idx = 0 + ($expr->index->evaluate($self) // 0);
Condition50%1/2
$expr->index->evaluate($self) // 0
l!l
60
MC/DC0%0/1
$expr->index->evaluate($self) // 0
$expr->index->evaluate($self)
Truth table50%1/2
A
A= $expr->index->evaluate($self)
Aresult
11
00
1463 6 ▶ if ( blessed($col) and $col->isa('Zuzu::Value::Array') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($col) and $col->isa("Zuzu::Value::Array")) 6 0 6
Condition33%1/3
builtin::blessed($col) and $col->isa("Zuzu::Value::Array")
!ll&&!rl&&r
006
MC/DC0%0/2
builtin::blessed($col) and $col->isa("Zuzu::Value::Array")
builtin::blessed($col) $col->isa("Zuzu::Value::Array")
Truth table33%1/3
A and B
A= builtin::blessed($col)B= $col->isa("Zuzu::Value::Array")
ABresult
0X0
100
111
1464 6 $self->_assert_mutable_collection( $col, $expr->file, $expr->line );
1465  
1466 return {
1467 6 kind => 'array_index',
1468 array => $col,
1469 index => $idx,
1470 ref => \$col->items->[$idx],
1471 weak_storage => 0,
1472 file => $expr->file,
1473 line => $expr->line,
1474 };
1475 }
1476 0 ▶ if ( defined($col) and !ref($col) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $col and not ref $col) 0 0 0
Condition0%0/3
defined $col and not ref $col
!ll&&!rl&&r
000
MC/DC0%0/2
defined $col and not ref $col
defined $col not ref $col
Truth table0%0/3
A and not(B)
A= defined $colB= not ref $col
ABresult
0X0
100
111
1477 0 my $target = $self->_resolve_lvalue_target( $expr->array );
1478  
1479 return {
1480 kind => 'string_index',
1481 string_ref => $target->{ref},
1482 name => $target->{name},
1483 env => $target->{env},
1484 0 target_expr => $expr,
1485 file => $expr->file,
1486 line => $expr->line,
1487 };
1488 }
1489 0 ▶ if ( blessed($col) and $col->isa('Zuzu::Value::BinaryString') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($col) and $col->isa("Zuzu::Value::BinaryString")) 0 0 0
Condition0%0/3
builtin::blessed($col) and $col->isa("Zuzu::Value::BinaryString")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($col) and $col->isa("Zuzu::Value::BinaryString")
builtin::blessed($col) $col->isa("Zuzu::Value::BinaryString")
Truth table0%0/3
A and B
A= builtin::blessed($col)B= $col->isa("Zuzu::Value::BinaryString")
ABresult
0X0
100
111
1490 0 $self->_assert_mutable_collection( $col, $expr->file, $expr->line );
1491  
1492 return {
1493 0 kind => 'binary_string_index',
1494 binary_string => $col,
1495 target_expr => $expr,
1496 file => $expr->file,
1497 line => $expr->line,
1498 };
1499 }
1500 0 die Zuzu::Error->new_runtime(message => "Index assignment expects Array, String, or BinaryString", file => $expr->file, line => $expr->line);
1501 }
1502 261 ▶ if ( blessed($expr) and $expr->isa('Zuzu::AST::Expr::DictGet') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::DictGet")) 251 10 261
Condition66%2/3
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::DictGet")
!ll&&!rl&&r
010251
MC/DC50%1/2
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::DictGet")
builtin::blessed($expr) $expr->isa("Zuzu::AST::Expr::DictGet")
Truth table66%2/3
A and B
A= builtin::blessed($expr)B= $expr->isa("Zuzu::AST::Expr::DictGet")
ABresult
0X0
100
111
1503 251 my $dict = $expr->dict->evaluate($self);
1504 251 my $key = $expr->key->evaluate($self);
1505 251 ▶ $key = defined($key) ? "$key" : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $key ? : 251 0 251
1506 251 ▶ if ( blessed($dict) and $dict->isa('Zuzu::Value::Dict') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($dict) and $dict->isa("Zuzu::Value::Dict")) 245 6 251
Condition66%2/3
builtin::blessed($dict) and $dict->isa("Zuzu::Value::Dict")
!ll&&!rl&&r
06245
MC/DC50%1/2
builtin::blessed($dict) and $dict->isa("Zuzu::Value::Dict")
builtin::blessed($dict) $dict->isa("Zuzu::Value::Dict")
Truth table66%2/3
A and B
A= builtin::blessed($dict)B= $dict->isa("Zuzu::Value::Dict")
ABresult
0X0
100
111
1507 245 $self->_assert_mutable_collection( $dict, $expr->file, $expr->line );
1508  
1509 return {
1510 kind => 'dict_key',
1511 dict => $dict,
1512 dict_key => $key,
1513 244 ref => \$dict->map->{ $key },
1514 weak_storage => 0,
1515 file => $expr->file,
1516 line => $expr->line,
1517 };
1518 }
1519 6 ▶ if ( blessed($dict) and $dict->isa('Zuzu::Value::PairList') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($dict) and $dict->isa("Zuzu::Value::PairList")) 3 3 6
Condition66%2/3
builtin::blessed($dict) and $dict->isa("Zuzu::Value::PairList")
!ll&&!rl&&r
033
MC/DC50%1/2
builtin::blessed($dict) and $dict->isa("Zuzu::Value::PairList")
builtin::blessed($dict) $dict->isa("Zuzu::Value::PairList")
Truth table66%2/3
A and B
A= builtin::blessed($dict)B= $dict->isa("Zuzu::Value::PairList")
ABresult
0X0
100
111
1520 3 $self->_assert_mutable_collection( $dict, $expr->file, $expr->line );
1521  
1522 return {
1523 3 kind => 'pairlist',
1524 pairlist => $dict,
1525 pairlist_key => $key,
1526 file => $expr->file,
1527 line => $expr->line,
1528 };
1529 }
1530 3 ▶ if ( blessed($dict) and $dict->isa('Zuzu::Value::Object') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($dict) and $dict->isa("Zuzu::Value::Object")) 3 0 3
Condition33%1/3
builtin::blessed($dict) and $dict->isa("Zuzu::Value::Object")
!ll&&!rl&&r
003
MC/DC0%0/2
builtin::blessed($dict) and $dict->isa("Zuzu::Value::Object")
builtin::blessed($dict) $dict->isa("Zuzu::Value::Object")
Truth table33%1/3
A and B
A= builtin::blessed($dict)B= $dict->isa("Zuzu::Value::Object")
ABresult
0X0
100
111
1531 die Zuzu::Error->new_runtime(
1532 message => "Object assignment expects existing field '$key'",
1533 file => $expr->file,
1534 line => $expr->line,
1535 3 ▶ ) if !exists $dict->slots->{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $dict->slots->{$key} 0 3 3
1536  
1537 return {
1538 kind => 'scalar_ref',
1539 ref => \$dict->slots->{$key},
1540 weak_storage => $dict->weak->{$key} ? 1 : 0,
1541 const => $dict->const->{$key} ? 1 : 0,
1542 3 ▶ declared_type => $dict->types->{$key} // 'Any',
Branch: 2 branches
BranchTrueFalseTotal
$dict->weak->{$key} ? : 2 1 3
$dict->const->{$key} ? : 0 3 3
Condition50%1/2
$dict->types->{$key} // "Any"
l!l
30
MC/DC0%0/1
$dict->types->{$key} // "Any"
$dict->types->{$key}
Truth table50%1/2
A
A= $dict->types->{$key}
Aresult
11
00
1543 file => $expr->file,
1544 line => $expr->line,
1545 };
1546 }
1547 0 die Zuzu::Error->new_runtime(message => "Dict assignment expects Dict", file => $expr->file, line => $expr->line);
1548 }
1549 10 ▶ if ( blessed($expr) and $expr->isa('Zuzu::AST::Expr::Slice') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Slice")) 1 9 10
Condition66%2/3
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Slice")
!ll&&!rl&&r
091
MC/DC50%1/2
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Slice")
builtin::blessed($expr) $expr->isa("Zuzu::AST::Expr::Slice")
Truth table66%2/3
A and B
A= builtin::blessed($expr)B= $expr->isa("Zuzu::AST::Expr::Slice")
ABresult
0X0
100
111
1550 1 my $col = $expr->collection->evaluate($self);
1551 1 ▶ if ( blessed($col) and $col->isa('Zuzu::Value::Array') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($col) and $col->isa("Zuzu::Value::Array")) 1 0 1
Condition33%1/3
builtin::blessed($col) and $col->isa("Zuzu::Value::Array")
!ll&&!rl&&r
001
MC/DC0%0/2
builtin::blessed($col) and $col->isa("Zuzu::Value::Array")
builtin::blessed($col) $col->isa("Zuzu::Value::Array")
Truth table33%1/3
A and B
A= builtin::blessed($col)B= $col->isa("Zuzu::Value::Array")
ABresult
0X0
100
111
1552 1 $self->_assert_mutable_collection( $col, $expr->file, $expr->line );
1553  
1554 return {
1555 1 kind => 'slice',
1556 slice_col => $col,
1557 target_expr => $expr,
1558 file => $expr->file,
1559 line => $expr->line,
1560 };
1561 }
1562 0 ▶ if ( defined($col) and !ref($col) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $col and not ref $col) 0 0 0
Condition0%0/3
defined $col and not ref $col
!ll&&!rl&&r
000
MC/DC0%0/2
defined $col and not ref $col
defined $col not ref $col
Truth table0%0/3
A and not(B)
A= defined $colB= not ref $col
ABresult
0X0
100
111
1563 0 my $target = $self->_resolve_lvalue_target( $expr->collection );
1564  
1565 return {
1566 kind => 'string_slice',
1567 string_ref => $target->{ref},
1568 name => $target->{name},
1569 env => $target->{env},
1570 0 target_expr => $expr,
1571 file => $expr->file,
1572 line => $expr->line,
1573 };
1574 }
1575 0 ▶ if ( blessed($col) and $col->isa('Zuzu::Value::BinaryString') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($col) and $col->isa("Zuzu::Value::BinaryString")) 0 0 0
Condition0%0/3
builtin::blessed($col) and $col->isa("Zuzu::Value::BinaryString")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($col) and $col->isa("Zuzu::Value::BinaryString")
builtin::blessed($col) $col->isa("Zuzu::Value::BinaryString")
Truth table0%0/3
A and B
A= builtin::blessed($col)B= $col->isa("Zuzu::Value::BinaryString")
ABresult
0X0
100
111
1576 0 $self->_assert_mutable_collection( $col, $expr->file, $expr->line );
1577  
1578 return {
1579 0 kind => 'binary_string_slice',
1580 binary_string => $col,
1581 target_expr => $expr,
1582 file => $expr->file,
1583 line => $expr->line,
1584 };
1585 }
1586 0 die Zuzu::Error->new_runtime(message => "Slice assignment expects Array, String, or BinaryString", file => $expr->file, line => $expr->line);
1587 }
1588 9 ▶ if ( $self->_is_path_lvalue_expr($expr) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_is_path_lvalue_expr($expr)) 8 1 9
1589 8 my $file = $expr->file;
1590 8 my $line = $expr->line;
1591 8 my $root_value = $expr->left->evaluate($self);
1592 8 my $path_value = $expr->right->evaluate($self);
1593 8 my $path_obj = $self->_coerce_path_operand( $path_value, $file, $line );
1594  
1595 8 ▶ if ( $expr->op eq '@@' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expr->op eq "\@\@") 3 5 8
1596 3 my $refs = $self->_call_path_method(
1597 $path_obj,
1598 'ref_all',
1599 [ $root_value ],
1600 $file,
1601 $line,
1602 );
1603 3 ▶ die Zuzu::Error->new_runtime(
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($refs) and $refs->isa("Zuzu::Value::Array") 0 3 3
Condition33%1/3
builtin::blessed($refs) and $refs->isa("Zuzu::Value::Array")
!ll&&!rl&&r
003
MC/DC0%0/2
builtin::blessed($refs) and $refs->isa("Zuzu::Value::Array")
builtin::blessed($refs) $refs->isa("Zuzu::Value::Array")
Truth table33%1/3
A and B
A= builtin::blessed($refs)B= $refs->isa("Zuzu::Value::Array")
ABresult
0X0
100
111
1604 message => "Path object returned invalid multi-reference result for \@\@ target",
1605 file => $file,
1606 line => $line,
1607 ) if !blessed($refs) or !$refs->isa('Zuzu::Value::Array');
1608 3 for my $item ( @{ $refs->items } ) {
1609 6 $self->_assert_path_ref_value( $item, $file, $line, '@@ target' );
1610 }
1611 return {
1612 3 kind => 'path_multi_ref',
1613 refs => $refs,
1614 file => $file,
1615 line => $line,
1616 };
1617 }
1618  
1619 5 ▶ my $method_name = $expr->op eq '@' ? 'ref_first' : 'ref_maybe';
Branch: 1 branch
BranchTrueFalseTotal
$expr->op eq '@' ? : 2 3 5
1620 5 my $ref_fn = $self->_call_path_method(
1621 $path_obj,
1622 $method_name,
1623 [ $root_value ],
1624 $file,
1625 $line,
1626 );
1627 5 ▶ if ( $expr->op eq '@?' and !defined $ref_fn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expr->op eq "\@?" and not defined $ref_fn) 2 3 5
Condition100%3/3
$expr->op eq "\@?" and not defined $ref_fn
!ll&&!rl&&r
212
MC/DC100%2/2
$expr->op eq "\@?" and not defined $ref_fn
$expr->op eq "\@?" not defined $ref_fn
Truth table100%3/3
A and not(B)
A= $expr->op eq "\@?"B= not defined $ref_fn
ABresult
0X0
100
111
1628 return {
1629 2 kind => 'path_maybe_ref',
1630 matched => 0,
1631 file => $file,
1632 line => $line,
1633 };
1634 }
1635 3 $self->_assert_path_ref_value( $ref_fn, $file, $line, $expr->op . ' target' );
1636 return {
1637 3 ▶ kind => $expr->op eq '@?' ? 'path_maybe_ref' : 'path_single_ref',
Branch: 1 branch
BranchTrueFalseTotal
$expr->op eq '@?' ? : 1 2 3
1638 matched => 1,
1639 ref_fn => $ref_fn,
1640 file => $file,
1641 line => $line,
1642 };
1643 }
1644 1 die Zuzu::Error->new_runtime(message => "Invalid assignment target", file => $expr->file, line => $expr->line);
1645 }
1646  
1647 24238 ▶sub eval_assign {
Subroutine eval_assign: called CC=39 SCAR=49.6
Pod documented
1648 24238 my ($self, $node) = @_;
1649  
1650 24238 ▶ if ( $self->_is_path_lvalue_expr( $node->target ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_is_path_lvalue_expr($node->target)) 10 24228 24238
1651 10 return $self->_eval_path_assignment($node);
1652 }
1653  
1654 24228 my $target = $self->_resolve_lvalue_target($node->target);
1655 my (
1656 $ref, $name, $target_env, $file, $line, $slice_col, $string_ref,
1657 $string_index, $binary_string, $binary_string_index, $pairlist,
1658 $pairlist_key
1659 )
1660 = (
1661 $target->{ref},
1662 $target->{name},
1663 $target->{env},
1664 $target->{file},
1665 $target->{line},
1666 $target->{slice_col},
1667 $target->{string_ref},
1668 $target->{kind} && $target->{kind} eq 'string_index',
1669 $target->{binary_string},
1670 $target->{kind} && $target->{kind} eq 'binary_string_index',
1671 $target->{pairlist},
1672 $target->{pairlist_key},
1673 24226 ▶ );
Condition33%2/6
$target->{'kind'} && $target->{'kind'} eq 'string_index'
!ll&&!rl&&r
0242260
$target->{'kind'} && $target->{'kind'} eq 'binary_string_index'
!ll&&!rl&&r
0242260
MC/DC0%0/2
$target->{'kind'} && $target->{'kind'} eq 'string_index'
$target->{'kind'} $target->{'kind'} eq 'string_index'
MC/DC0%0/2
$target->{'kind'} && $target->{'kind'} eq 'binary_string_index'
$target->{'kind'} $target->{'kind'} eq 'binary_string_index'
Truth table33%1/3
A && B
A= $target->{'kind'}B= $target->{'kind'} eq 'string_index'
ABresult
0X0
100
111
Truth table33%1/3
A && B
A= $target->{'kind'}B= $target->{'kind'} eq 'binary_string_index'
ABresult
0X0
100
111
1674 die Zuzu::Error->new_runtime(
1675 message => "Cannot assign to const field",
1676 file => $file,
1677 line => $line,
1678 24226 ▶ ) if $target->{const};
Branch: 1 branch
BranchTrueFalseTotal
if $target->{"const"} 0 24226 24226
1679  
1680 24226 ▶ if ( defined $name ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $name) 23988 238 24226
1681 my $const_here = defined $target_env
1682 23988 ▶ ? $target_env->{const}{$name}
Branch: 1 branch
BranchTrueFalseTotal
defined $target_env ? : 23988 0 23988
1683 : $self->_env->is_const_here($name);
1684 23988 ▶ if (!defined $const_here and !defined $target_env) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $const_here or defined $target_env) 0 23988 23988
Condition33%1/3
defined $const_here or defined $target_env
l!l&&r!l&&!r
2398800
MC/DC0%0/2
defined $const_here or defined $target_env
defined $const_here defined $target_env
Truth table33%1/3
A or B
A= defined $const_hereB= defined $target_env
ABresult
1X1
011
000
1685 # const could be in parent; find by walking
1686 0 my $env = $self->_env;
1687 0 ▶ while ($env) {
Branch: 1 branch
BranchTrueFalseTotal
if ($env) 0 0 0
1688 0 ▶ if (exists $env->{slots}{$name}) { $const_here = $env->{const}{$name}; last; }
Branch: 1 branch
BranchTrueFalseTotal
if (exists $env->{"slots"}{$name}) 0 0 0
1689 0 $env = $env->{parent};
1690 }
1691 }
1692 23988 ▶ die Zuzu::Error->new_runtime(message => "Cannot assign to const '$name'", file => $file, line => $line) if $const_here;
Branch: 1 branch
BranchTrueFalseTotal
if $const_here 0 23988 23988
1693 }
1694  
1695 24226 my $rhs;
1696 24226 ▶ if ( $node->op ne '~=' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->op ne "~=") 24225 1 24226
1697 24225 $rhs = $node->expr->evaluate($self);
1698 }
1699 24196 ▶ if ( $pairlist ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pairlist) 3 24193 24196
1700 3 ▶ $pairlist->_append(
Branch: 1 branch
BranchTrueFalseTotal
$node->is_weak_write ? : 2 1 3
1701 $pairlist_key,
1702 $rhs,
1703 $node->is_weak_write ? 1 : 0,
1704 );
1705  
1706 3 return $rhs;
1707 }
1708 24193 ▶ if ( $slice_col ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($slice_col) 1 24192 24193
1709 1 ▶ my $start = defined $node->target->start ? 0 + ($node->target->start->evaluate($self) // 0) : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $node->target->start ? : 1 0 1
Condition50%1/2
$node->target->start->evaluate($self) // 0
l!l
10
MC/DC0%0/1
$node->target->start->evaluate($self) // 0
$node->target->start->evaluate($self)
Truth table50%1/2
A
A= $node->target->start->evaluate($self)
Aresult
11
00
1710 1 my $len;
1711 1 ▶ if ( defined $node->target->length ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $node->target->length) { } 1 0 1
1712 1 ▶ $len = 0 + ($node->target->length->evaluate($self) // 0);
Condition50%1/2
$node->target->length->evaluate($self) // 0
l!l
10
MC/DC0%0/1
$node->target->length->evaluate($self) // 0
$node->target->length->evaluate($self)
Truth table50%1/2
A
A= $node->target->length->evaluate($self)
Aresult
11
00
1713 }
1714 else {
1715 0 $len = scalar(@{ $slice_col->items }) - $start;
1716 }
1717 1 ▶ die Zuzu::Error->new_runtime(message => "Slice assignment RHS must be Array", file => $file, line => $line)
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($rhs) and $rhs->isa("Zuzu::Value::Array") 0 1 1
Condition33%1/3
builtin::blessed($rhs) and $rhs->isa("Zuzu::Value::Array")
!ll&&!rl&&r
001
MC/DC0%0/2
builtin::blessed($rhs) and $rhs->isa("Zuzu::Value::Array")
builtin::blessed($rhs) $rhs->isa("Zuzu::Value::Array")
Truth table33%1/3
A and B
A= builtin::blessed($rhs)B= $rhs->isa("Zuzu::Value::Array")
ABresult
0X0
100
111
1718 if !blessed($rhs) or !$rhs->isa('Zuzu::Value::Array');
1719 1 splice @{ $slice_col->items }, $start, $len, @{ $rhs->items };
1720  
1721 1 return $slice_col;
1722 }
1723 24192 ▶ if ( $string_ref ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($string_ref) 0 24192 24192
1724 0 ▶ return $string_index
Branch: 1 branch
BranchTrueFalseTotal
$string_index ? : 0 0 0
1725 ? $self->_assign_string_index(
1726 $string_ref,
1727 $node->target,
1728 $rhs,
1729 $name,
1730 $target_env,
1731 $file,
1732 $line,
1733 )
1734 : $self->_assign_string_slice(
1735 $string_ref,
1736 $node->target,
1737 $rhs,
1738 $name,
1739 $target_env,
1740 $file,
1741 $line,
1742 );
1743 }
1744 24192 ▶ if ( $binary_string ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($binary_string) 0 24192 24192
1745 0 ▶ return $binary_string_index
Branch: 1 branch
BranchTrueFalseTotal
$binary_string_index ? : 0 0 0
1746 ? $self->_assign_binary_string_index(
1747 $binary_string,
1748 $node->target,
1749 $rhs,
1750 $file,
1751 $line,
1752 )
1753 : $self->_assign_binary_string_slice(
1754 $binary_string,
1755 $node->target,
1756 $rhs,
1757 $file,
1758 $line,
1759 );
1760 }
1761  
1762 24192 my $op = $node->op;
1763 24192 ▶ if ($op eq ':=') {
Branch: 11 branches
BranchTrueFalseTotal
if ($op eq ':=') { } 9598 14594 24192
elsif ($op eq '+=') { } 54 14540 14594
elsif ($op eq '-=') { } 0 14540 14540
elsif ($op eq '*=') { } 0 14540 14540
elsif ($op eq "\327=") { } 0 14540 14540
elsif ($op eq '/=') { } 0 14540 14540
elsif ($op eq "\367=") { } 0 14540 14540
elsif ($op eq '**=') { } 0 14540 14540
elsif ($op eq '_=') { } 14417 123 14540
elsif ($op eq '?:=') { } 122 1 123
elsif ($op eq '~=') { } 1 0 1
1764 9598 my $declared_type = $self->_target_declared_type( $target, $name );
1765 $self->_assert_declared_type( $declared_type, $rhs, $file, $line, $name )
1766 9598 ▶ if !$node->{_skip_type_check};
Branch: 1 branch
BranchTrueFalseTotal
unless $node->{"_skip_type_check"} 9595 3 9598
1767 9598 $self->_store_target_value( $target, $node, $rhs );
1768 } elsif ($op eq '+=') {
1769 54 my $new_value = $self->_to_Number($$ref) + $self->_to_Number($rhs);
1770 54 my $declared_type = $self->_target_declared_type( $target, $name );
1771 54 $self->_assert_declared_type( $declared_type, $new_value, $file, $line, $name );
1772 54 $self->_store_target_value( $target, $node, $new_value );
1773 } elsif ($op eq '-=') {
1774 0 my $new_value = $self->_to_Number($$ref) - $self->_to_Number($rhs);
1775 0 my $declared_type = $self->_target_declared_type( $target, $name );
1776 0 $self->_assert_declared_type( $declared_type, $new_value, $file, $line, $name );
1777 0 $self->_store_target_value( $target, $node, $new_value );
1778 } elsif ($op eq '*=') {
1779 0 my $new_value = $self->_to_Number($$ref) * $self->_to_Number($rhs);
1780 0 my $declared_type = $self->_target_declared_type( $target, $name );
1781 0 $self->_assert_declared_type( $declared_type, $new_value, $file, $line, $name );
1782 0 $self->_store_target_value( $target, $node, $new_value );
1783 } elsif ($op eq '×=') {
1784 0 my $new_value = $self->_to_Number($$ref) * $self->_to_Number($rhs);
1785 0 my $declared_type = $self->_target_declared_type( $target, $name );
1786 0 $self->_assert_declared_type( $declared_type, $new_value, $file, $line, $name );
1787 0 $self->_store_target_value( $target, $node, $new_value );
1788 } elsif ($op eq '/=') {
1789 0 my $new_value = $self->_to_Number($$ref) / $self->_to_Number($rhs);
1790 0 my $declared_type = $self->_target_declared_type( $target, $name );
1791 0 $self->_assert_declared_type( $declared_type, $new_value, $file, $line, $name );
1792 0 $self->_store_target_value( $target, $node, $new_value );
1793 } elsif ($op eq '÷=') {
1794 0 my $new_value = $self->_to_Number($$ref) / $self->_to_Number($rhs);
1795 0 my $declared_type = $self->_target_declared_type( $target, $name );
1796 0 $self->_assert_declared_type( $declared_type, $new_value, $file, $line, $name );
1797 0 $self->_store_target_value( $target, $node, $new_value );
1798 } elsif ($op eq '**=') {
1799 0 my $new_value = $self->_to_Number($$ref) ** $self->_to_Number($rhs);
1800 0 my $declared_type = $self->_target_declared_type( $target, $name );
1801 0 $self->_assert_declared_type( $declared_type, $new_value, $file, $line, $name );
1802 0 $self->_store_target_value( $target, $node, $new_value );
1803 } elsif ($op eq '_=') {
1804 14417 my $new_value = $self->_to_OperatorString( $$ref, $file, $line )
1805 . $self->_to_OperatorString( $rhs, $file, $line );
1806 14417 my $declared_type = $self->_target_declared_type( $target, $name );
1807 14417 $self->_assert_declared_type( $declared_type, $new_value, $file, $line, $name );
1808 14417 $self->_store_target_value( $target, $node, $new_value );
1809 } elsif ($op eq '?:=') {
1810 122 ▶ my $new_value = (defined($$ref) ? $$ref : $rhs);
Branch: 1 branch
BranchTrueFalseTotal
defined $$ref ? : 31 91 122
1811 122 my $declared_type = $self->_target_declared_type( $target, $name );
1812 122 $self->_assert_declared_type( $declared_type, $new_value, $file, $line, $name );
1813 122 $self->_store_target_value( $target, $node, $new_value );
1814 } elsif ( $op eq '~=' ) {
1815 1 my $target_text = $self->_to_OperatorString( $$ref, $file, $line );
1816 1 my $match_value = $node->match_expr->evaluate($self);
1817 1 my $regex = $self->_coerce_regexp( $match_value, $file, $line );
1818 1 my $global = $self->_regexp_is_global($match_value);
1819 1 my $new_value = $self->_regexp_replace_value(
1820 $target_text,
1821 $regex,
1822 $global,
1823 $node->replace_expr,
1824 );
1825 1 my $declared_type = $self->_target_declared_type( $target, $name );
1826 1 $self->_assert_declared_type( $declared_type, $new_value, $file, $line, $name );
1827 1 $self->_store_target_value( $target, $node, $new_value );
1828 } else {
1829 0 die Zuzu::Error->new_runtime(message => "Unsupported assignment operator '$op'", file => $file, line => $line);
1830 }
1831  
1832 24192 return $$ref;
1833 }
1834  
1835 0 ▶sub _assign_string_slice {
Subroutine _assign_string_slice: not called CC=12 SCAR=50.5
1836 0 my ( $self, $string_ref, $target, $value, $name, $target_env, $file, $line ) = @_;
1837  
1838 0 ▶ my $start = defined $target->start
Branch: 1 branch
BranchTrueFalseTotal
defined $target->start ? : 0 0 0
Condition0%0/2
$target->start->evaluate($self) // 0
l!l
00
MC/DC0%0/1
$target->start->evaluate($self) // 0
$target->start->evaluate($self)
Truth table0%0/2
A
A= $target->start->evaluate($self)
Aresult
11
00
1839 ? 0 + ( $target->start->evaluate($self) // 0 )
1840 : 0;
1841 0 ▶ my $current = defined $$string_ref ? "$$string_ref" : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $$string_ref ? : 0 0 0
1842 0 my $size = length($current);
1843 0 ▶ $start += $size if $start < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $start < 0 0 0 0
1844 0 ▶ $start = 0 if $start < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $start < 0 0 0 0
1845 0 ▶ $start = $size if $start > $size;
Branch: 1 branch
BranchTrueFalseTotal
if $start > $size 0 0 0
1846 0 ▶ my $len = defined $target->length
Branch: 1 branch
BranchTrueFalseTotal
defined $target->length ? : 0 0 0
Condition0%0/2
$target->length->evaluate($self) // 0
l!l
00
MC/DC0%0/1
$target->length->evaluate($self) // 0
$target->length->evaluate($self)
Truth table0%0/2
A
A= $target->length->evaluate($self)
Aresult
11
00
1847 ? 0 + ( $target->length->evaluate($self) // 0 )
1848 : $size - $start;
1849 0 my $replacement = $self->_to_String($value);
1850 0 substr( $current, $start, $len ) = $replacement;
1851 my $declared_type = defined $name
1852 ? (
1853 defined $target_env
1854 0 ▶ ? ( $target_env->{types}{$name} // 'Any' )
Branch: 2 branches
BranchTrueFalseTotal
defined $name ? : 0 0 0
defined $target_env ? : 0 0 0
Condition0%0/2
$target_env->{"types"}{$name} // "Any"
l!l
00
MC/DC0%0/1
$target_env->{"types"}{$name} // "Any"
$target_env->{"types"}{$name}
Truth table0%0/2
A
A= $target_env->{"types"}{$name}
Aresult
11
00
1855 : $self->_env->declared_type_for($name)
1856 )
1857 : 'Any';
1858 0 $self->_assert_declared_type(
1859 $declared_type,
1860 $current,
1861 $file,
1862 $line,
1863 $name,
1864 );
1865 0 $$string_ref = $current;
1866  
1867 0 return $current;
1868 }
1869  
1870 0 ▶sub _assign_string_index {
Subroutine _assign_string_index: not called CC=9 SCAR=45.0
1871 0 my ( $self, $string_ref, $target, $value, $name, $target_env, $file, $line ) = @_;
1872  
1873 0 ▶ my $current = defined $$string_ref ? "$$string_ref" : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $$string_ref ? : 0 0 0
1874 0 my $size = length($current);
1875 0 ▶ my $idx = 0 + ( $target->index->evaluate($self) // 0 );
Condition0%0/2
$target->index->evaluate($self) // 0
l!l
00
MC/DC0%0/1
$target->index->evaluate($self) // 0
$target->index->evaluate($self)
Truth table0%0/2
A
A= $target->index->evaluate($self)
Aresult
11
00
1876 0 ▶ $idx += $size if $idx < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $idx < 0 0 0 0
1877 0 ▶ $idx = 0 if $idx < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $idx < 0 0 0 0
1878 0 ▶ $idx = $size if $idx > $size;
Branch: 1 branch
BranchTrueFalseTotal
if $idx > $size 0 0 0
1879 0 my $replacement = $self->_to_String($value);
1880 0 substr( $current, $idx, 1 ) = $replacement;
1881 my $declared_type = defined $name
1882 ? (
1883 defined $target_env
1884 0 ▶ ? ( $target_env->{types}{$name} // 'Any' )
Branch: 2 branches
BranchTrueFalseTotal
defined $name ? : 0 0 0
defined $target_env ? : 0 0 0
Condition0%0/2
$target_env->{"types"}{$name} // "Any"
l!l
00
MC/DC0%0/1
$target_env->{"types"}{$name} // "Any"
$target_env->{"types"}{$name}
Truth table0%0/2
A
A= $target_env->{"types"}{$name}
Aresult
11
00
1885 : $self->_env->declared_type_for($name)
1886 )
1887 : 'Any';
1888 0 $self->_assert_declared_type(
1889 $declared_type,
1890 $current,
1891 $file,
1892 $line,
1893 $name,
1894 );
1895 0 $$string_ref = $current;
1896  
1897 0 return $current;
1898 }
1899  
1900 0 ▶sub _assign_binary_string_slice {
Subroutine _assign_binary_string_slice: not called CC=13 SCAR=52.0
1901 0 my ( $self, $binary, $target, $value, $file, $line ) = @_;
1902  
1903 0 ▶ die Zuzu::Error->new_runtime(
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($value) and $value->isa("Zuzu::Value::BinaryString") 0 0 0
Condition0%0/3
builtin::blessed($value) and $value->isa("Zuzu::Value::BinaryString")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($value) and $value->isa("Zuzu::Value::BinaryString")
builtin::blessed($value) $value->isa("Zuzu::Value::BinaryString")
Truth table0%0/3
A and B
A= builtin::blessed($value)B= $value->isa("Zuzu::Value::BinaryString")
ABresult
0X0
100
111
1904 message => "BinaryString slice assignment RHS must be BinaryString",
1905 file => $file,
1906 line => $line,
1907 ) if !blessed($value) or !$value->isa('Zuzu::Value::BinaryString');
1908  
1909 0 ▶ my $start = defined $target->start
Branch: 1 branch
BranchTrueFalseTotal
defined $target->start ? : 0 0 0
Condition0%0/2
$target->start->evaluate($self) // 0
l!l
00
MC/DC0%0/1
$target->start->evaluate($self) // 0
$target->start->evaluate($self)
Truth table0%0/2
A
A= $target->start->evaluate($self)
Aresult
11
00
1910 ? 0 + ( $target->start->evaluate($self) // 0 )
1911 : 0;
1912 0 ▶ my $current = $binary->bytes // '';
Condition0%0/2
$binary->bytes // ""
l!l
00
MC/DC0%0/1
$binary->bytes // ""
$binary->bytes
Truth table0%0/2
A
A= $binary->bytes
Aresult
11
00
1913 0 my $size = length($current);
1914 0 ▶ $start += $size if $start < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $start < 0 0 0 0
1915 0 ▶ $start = 0 if $start < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $start < 0 0 0 0
1916 0 ▶ $start = $size if $start > $size;
Branch: 1 branch
BranchTrueFalseTotal
if $start > $size 0 0 0
1917 0 ▶ my $len = defined $target->length
Branch: 1 branch
BranchTrueFalseTotal
defined $target->length ? : 0 0 0
Condition0%0/2
$target->length->evaluate($self) // 0
l!l
00
MC/DC0%0/1
$target->length->evaluate($self) // 0
$target->length->evaluate($self)
Truth table0%0/2
A
A= $target->length->evaluate($self)
Aresult
11
00
1918 ? 0 + ( $target->length->evaluate($self) // 0 )
1919 : $size - $start;
1920 0 ▶ $len = 0 if $len < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $len < 0 0 0 0
1921 0 ▶ substr( $current, $start, $len ) = $value->bytes // '';
Condition0%0/2
$value->bytes // ""
l!l
00
MC/DC0%0/1
$value->bytes // ""
$value->bytes
Truth table0%0/2
A
A= $value->bytes
Aresult
11
00
1922 0 $binary->bytes($current);
1923  
1924 0 return $binary;
1925 }
1926  
1927 0 ▶sub _assign_binary_string_index {
Subroutine _assign_binary_string_index: not called CC=9 SCAR=45.0
1928 0 my ( $self, $binary, $target, $value, $file, $line ) = @_;
1929  
1930 0 ▶ die Zuzu::Error->new_runtime(
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($value) and $value->isa("Zuzu::Value::BinaryString") 0 0 0
Condition0%0/3
builtin::blessed($value) and $value->isa("Zuzu::Value::BinaryString")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($value) and $value->isa("Zuzu::Value::BinaryString")
builtin::blessed($value) $value->isa("Zuzu::Value::BinaryString")
Truth table0%0/3
A and B
A= builtin::blessed($value)B= $value->isa("Zuzu::Value::BinaryString")
ABresult
0X0
100
111
1931 message => "BinaryString index assignment RHS must be BinaryString",
1932 file => $file,
1933 line => $line,
1934 ) if !blessed($value) or !$value->isa('Zuzu::Value::BinaryString');
1935  
1936 0 ▶ my $current = $binary->bytes // '';
Condition0%0/2
$binary->bytes // ""
l!l
00
MC/DC0%0/1
$binary->bytes // ""
$binary->bytes
Truth table0%0/2
A
A= $binary->bytes
Aresult
11
00
1937 0 my $size = length($current);
1938 0 ▶ my $idx = 0 + ( $target->index->evaluate($self) // 0 );
Condition0%0/2
$target->index->evaluate($self) // 0
l!l
00
MC/DC0%0/1
$target->index->evaluate($self) // 0
$target->index->evaluate($self)
Truth table0%0/2
A
A= $target->index->evaluate($self)
Aresult
11
00
1939 0 ▶ $idx += $size if $idx < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $idx < 0 0 0 0
1940 0 ▶ $idx = 0 if $idx < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $idx < 0 0 0 0
1941 0 ▶ $idx = $size if $idx > $size;
Branch: 1 branch
BranchTrueFalseTotal
if $idx > $size 0 0 0
1942 0 ▶ substr( $current, $idx, 1 ) = $value->bytes // '';
Condition0%0/2
$value->bytes // ""
l!l
00
MC/DC0%0/1
$value->bytes // ""
$value->bytes
Truth table0%0/2
A
A= $value->bytes
Aresult
11
00
1943 0 $binary->bytes($current);
1944  
1945 0 return $binary;
1946 }
1947  
1948 10 ▶sub _eval_path_assignment {
Subroutine _eval_path_assignment: called CC=5 SCAR=16.1
1949 10 my ( $self, $node ) = @_;
1950  
1951 10 my $target = $node->target;
1952 10 my $file = $target->file;
1953 10 my $line = $target->line;
1954 10 my $op = $node->op;
1955 10 my $path_op = $target->op;
1956 10 my $root_value = $target->left->evaluate($self);
1957 10 my $path_value = $target->right->evaluate($self);
1958 10 my $path_obj = $self->_coerce_path_operand( $path_value, $file, $line );
1959 10 ▶ my $rhs = $op eq '~='
Branch: 1 branch
BranchTrueFalseTotal
$op eq '~=' ? : 1 9 10
1960 ? Zuzu::Value::Array->new(
1961 items => [
1962 $node->match_expr->evaluate($self),
1963 $self->_make_path_replace_callback( $node->replace_expr ),
1964 ],
1965 )
1966 : $node->expr->evaluate($self);
1967 10 ▶ my $method_name
Branch: 2 branches
BranchTrueFalseTotal
$path_op eq '@' ? : 5 5 10
$path_op eq '@@' ? : 3 2 5
1968 = $path_op eq '@' ? 'assign_first'
1969 : $path_op eq '@@' ? 'assign_all'
1970 : 'assign_maybe';
1971  
1972 10 ▶ return $self->_call_path_method(
Branch: 1 branch
BranchTrueFalseTotal
$node->is_weak_write ? : 2 8 10
1973 $path_obj,
1974 $method_name,
1975 [ $root_value, $rhs, $op, $node->is_weak_write ? 1 : 0 ],
1976 $file,
1977 $line,
1978 );
1979 }
1980  
1981 35415 ▶sub eval_if {
Subroutine eval_if: called CC=3 SCAR=11.0
Pod documented
1982 35415 my ($self, $node) = @_;
1983  
1984 35415 my $c = $node->cond->evaluate($self);
1985 35415 ▶ if ( $self->_to_Boolean($c) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_to_Boolean($c)) 8593 26822 35415
1986  
1987 8593 return $node->then_block->evaluate($self);
1988 }
1989 26822 ▶ if ($node->else_branch) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->else_branch) 5018 21804 26822
1990  
1991 5018 return $node->else_branch->evaluate($self);
1992 }
1993  
1994 21804 return undef;
1995 }
1996  
1997 7693 ▶sub eval_while {
Subroutine eval_while: called CC=9 SCAR=22.0
Pod documented
1998 7693 my ($self, $node) = @_;
1999  
2000 7693 my $v;
2001 7693 ▶ while ( $self->_to_Boolean( $node->cond->evaluate($self) ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_to_Boolean($node->cond->evaluate($self))) 22713 7339 30052
2002 22713 ▶ eval { $v = $node->body->evaluate($self); 1 } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $v = $node->body->evaluate($self); 1 } } or do { my $e = $@; if (ref $e and $e->{"_control"} and $e->{"_control"} eq "next") { next; } ; if (ref $e and $e->{"_control"} and $e->{"_control"} eq "last") { last; } ; die $e } 22203 510 22713
2003 510 my $e = $@;
2004 510 ▶ if (ref($e) && $e->{_control} && $e->{_control} eq 'next') { next; }
Branch: 1 branch
BranchTrueFalseTotal
if (ref $e and $e->{"_control"} and $e->{"_control"} eq "next") 156 354 510
Condition83%5/6
ref $e and $e->{"_control"} and $e->{"_control"} eq "next"
!ll&&!rl&&r
1353156
ref $e and $e->{"_control"}
!ll&&!rl&&r
01509
MC/DC66%2/3
ref $e and $e->{"_control"} and $e->{"_control"} eq "next"
ref $e $e->{"_control"} $e->{"_control"} eq "next"
Truth table75%3/4
A and B and C
A= ref $eB= $e->{"_control"}C= $e->{"_control"} eq "next"
ABCresult
0XX0
10X0
1100
1111
2005 354 ▶ if (ref($e) && $e->{_control} && $e->{_control} eq 'last') { last; }
Branch: 1 branch
BranchTrueFalseTotal
if (ref $e and $e->{"_control"} and $e->{"_control"} eq "last") 84 270 354
Condition83%5/6
ref $e and $e->{"_control"} and $e->{"_control"} eq "last"
!ll&&!rl&&r
126984
ref $e and $e->{"_control"}
!ll&&!rl&&r
01353
MC/DC66%2/3
ref $e and $e->{"_control"} and $e->{"_control"} eq "last"
ref $e $e->{"_control"} $e->{"_control"} eq "last"
Truth table75%3/4
A and B and C
A= ref $eB= $e->{"_control"}C= $e->{"_control"} eq "last"
ABCresult
0XX0
10X0
1100
1111
2006 270 die $e;
2007 };
2008 }
2009  
2010 7423 return $v;
2011 }
2012  
2013 2075 ▶sub eval_for {
Subroutine eval_for: called CC=42 SCAR=58.8
Pod documented
2014 2075 my ($self, $node) = @_;
2015  
2016 2075 my $col = $node->collection->evaluate($self);
2017 2072 my $iter_fn;
2018  
2019 my @items;
2020 2072 ▶ if (blessed($col) and $col->isa('Zuzu::Value::Array')) {
Branch: 9 branches
BranchTrueFalseTotal
if (builtin::blessed($col) and $col->isa('Zuzu::Value::Array')) { } 2006 66 2072
elsif (builtin::blessed($col) and $col->isa('Zuzu::Value::Dict')) { } 0 66 66
elsif (builtin::blessed($col) and $col->isa('Zuzu::Value::PairList')) { } 0 66 66
elsif (builtin::blessed($col) and $col->isa('Zuzu::Value::Set')) { } 66 0 66
elsif (builtin::blessed($col) and $col->isa('Zuzu::Value::Bag')) { } 0 0 0
elsif (builtin::blessed($col) and $col->isa('Zuzu::Value::Function')) { } 0 0 0
elsif (builtin::blessed($col) and $col->isa('Zuzu::Value::Object')) { } 0 0 0
elsif (builtin::blessed($col) and $col->isa('Zuzu::Value::BinaryString')) { } 0 0 0
elsif (not ref $col and defined $col and Zuzu::Value::Equality::equality_type($col) eq 'String') { } 0 0 0
Condition66%2/3
builtin::blessed($col) and $col->isa("Zuzu::Value::Array")
!ll&&!rl&&r
0662006
MC/DC50%1/2
builtin::blessed($col) and $col->isa("Zuzu::Value::Array")
builtin::blessed($col) $col->isa("Zuzu::Value::Array")
Truth table66%2/3
A and B
A= builtin::blessed($col)B= $col->isa("Zuzu::Value::Array")
ABresult
0X0
100
111
2021 2006 @items = $col->resolved_items;
2022 ▶ } elsif (blessed($col) and $col->isa('Zuzu::Value::Dict')) {
Condition33%1/3
builtin::blessed($col) and $col->isa("Zuzu::Value::Dict")
!ll&&!rl&&r
0660
MC/DC0%0/2
builtin::blessed($col) and $col->isa("Zuzu::Value::Dict")
builtin::blessed($col) $col->isa("Zuzu::Value::Dict")
Truth table33%1/3
A and B
A= builtin::blessed($col)B= $col->isa("Zuzu::Value::Dict")
ABresult
0X0
100
111
2023 0 @items = sort keys %{$col->map};
2024 ▶ } elsif (blessed($col) and $col->isa('Zuzu::Value::PairList')) {
Condition33%1/3
builtin::blessed($col) and $col->isa("Zuzu::Value::PairList")
!ll&&!rl&&r
0660
MC/DC0%0/2
builtin::blessed($col) and $col->isa("Zuzu::Value::PairList")
builtin::blessed($col) $col->isa("Zuzu::Value::PairList")
Truth table33%1/3
A and B
A= builtin::blessed($col)B= $col->isa("Zuzu::Value::PairList")
ABresult
0X0
100
111
2025 0 @items = map { $_->[0] } @{ $col->list };
2026 ▶ } elsif (blessed($col) and $col->isa('Zuzu::Value::Set')) {
Condition33%1/3
builtin::blessed($col) and $col->isa("Zuzu::Value::Set")
!ll&&!rl&&r
0066
MC/DC0%0/2
builtin::blessed($col) and $col->isa("Zuzu::Value::Set")
builtin::blessed($col) $col->isa("Zuzu::Value::Set")
Truth table33%1/3
A and B
A= builtin::blessed($col)B= $col->isa("Zuzu::Value::Set")
ABresult
0X0
100
111
2027 66 @items = $col->resolved_items;
2028 ▶ } elsif (blessed($col) and $col->isa('Zuzu::Value::Bag')) {
Condition0%0/3
builtin::blessed($col) and $col->isa("Zuzu::Value::Bag")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($col) and $col->isa("Zuzu::Value::Bag")
builtin::blessed($col) $col->isa("Zuzu::Value::Bag")
Truth table0%0/3
A and B
A= builtin::blessed($col)B= $col->isa("Zuzu::Value::Bag")
ABresult
0X0
100
111
2029 0 @items = $col->resolved_items;
2030 ▶ } elsif ( blessed($col) and $col->isa('Zuzu::Value::Function') ) {
Condition0%0/3
builtin::blessed($col) and $col->isa("Zuzu::Value::Function")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($col) and $col->isa("Zuzu::Value::Function")
builtin::blessed($col) $col->isa("Zuzu::Value::Function")
Truth table0%0/3
A and B
A= builtin::blessed($col)B= $col->isa("Zuzu::Value::Function")
ABresult
0X0
100
111
2031 0 $iter_fn = $col;
2032 ▶ } elsif ( blessed($col) and $col->isa('Zuzu::Value::Object') ) {
Condition0%0/3
builtin::blessed($col) and $col->isa("Zuzu::Value::Object")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($col) and $col->isa("Zuzu::Value::Object")
builtin::blessed($col) $col->isa("Zuzu::Value::Object")
Truth table0%0/3
A and B
A= builtin::blessed($col)B= $col->isa("Zuzu::Value::Object")
ABresult
0X0
100
111
2033 0 my $to_iterator = $self->_lookup_method( $col->class, 'to_Iterator', 0 );
2034 0 ▶ if ( $to_iterator ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($to_iterator) { } 0 0 0
2035 0 my $iter = $self->_call_method(
2036 $to_iterator,
2037 $col,
2038 [],
2039 {},
2040 [],
2041 $node->file,
2042 $node->line,
2043 );
2044 0 ▶ die Zuzu::Error->new_runtime(
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($iter) and $iter->isa("Zuzu::Value::Function") 0 0 0
Condition0%0/3
builtin::blessed($iter) and $iter->isa("Zuzu::Value::Function")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($iter) and $iter->isa("Zuzu::Value::Function")
builtin::blessed($iter) $iter->isa("Zuzu::Value::Function")
Truth table0%0/3
A and B
A= builtin::blessed($iter)B= $iter->isa("Zuzu::Value::Function")
ABresult
0X0
100
111
2045 message => "for(...) to_Iterator must return a Function",
2046 file => $node->file,
2047 line => $node->line,
2048 ) if !blessed($iter) or !$iter->isa('Zuzu::Value::Function');
2049 0 $iter_fn = $iter;
2050 } else {
2051 0 my $to_array = $self->_lookup_method( $col->class, 'to_Array', 0 );
2052 0 ▶ if ( $to_array ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($to_array) 0 0 0
2053 0 my $array = $self->_call_method(
2054 $to_array,
2055 $col,
2056 [],
2057 {},
2058 [],
2059 $node->file,
2060 $node->line,
2061 );
2062 0 my $array_like = $self->_unwrap_builtin_collection( $array, 'Array' );
2063 0 ▶ die Zuzu::Error->new_runtime(
Branch: 1 branch
BranchTrueFalseTotal
unless $array_like 0 0 0
2064 message => "for(...) to_Array must return an Array",
2065 file => $node->file,
2066 line => $node->line,
2067 ) if !$array_like;
2068 0 @items = $array_like->resolved_items;
2069 }
2070 }
2071 ▶ } elsif ( blessed($col) and $col->isa('Zuzu::Value::BinaryString') ) {
Condition0%0/3
builtin::blessed($col) and $col->isa("Zuzu::Value::BinaryString")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($col) and $col->isa("Zuzu::Value::BinaryString")
builtin::blessed($col) $col->isa("Zuzu::Value::BinaryString")
Truth table0%0/3
A and B
A= builtin::blessed($col)B= $col->isa("Zuzu::Value::BinaryString")
ABresult
0X0
100
111
2072 # Iterate byte-by-byte, each as a 1-byte BinaryString.
2073 @items = map {
2074 0 ▶ Zuzu::Value::BinaryString->new( bytes => $_ )
Condition0%0/2
$col->bytes // ""
l!l
00
MC/DC0%0/1
$col->bytes // ""
$col->bytes
Truth table0%0/2
A
A= $col->bytes
Aresult
11
00
2075 } split //, ( $col->bytes // '' );
2076 ▶ } elsif ( !ref($col) and defined($col) and Zuzu::Value::Equality::equality_type($col) eq 'String' ) {
Condition0%0/6
not ref $col and defined $col and Zuzu::Value::Equality::equality_type($col) eq "String"
!ll&&!rl&&r
000
not ref $col and defined $col
!ll&&!rl&&r
000
MC/DC0%0/3
not ref $col and defined $col and Zuzu::Value::Equality::equality_type($col) eq "String"
not ref $col defined $col Zuzu::Value::Equality::equality_type($col) eq "String"
Truth table0%0/4
not(A) and B and C
A= not ref $colB= defined $colC= Zuzu::Value::Equality::equality_type($col) eq "String"
ABCresult
0XX0
10X0
1100
1111
2077 # Iterate character-by-character, each as a 1-char String.
2078 0 @items = split //, $col;
2079 } else {
2080 0 die Zuzu::Error->new_runtime(message => "for(...) expects Array, Dict, PairList, Set, Bag, Function, String, BinaryString, or convertible Object", file => $node->file, line => $node->line);
2081 }
2082  
2083 2072 ▶ if ( !@items and !defined $iter_fn ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@items or defined $iter_fn) 20 2052 2072
Condition66%2/3
@items or defined $iter_fn
l!l&&r!l&&!r
2052020
MC/DC50%1/2
@items or defined $iter_fn
@items defined $iter_fn
Truth table66%2/3
A or B
A= @itemsB= defined $iter_fn
ABresult
1X1
011
000
2084  
2085 20 ▶ return $node->else_block ? $node->else_block->evaluate($self) : undef;
Branch: 1 branch
BranchTrueFalseTotal
$node->else_block ? : 1 19 20
2086 }
2087  
2088 2052 my $v;
2089 2052 my $has_any = 0;
2090 11819 ▶ my $run_body = sub {
Subroutine __ANON__: called CC=19 SCAR=31.4
2091 11819 my ( $it ) = @_;
2092  
2093 11819 ▶ my $using_inner_loop_scope = $node->declare_loop_var ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$node->declare_loop_var ? : 11816 3 11819
2094 11819 ▶ if ($using_inner_loop_scope) {
Branch: 1 branch
BranchTrueFalseTotal
if ($using_inner_loop_scope) { } 11816 3 11819
2095 11816 my $env = Zuzu::Env->_new_fast( $self->{_stack}[-1] ); # inlined $self->_env
2096 11816 push @{$self->{_stack}}, $env; # inlined $self->_push_env
2097 11816 ▶ my $const_flag = ( defined $node->loop_var_kind and $node->loop_var_kind eq 'const' ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $node->loop_var_kind && $node->loop_var_kind eq 'const' ? : 8 11808 11816
Condition66%2/3
defined $node->loop_var_kind and $node->loop_var_kind eq "const"
!ll&&!rl&&r
0118088
MC/DC50%1/2
defined $node->loop_var_kind and $node->loop_var_kind eq "const"
defined $node->loop_var_kind $node->loop_var_kind eq "const"
Truth table66%2/3
A and B
A= defined $node->loop_var_kindB= $node->loop_var_kind eq "const"
ABresult
0X0
100
111
2098 11816 $env->declare($node->var, $it, $const_flag);
2099 }
2100 else {
2101 3 my $ref = $self->_env->find_ref($node->var);
2102 3 ▶ die Zuzu::Error->new_runtime(
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ref 0 3 3
2103 message => "Use of undeclared variable '".$node->var."'",
2104 file => $node->file,
2105 line => $node->line,
2106 ) if !defined $ref;
2107  
2108 3 my $const_here = $self->_env->is_const_here($node->var);
2109 3 ▶ if (!defined $const_here) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $const_here) 0 3 3
2110 0 my $env = $self->_env;
2111 0 ▶ while ($env) {
Branch: 1 branch
BranchTrueFalseTotal
if ($env) 0 0 0
2112 0 ▶ if (exists $env->{slots}{ $node->var }) { $const_here = $env->{const}{ $node->var }; last; }
Branch: 1 branch
BranchTrueFalseTotal
if (exists $env->{"slots"}{$node->var}) 0 0 0
2113 0 $env = $env->{parent};
2114 }
2115 }
2116 3 ▶ die Zuzu::Error->new_runtime(
Branch: 1 branch
BranchTrueFalseTotal
if $const_here 0 3 3
2117 message => "Cannot assign to const '".$node->var."'",
2118 file => $node->file,
2119 line => $node->line,
2120 ) if $const_here;
2121  
2122 3 my $declared_type = $self->_env->declared_type_for($node->var);
2123 3 $self->_assert_declared_type( $declared_type, $it, $node->file, $node->line, $node->var );
2124 3 $$ref = $it;
2125 }
2126  
2127 11819 ▶ eval { $v = $node->body->evaluate($self); 1 } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $v = $node->body->evaluate($self); 1 } } or do { my $e = $@; pop @{$$self{"_stack"};} if $using_inner_loop_scope; return "next" if ref $e and $e->{"_control"} and $e->{"_control"} eq "next"; return "last" if ref $e and $e->{"_control"} and $e->{"_control"} eq "last"; die $e } 11746 73 11819
2128 73 my $e = $@;
2129 73 ▶ pop @{$self->{_stack}} if $using_inner_loop_scope; # inlined $self->_pop_env
Branch: 1 branch
BranchTrueFalseTotal
if $using_inner_loop_scope 73 0 73
2130 73 ▶ return 'next' if ref($e) and $e->{_control} and $e->{_control} eq 'next';
Branch: 1 branch
BranchTrueFalseTotal
if ref $e and $e->{"_control"} and $e->{"_control"} eq "next" 40 33 73
Condition83%5/6
ref $e and $e->{"_control"} and $e->{"_control"} eq "next"
!ll&&!rl&&r
42940
ref $e and $e->{"_control"}
!ll&&!rl&&r
0469
MC/DC66%2/3
ref $e and $e->{"_control"} and $e->{"_control"} eq "next"
ref $e $e->{"_control"} $e->{"_control"} eq "next"
Truth table75%3/4
A and B and C
A= ref $eB= $e->{"_control"}C= $e->{"_control"} eq "next"
ABCresult
0XX0
10X0
1100
1111
2131 33 ▶ return 'last' if ref($e) and $e->{_control} and $e->{_control} eq 'last';
Branch: 1 branch
BranchTrueFalseTotal
if ref $e and $e->{"_control"} and $e->{"_control"} eq "last" 1 32 33
Condition83%5/6
ref $e and $e->{"_control"} and $e->{"_control"} eq "last"
!ll&&!rl&&r
4281
ref $e and $e->{"_control"}
!ll&&!rl&&r
0429
MC/DC66%2/3
ref $e and $e->{"_control"} and $e->{"_control"} eq "last"
ref $e $e->{"_control"} $e->{"_control"} eq "last"
Truth table75%3/4
A and B and C
A= ref $eB= $e->{"_control"}C= $e->{"_control"} eq "last"
ABCresult
0XX0
10X0
1100
1111
2132 32 die $e;
2133 };
2134  
2135 11746 ▶ pop @{$self->{_stack}} if $using_inner_loop_scope; # inlined $self->_pop_env
Branch: 1 branch
BranchTrueFalseTotal
if $using_inner_loop_scope 11743 3 11746
2136 11746 return 'ok';
2137 2052 };
2138  
2139 2052 ▶ if ( defined $iter_fn ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $iter_fn) { } 0 2052 2052
2140 0 my $exhausted_class = $self->{_builtin_classes}{ExhaustedException};
2141 0 while (1) {
2142 0 my $next_item;
2143 eval {
2144 0 $next_item = $self->_call_function(
2145 $iter_fn,
2146 [],
2147 {},
2148 [],
2149 $node->file,
2150 $node->line,
2151 );
2152 0 1;
2153 0 ▶ } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $next_item = $self->_call_function($iter_fn, [], {}, [], $node->file, $node->line); 1 } } or do { my $e = $@; if (ref $e and $e->{"_zuzu_throw"}) { my $thrown = $e->{"value"}; if (defined $exhausted_class and $self->_value_matches_class($thrown, $exhausted_class)) { last; } ; } ; die $e } 0 0 0
2154 0 my $e = $@;
2155 0 ▶ if ( ref($e) and $e->{_zuzu_throw} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $e and $e->{"_zuzu_throw"}) 0 0 0
Condition0%0/3
ref $e and $e->{"_zuzu_throw"}
!ll&&!rl&&r
000
MC/DC0%0/2
ref $e and $e->{"_zuzu_throw"}
ref $e $e->{"_zuzu_throw"}
Truth table0%0/3
A and B
A= ref $eB= $e->{"_zuzu_throw"}
ABresult
0X0
100
111
2156 0 my $thrown = $e->{value};
2157 0 ▶ if ( defined $exhausted_class and $self->_value_matches_class( $thrown, $exhausted_class ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $exhausted_class and $self->_value_matches_class($thrown, $exhausted_class)) 0 0 0
Condition0%0/3
defined $exhausted_class and $self->_value_matches_class($thrown, $exhausted_class)
!ll&&!rl&&r
000
MC/DC0%0/2
defined $exhausted_class and $self->_value_matches_class($thrown, $exhausted_class)
defined $exhausted_class $self->_value_matches_class($thrown, $exhausted_class)
Truth table0%0/3
A and B
A= defined $exhausted_classB= $self->_value_matches_class($thrown, $exhausted_class)
ABresult
0X0
100
111
2158 0 last;
2159 }
2160 }
2161 0 die $e;
2162 };
2163 0 $has_any = 1;
2164 0 my $control = $run_body->( $next_item );
2165 0 ▶ next if $control eq 'next';
Branch: 1 branch
BranchTrueFalseTotal
if $control eq "next" 0 0 0
2166 0 ▶ last if $control eq 'last';
Branch: 1 branch
BranchTrueFalseTotal
if $control eq "last" 0 0 0
2167 }
2168 } else {
2169 2052 for my $it (@items) {
2170 11819 $has_any = 1;
2171 11819 my $control = $run_body->($it);
2172 11787 ▶ next if $control eq 'next';
Branch: 1 branch
BranchTrueFalseTotal
if $control eq "next" 40 11747 11787
2173 11747 ▶ last if $control eq 'last';
Branch: 1 branch
BranchTrueFalseTotal
if $control eq "last" 1 11746 11747
2174 }
2175 }
2176  
2177 2020 ▶ if ( !$has_any ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($has_any) 0 2020 2020
2178 0 ▶ return $node->else_block ? $node->else_block->evaluate($self) : undef;
Branch: 1 branch
BranchTrueFalseTotal
$node->else_block ? : 0 0 0
2179 }
2180  
2181 2020 return $v;
2182 }
2183  
2184 32 ▶sub eval_switch {
Subroutine eval_switch: called CC=44 SCAR=58.2
Pod undocumented
2185 32 my ( $self, $node ) = @_;
2186  
2187 32 my $value = $node->value_expr->evaluate($self);
2188 32 my $env = Zuzu::Env->_new_fast( $self->{_stack}[-1] );
2189 32 $self->_push_env($env);
2190 32 $env->declare( '^^', $value, 1, 'Any' );
2191  
2192 32 my $matched = 0;
2193 32 my $fell_through = 0;
2194 32 my $result;
2195 32 ▶ my $cases = $node->cases // [];
Condition50%1/2
$node->cases // []
l!l
320
MC/DC0%0/1
$node->cases // []
$node->cases
Truth table50%1/2
A
A= $node->cases
Aresult
11
00
2196 32 my $dispatch = $self->_switch_dispatch_table( $node, $cases, $value );
2197 32 my $ok = eval {
2198 SWITCH_EVAL: {
2199 32 ▶ if ( $dispatch and exists $dispatch->{case_index} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dispatch and exists $dispatch->{"case_index"}) 31 1 32
Condition66%2/3
$dispatch and exists $dispatch->{"case_index"}
!ll&&!rl&&r
1031
MC/DC50%1/2
$dispatch and exists $dispatch->{"case_index"}
$dispatch exists $dispatch->{"case_index"}
Truth table66%2/3
A and B
A= $dispatchB= exists $dispatch->{"case_index"}
ABresult
0X0
100
111
2200 31 my $start_index = $dispatch->{case_index};
2201 31 $matched = 1;
2202 31 for my $case ( @{$cases}[ $start_index .. $#$cases ] ) {
2203 31 $fell_through = 0;
2204  
2205 eval {
2206 31 $result = $case->{body}->evaluate($self);
2207 1 1;
2208 31 ▶ } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $result = $case->{"body"}->evaluate($self); 1 } } or do { my $e = $@; if (ref $e and $e->{"_control"} and $e->{"_control"} eq "continue") { $fell_through = 1; next; } ; die $e } 1 30 31
2209 30 my $e = $@;
2210 30 ▶ if ( ref($e) and $e->{_control} and $e->{_control} eq 'continue' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $e and $e->{"_control"} and $e->{"_control"} eq "continue") 0 30 30
Condition66%4/6
ref $e and $e->{"_control"} and $e->{"_control"} eq "continue"
!ll&&!rl&&r
1290
ref $e and $e->{"_control"}
!ll&&!rl&&r
0129
MC/DC0%0/3
ref $e and $e->{"_control"} and $e->{"_control"} eq "continue"
ref $e $e->{"_control"} $e->{"_control"} eq "continue"
Truth table50%2/4
A and B and C
A= ref $eB= $e->{"_control"}C= $e->{"_control"} eq "continue"
ABCresult
0XX0
10X0
1100
1111
2211 0 $fell_through = 1;
2212 0 next;
2213 }
2214 30 die $e;
2215 };
2216  
2217 1 ▶ last if !$fell_through;
Branch: 1 branch
BranchTrueFalseTotal
unless $fell_through 1 0 1
2218 }
2219 1 ▶ if ( ( !$matched || $fell_through ) and defined $node->default_block ) {
Branch: 1 branch
BranchTrueFalseTotal
if (!$matched || $fell_through and defined $node->default_block) 0 1 1
Condition33%2/6
!$matched || $fell_through and defined $node->default_block
!ll&&!rl&&r
100
not $matched or $fell_through
l!l&&r!l&&!r
001
MC/DC0%0/3
!$matched || $fell_through and defined $node->default_block
not $matched $fell_through defined $node->default_block
Truth table20%1/5
not(A) or B and C
A= not $matchedB= $fell_throughC= defined $node->default_block
ABCresult
00X0
1X00
0100
1X11
0111
2220 eval {
2221 0 $result = $node->default_block->evaluate($self);
2222 0 1;
2223 0 ▶ } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $result = $node->default_block->evaluate($self); 1 } } or do { my $e = $@; if (ref $e and $e->{"_control"} and $e->{"_control"} eq "continue") { last SWITCH_EVAL; } ; die $e } 0 0 0
2224 0 my $e = $@;
2225 0 ▶ if ( ref($e) and $e->{_control} and $e->{_control} eq 'continue' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $e and $e->{"_control"} and $e->{"_control"} eq "continue") 0 0 0
Condition0%0/6
ref $e and $e->{"_control"} and $e->{"_control"} eq "continue"
!ll&&!rl&&r
000
ref $e and $e->{"_control"}
!ll&&!rl&&r
000
MC/DC0%0/3
ref $e and $e->{"_control"} and $e->{"_control"} eq "continue"
ref $e $e->{"_control"} $e->{"_control"} eq "continue"
Truth table0%0/4
A and B and C
A= ref $eB= $e->{"_control"}C= $e->{"_control"} eq "continue"
ABCresult
0XX0
10X0
1100
1111
2226 0 last SWITCH_EVAL;
2227 }
2228 0 die $e;
2229 };
2230 }
2231 1 last SWITCH_EVAL;
2232 }
2233 1 ▶ if ( $dispatch and $dispatch->{eligible} and defined $node->default_block ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dispatch and $dispatch->{"eligible"} and defined $node->default_block) 0 1 1
Condition33%2/6
$dispatch and $dispatch->{"eligible"} and defined $node->default_block
!ll&&!rl&&r
100
$dispatch and $dispatch->{"eligible"}
!ll&&!rl&&r
100
MC/DC0%0/3
$dispatch and $dispatch->{"eligible"} and defined $node->default_block
$dispatch $dispatch->{"eligible"} defined $node->default_block
Truth table25%1/4
A and B and C
A= $dispatchB= $dispatch->{"eligible"}C= defined $node->default_block
ABCresult
0XX0
10X0
1100
1111
2234 eval {
2235 0 $result = $node->default_block->evaluate($self);
2236 0 1;
2237 0 ▶ } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $result = $node->default_block->evaluate($self); 1 } } or do { my $e = $@; if (ref $e and $e->{"_control"} and $e->{"_control"} eq "continue") { last SWITCH_EVAL; } ; die $e } 0 0 0
2238 0 my $e = $@;
2239 0 ▶ if ( ref($e) and $e->{_control} and $e->{_control} eq 'continue' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $e and $e->{"_control"} and $e->{"_control"} eq "continue") 0 0 0
Condition0%0/6
ref $e and $e->{"_control"} and $e->{"_control"} eq "continue"
!ll&&!rl&&r
000
ref $e and $e->{"_control"}
!ll&&!rl&&r
000
MC/DC0%0/3
ref $e and $e->{"_control"} and $e->{"_control"} eq "continue"
ref $e $e->{"_control"} $e->{"_control"} eq "continue"
Truth table0%0/4
A and B and C
A= ref $eB= $e->{"_control"}C= $e->{"_control"} eq "continue"
ABCresult
0XX0
10X0
1100
1111
2240 0 last SWITCH_EVAL;
2241 }
2242 0 die $e;
2243 };
2244 0 last SWITCH_EVAL;
2245 }
2246  
2247 CASE:
2248 1 for my $case ( @$cases ) {
2249 1 ▶ if ( !$matched ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($matched) 1 0 1
2250 1 ▶ for my $case_value ( @{ $case->{values} // [] } ) {
Condition50%1/2
$case->{"values"} // []
l!l
10
MC/DC0%0/1
$case->{"values"} // []
$case->{"values"}
Truth table50%1/2
A
A= $case->{"values"}
Aresult
11
00
2251 1 my $operator = $node->comparator;
2252 1 my $candidate_expr = $case_value;
2253 1 ▶ if ( ref($case_value) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $case_value eq "HASH") 1 0 1
2254 1 ▶ $operator = $case_value->{operator} // $operator;
Condition33%1/3
$case_value->{"operator"} // $operator
l!l&&r!l&&!r
010
MC/DC0%0/2
$case_value->{"operator"} // $operator
$case_value->{"operator"} $operator
Truth table33%1/3
A // B
A= $case_value->{"operator"}B= $operator
ABresult
1X1
011
000
2255 1 $candidate_expr = $case_value->{value};
2256 }
2257 1 my $candidate = $candidate_expr->evaluate($self);
2258 1 ▶ if ( $self->_switch_matches( $operator, $value, $candidate, $node->file, $node->line ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_switch_matches($operator, $value, $candidate, $node->file, $node->line)) 1 0 1
2259 1 $matched = 1;
2260 1 last;
2261 }
2262 }
2263 }
2264  
2265 1 ▶ next if !$matched;
Branch: 1 branch
BranchTrueFalseTotal
unless $matched 0 1 1
2266 1 $fell_through = 0;
2267  
2268 eval {
2269 1 $result = $case->{body}->evaluate($self);
2270 1 1;
2271 1 ▶ } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $result = $case->{"body"}->evaluate($self); 1 } } or do { my $e = $@; if (ref $e and $e->{"_control"} and $e->{"_control"} eq "continue") { $fell_through = 1; next CASE; } ; die $e } 1 0 1
2272 0 my $e = $@;
2273 0 ▶ if ( ref($e) and $e->{_control} and $e->{_control} eq 'continue' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $e and $e->{"_control"} and $e->{"_control"} eq "continue") 0 0 0
Condition0%0/6
ref $e and $e->{"_control"} and $e->{"_control"} eq "continue"
!ll&&!rl&&r
000
ref $e and $e->{"_control"}
!ll&&!rl&&r
000
MC/DC0%0/3
ref $e and $e->{"_control"} and $e->{"_control"} eq "continue"
ref $e $e->{"_control"} $e->{"_control"} eq "continue"
Truth table0%0/4
A and B and C
A= ref $eB= $e->{"_control"}C= $e->{"_control"} eq "continue"
ABCresult
0XX0
10X0
1100
1111
2274 0 $fell_through = 1;
2275 0 next CASE;
2276 }
2277 0 die $e;
2278 };
2279  
2280 1 last CASE;
2281 }
2282  
2283 1 ▶ if ( ( !$matched or $fell_through ) and defined $node->default_block ) {
Branch: 1 branch
BranchTrueFalseTotal
if (!$matched || $fell_through and defined $node->default_block) 0 1 1
Condition33%2/6
!$matched || $fell_through and defined $node->default_block
!ll&&!rl&&r
100
not $matched or $fell_through
l!l&&r!l&&!r
001
MC/DC0%0/3
!$matched || $fell_through and defined $node->default_block
not $matched $fell_through defined $node->default_block
Truth table20%1/5
not(A) or B and C
A= not $matchedB= $fell_throughC= defined $node->default_block
ABCresult
00X0
1X00
0100
1X11
0111
2284 eval {
2285 0 $result = $node->default_block->evaluate($self);
2286 0 1;
2287 0 ▶ } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $result = $node->default_block->evaluate($self); 1 } } or do { my $e = $@; if (ref $e and $e->{"_control"} and $e->{"_control"} eq "continue") { last SWITCH_EVAL; } ; die $e } 0 0 0
2288 0 my $e = $@;
2289 0 ▶ if ( ref($e) and $e->{_control} and $e->{_control} eq 'continue' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $e and $e->{"_control"} and $e->{"_control"} eq "continue") 0 0 0
Condition0%0/6
ref $e and $e->{"_control"} and $e->{"_control"} eq "continue"
!ll&&!rl&&r
000
ref $e and $e->{"_control"}
!ll&&!rl&&r
000
MC/DC0%0/3
ref $e and $e->{"_control"} and $e->{"_control"} eq "continue"
ref $e $e->{"_control"} $e->{"_control"} eq "continue"
Truth table0%0/4
A and B and C
A= ref $eB= $e->{"_control"}C= $e->{"_control"} eq "continue"
ABCresult
0XX0
10X0
1100
1111
2290 0 last SWITCH_EVAL;
2291 }
2292 0 die $e;
2293 };
2294 }
2295 }
2296  
2297 2 1;
2298 };
2299 32 my $err = $@;
2300 32 $self->_pop_env;
2301 32 ▶ die $err if !$ok;
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 30 2 32
2302  
2303 2 return $result;
2304 }
2305  
2306 32 ▶sub _switch_dispatch_table {
Subroutine _switch_dispatch_table: called CC=19 SCAR=32.0
2307 32 my ( $self, $node, $cases, $value ) = @_;
2308  
2309 32 ▶ my $header_operator = $node->comparator // '==';
Condition50%1/2
$node->comparator // "=="
l!l
320
MC/DC0%0/1
$node->comparator // "=="
$node->comparator
Truth table50%1/2
A
A= $node->comparator
Aresult
11
00
2310 32 my %entries;
2311 32 my $eligible = 0;
2312 32 my $common_operator;
2313 32 for my $case_index ( 0 .. $#$cases ) {
2314 244 my $case = $cases->[$case_index];
2315 244 ▶ for my $case_value ( @{ $case->{values} // [] } ) {
Condition50%1/2
$case->{"values"} // []
l!l
2440
MC/DC0%0/1
$case->{"values"} // []
$case->{"values"}
Truth table50%1/2
A
A= $case->{"values"}
Aresult
11
00
2316 244 my $operator = $header_operator;
2317 244 my $candidate_expr = $case_value;
2318 244 ▶ if ( ref($case_value) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $case_value eq "HASH") 244 0 244
2319 244 ▶ $operator = $case_value->{operator} // $operator;
Condition33%1/3
$case_value->{"operator"} // $operator
l!l&&r!l&&!r
02440
MC/DC0%0/2
$case_value->{"operator"} // $operator
$case_value->{"operator"} $operator
Truth table33%1/3
A // B
A= $case_value->{"operator"}B= $operator
ABresult
1X1
011
000
2320 244 $candidate_expr = $case_value->{value};
2321 }
2322 244 ▶ return if $operator ne 'eq' and $operator ne 'eqi' and $operator ne '=';
Branch: 1 branch
BranchTrueFalseTotal
if $operator ne "eq" and $operator ne "eqi" and $operator ne "=" 1 243 244
Condition83%5/6
$operator ne "eq" and $operator ne "eqi" and $operator ne "="
!ll&&!rl&&r
24031
$operator ne "eq" and $operator ne "eqi"
!ll&&!rl&&r
24004
MC/DC66%2/3
$operator ne "eq" and $operator ne "eqi" and $operator ne "="
$operator ne "eq" $operator ne "eqi" $operator ne "="
Truth table75%3/4
A and B and C
A= $operator ne "eq"B= $operator ne "eqi"C= $operator ne "="
ABCresult
0XX0
10X0
1100
1111
2323 243 ▶ $common_operator //= $operator;
Condition66%2/3
$common_operator //= $operator
l!l&&r!l&&!r
212310
MC/DC0%0/2
$common_operator //= $operator
$common_operator $operator
Truth table66%2/3
A //= B
A= $common_operatorB= $operator
ABresult
1X1
011
000
2324 243 ▶ return if $operator ne $common_operator;
Branch: 1 branch
BranchTrueFalseTotal
if $operator ne $common_operator 0 243 243
2325 243 ▶ return if !blessed($candidate_expr) or !$candidate_expr->isa('Zuzu::AST::Expr::Literal');
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($candidate_expr) and $candidate_expr->isa("Zuzu::AST::Expr::Literal") 0 243 243
Condition33%1/3
builtin::blessed($candidate_expr) and $candidate_expr->isa("Zuzu::AST::Expr::Literal")
!ll&&!rl&&r
00243
MC/DC0%0/2
builtin::blessed($candidate_expr) and $candidate_expr->isa("Zuzu::AST::Expr::Literal")
builtin::blessed($candidate_expr) $candidate_expr->isa("Zuzu::AST::Expr::Literal")
Truth table33%1/3
A and B
A= builtin::blessed($candidate_expr)B= $candidate_expr->isa("Zuzu::AST::Expr::Literal")
ABresult
0X0
100
111
2326 243 my $key = $self->_switch_dispatch_key_for_literal( $operator, $candidate_expr->value );
2327 243 ▶ return if !defined $key;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $key 0 243 243
2328 243 ▶ return if exists $entries{$key};
Branch: 1 branch
BranchTrueFalseTotal
if exists $entries{$key} 0 243 243
2329 243 $entries{$key} = $case_index;
2330 243 $eligible = 1;
2331 }
2332 }
2333 31 ▶ return if !$eligible;
Branch: 1 branch
BranchTrueFalseTotal
unless $eligible 0 31 31
2334 31 my $subject_key = $self->_switch_dispatch_key_for_value( $common_operator, $value );
2335 31 ▶ return { eligible => 1 } if !defined $subject_key;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $subject_key 0 31 31
2336 return {
2337 eligible => 1,
2338 31 ▶ ( exists $entries{$subject_key} ? ( case_index => $entries{$subject_key} ) : () ),
Branch: 1 branch
BranchTrueFalseTotal
exists $entries{$subject_key} ? : 31 0 31
2339 };
2340 }
2341  
2342 243 ▶sub _switch_dispatch_key_for_literal {
Subroutine _switch_dispatch_key_for_literal: called CC=6 SCAR=19.9
2343 243 my ( $self, $operator, $value ) = @_;
2344  
2345 243 ▶ return 'q:' . $value if $operator eq 'eq';
Branch: 1 branch
BranchTrueFalseTotal
if $operator eq "eq" 240 3 243
2346 3 ▶ return 'qi:' . CORE::fc($value) if $operator eq 'eqi';
Branch: 1 branch
BranchTrueFalseTotal
if $operator eq "eqi" 0 3 3
2347 3 ▶ if ( $operator eq '=' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($operator eq "=") 3 0 3
2348 3 ▶ return if !defined $value or $value !~ /\A-?\d+\z/;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value and $value =~ /\A-?\d+\z/ 0 3 3
Condition33%1/3
defined $value and $value =~ /\A-?\d+\z/
!ll&&!rl&&r
003
MC/DC0%0/2
defined $value and $value =~ /\A-?\d+\z/
defined $value $value =~ /\A-?\d+\z/
Truth table33%1/3
A and B
A= defined $valueB= $value =~ /\A-?\d+\z/
ABresult
0X0
100
111
2349 3 return 'i:' . ( 0 + $value );
2350 }
2351 0 return;
2352 }
2353  
2354 31 ▶sub _switch_dispatch_key_for_value {
Subroutine _switch_dispatch_key_for_value: called CC=5 SCAR=16.8
2355 31 my ( $self, $operator, $value ) = @_;
2356  
2357 31 ▶ return 'q:' . $self->_to_OperatorString($value) if $operator eq 'eq';
Branch: 1 branch
BranchTrueFalseTotal
if $operator eq "eq" 30 1 31
2358 1 ▶ return 'qi:' . CORE::fc( $self->_to_OperatorString($value) ) if $operator eq 'eqi';
Branch: 1 branch
BranchTrueFalseTotal
if $operator eq "eqi" 0 1 1
2359 1 ▶ if ( $operator eq '=' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($operator eq "=") 1 0 1
2360 1 my $number = $self->_to_Number($value);
2361 1 ▶ return if $number != int($number);
Branch: 1 branch
BranchTrueFalseTotal
if $number != int $number 0 1 1
2362 1 return 'i:' . int($number);
2363 }
2364 0 return;
2365 }
2366  
2367 6394 ▶sub eval_function_def {
Subroutine eval_function_def: called CC=16 SCAR=28.9
Pod documented
2368 6394 my ($self, $node) = @_;
2369  
2370 6394 my $ref = $self->_env->find_ref($node->name);
2371 6394 ▶ if ( $node->is_predeclared ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->is_predeclared) 111 6283 6394
2372 111 ▶ if (!$ref) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ref) 111 0 111
2373 111 $self->_env->declare(
2374 $node->name,
2375 Zuzu::Value::Function->new(
2376 name => $node->name,
2377 params => [],
2378 return_type => 'Any',
2379 closure_env => $self->_capture_env( $self->_env ),
2380 is_bodyless => 1,
2381 source_node => $node,
2382 ),
2383 1,
2384 );
2385 111 return ${ $self->_env->find_ref($node->name) };
2386 }
2387 0 die Zuzu::Error->new_runtime(
2388 message => "Redeclaration of '".$node->name."' in the same scope",
2389 file => $node->file,
2390 line => $node->line,
2391 );
2392 }
2393 6283 ▶ if (!$ref) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ref) 6172 111 6283
2394 6172 $self->_env->declare($node->name, undef, 1);
2395 6172 $ref = $self->_env->find_ref($node->name);
2396 }
2397  
2398 my $fn = Zuzu::Value::Function->new(
2399 name => $node->name,
2400 params => $node->params,
2401 vararg => $node->vararg,
2402 named_vararg => $node->named_vararg,
2403 6283 ▶ param_types => { %{ $node->param_types // {} } },
Condition50%3/6
$node->param_types // {}
l!l
62830
$node->vararg_type // "Any"
l!l
62830
$node->named_vararg_type // "PairList"
l!l
62830
MC/DC0%0/1
$node->param_types // {}
$node->param_types
MC/DC0%0/1
$node->vararg_type // "Any"
$node->vararg_type
MC/DC0%0/1
$node->named_vararg_type // "PairList"
$node->named_vararg_type
Truth table50%1/2
A
A= $node->param_types
Aresult
11
00
Truth table50%1/2
A
A= $node->vararg_type
Aresult
11
00
Truth table50%1/2
A
A= $node->named_vararg_type
Aresult
11
00
2404 vararg_type => $node->vararg_type // 'Any',
2405 named_vararg_type => $node->named_vararg_type // 'PairList',
2406 6283 ▶ param_optional => { %{ $node->param_optional // {} } },
Condition50%1/2
$node->param_optional // {}
l!l
62830
MC/DC0%0/1
$node->param_optional // {}
$node->param_optional
Truth table50%1/2
A
A= $node->param_optional
Aresult
11
00
2407 6283 ▶ param_defaults => { %{ $node->param_defaults // {} } },
Branch: 1 branch
BranchTrueFalseTotal
$node->is_async ? : 36 6247 6283
Condition50%2/4
$node->param_defaults // {}
l!l
62830
$node->return_type // "Any"
l!l
62830
MC/DC0%0/1
$node->param_defaults // {}
$node->param_defaults
MC/DC0%0/1
$node->return_type // "Any"
$node->return_type
Truth table50%1/2
A
A= $node->param_defaults
Aresult
11
00
Truth table50%1/2
A
A= $node->return_type
Aresult
11
00
2408 return_type => $node->return_type // 'Any',
2409 body => $node->body,
2410 closure_env => $self->_capture_env( $self->_env ),
2411 is_async => $node->is_async ? 1 : 0,
2412 source_node => $node,
2413 );
2414 6283 ▶ $fn->{_default_typecheck_safe} = { %{ $node->{_default_typecheck_safe} // {} } };
Condition100%2/2
$node->{"_default_typecheck_safe"} // {}
l!l
3225961
MC/DC100%1/1
$node->{"_default_typecheck_safe"} // {}
$node->{"_default_typecheck_safe"}
Truth table100%2/2
A
A= $node->{"_default_typecheck_safe"}
Aresult
11
00
2415 6283 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (defined $$ref and builtin::blessed($$ref) and $$ref->isa("Zuzu::Value::Function") and $$ref->is_bodyless) 111 6172 6283
Condition66%6/9
defined $$ref and builtin::blessed($$ref) and $$ref->isa("Zuzu::Value::Function") and $$ref->is_bodyless
!ll&&!rl&&r
61720111
defined $$ref and builtin::blessed($$ref) and $$ref->isa("Zuzu::Value::Function")
!ll&&!rl&&r
61720111
defined $$ref and builtin::blessed($$ref)
!ll&&!rl&&r
61720111
MC/DC25%1/4
defined $$ref and builtin::blessed($$ref) and $$ref->isa("Zuzu::Value::Function") and $$ref->is_bodyless
defined $$ref builtin::blessed($$ref) $$ref->isa("Zuzu::Value::Function") $$ref->is_bodyless
Truth table40%2/5
A and B and C and D
A= defined $$refB= builtin::blessed($$ref)C= $$ref->isa("Zuzu::Value::Function")D= $$ref->is_bodyless
ABCDresult
0XXX0
10XX0
110X0
11100
11111
2416 defined $$ref
2417 and blessed($$ref)
2418 and $$ref->isa('Zuzu::Value::Function')
2419 and $$ref->is_bodyless
2420 ) {
2421 111 $self->_complete_bodyless_function( $$ref, $fn );
2422 111 return $$ref;
2423 }
2424 6172 $$ref = $fn;
2425  
2426 6172 return $fn;
2427 }
2428  
2429 114 ▶sub _complete_bodyless_function {
Subroutine _complete_bodyless_function: called CC=5 SCAR=16.1
2430 114 my ( $self, $target, $source ) = @_;
2431  
2432 114 for my $field (
2433 qw(
2434 params vararg named_vararg param_types vararg_type named_vararg_type
2435 param_optional param_defaults return_type body closure_env is_async
2436 source_node
2437 )
2438 ) {
2439 1482 $target->$field( $source->$field );
2440 }
2441 114 $target->is_bodyless(0);
2442 114 ▶ $target->{_default_typecheck_safe} = { %{ $source->{_default_typecheck_safe} // {} } };
Condition50%1/2
$source->{"_default_typecheck_safe"} // {}
l!l
1140
MC/DC0%0/1
$source->{"_default_typecheck_safe"} // {}
$source->{"_default_typecheck_safe"}
Truth table50%1/2
A
A= $source->{"_default_typecheck_safe"}
Aresult
11
00
2443 114 for my $key (
2444 qw(
2445 _owner_class _method_name _method_kind _method_source _uses_super
2446 )
2447 ) {
2448 570 ▶ $target->{$key} = $source->{$key} if exists $source->{$key};
Branch: 1 branch
BranchTrueFalseTotal
if exists $source->{$key} 11 559 570
2449 }
2450  
2451 114 return $target;
2452 }
2453  
2454 18650 ▶sub _function_from_method_decl {
Subroutine _function_from_method_decl: called CC=11 SCAR=25.4
2455 18650 my ( $self, $m, $closure_env ) = @_;
2456  
2457 my $fn = Zuzu::Value::Function->new(
2458 name => $m->name,
2459 18650 ▶ params => [ @{ $m->params // [] } ],
Condition50%1/2
$m->params // []
l!l
186500
MC/DC0%0/1
$m->params // []
$m->params
Truth table50%1/2
A
A= $m->params
Aresult
11
00
2460 vararg => $m->vararg,
2461 named_vararg => $m->named_vararg,
2462 18650 ▶ param_types => { %{ $m->param_types // {} } },
Condition50%3/6
$m->param_types // {}
l!l
186500
$m->vararg_type // "Any"
l!l
186500
$m->named_vararg_type // "PairList"
l!l
186500
MC/DC0%0/1
$m->param_types // {}
$m->param_types
MC/DC0%0/1
$m->vararg_type // "Any"
$m->vararg_type
MC/DC0%0/1
$m->named_vararg_type // "PairList"
$m->named_vararg_type
Truth table50%1/2
A
A= $m->param_types
Aresult
11
00
Truth table50%1/2
A
A= $m->vararg_type
Aresult
11
00
Truth table50%1/2
A
A= $m->named_vararg_type
Aresult
11
00
2463 vararg_type => $m->vararg_type // 'Any',
2464 named_vararg_type => $m->named_vararg_type // 'PairList',
2465 18650 ▶ param_optional => { %{ $m->param_optional // {} } },
Condition50%1/2
$m->param_optional // {}
l!l
186500
MC/DC0%0/1
$m->param_optional // {}
$m->param_optional
Truth table50%1/2
A
A= $m->param_optional
Aresult
11
00
2466 18650 ▶ param_defaults => { %{ $m->param_defaults // {} } },
Branch: 2 branches
BranchTrueFalseTotal
$m->is_async ? : 2 18648 18650
$m->is_predeclared ? : 3 18647 18650
Condition50%2/4
$m->param_defaults // {}
l!l
186500
$m->return_type // "Any"
l!l
186500
MC/DC0%0/1
$m->param_defaults // {}
$m->param_defaults
MC/DC0%0/1
$m->return_type // "Any"
$m->return_type
Truth table50%1/2
A
A= $m->param_defaults
Aresult
11
00
Truth table50%1/2
A
A= $m->return_type
Aresult
11
00
2467 return_type => $m->return_type // 'Any',
2468 body => $m->body,
2469 closure_env => $closure_env,
2470 is_async => $m->is_async ? 1 : 0,
2471 is_bodyless => $m->is_predeclared ? 1 : 0,
2472 source_node => $m,
2473 );
2474 18650 ▶ $fn->{_default_typecheck_safe} = { %{ $m->{_default_typecheck_safe} // {} } };
Condition100%2/2
$m->{"_default_typecheck_safe"} // {}
l!l
39618254
MC/DC100%1/1
$m->{"_default_typecheck_safe"} // {}
$m->{"_default_typecheck_safe"}
Truth table100%2/2
A
A= $m->{"_default_typecheck_safe"}
Aresult
11
00
2475  
2476 18650 return $fn;
2477 }
2478  
2479 18650 ▶sub _install_method_function {
Subroutine _install_method_function: called CC=4 SCAR=14.5
2480 18650 my ( $self, $table, $m, $fn ) = @_;
2481  
2482 18650 ▶ if ( exists $table->{ $m->name } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $$table{$m->name}) 3 18647 18650
2483 3 my $existing = $table->{ $m->name };
2484 3 ▶ if ( $m->is_predeclared or !$existing->is_bodyless ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($m->is_predeclared or not $existing->is_bodyless) 0 3 3
Condition33%1/3
$m->is_predeclared or not $existing->is_bodyless
l!l&&r!l&&!r
003
MC/DC0%0/2
$m->is_predeclared or not $existing->is_bodyless
$m->is_predeclared not $existing->is_bodyless
Truth table33%1/3
A or not(B)
A= $m->is_predeclaredB= not $existing->is_bodyless
ABresult
1X1
011
000
2485 0 die Zuzu::Error->new_runtime(
2486 message => "Redeclaration of '".$m->name."' in the same scope",
2487 file => $m->file,
2488 line => $m->line,
2489 );
2490 }
2491 3 $self->_complete_bodyless_function( $existing, $fn );
2492 3 return $existing;
2493 }
2494  
2495 18647 $table->{ $m->name } = $fn;
2496 18647 return $fn;
2497 }
2498  
2499 4967 ▶sub eval_function_expr {
Subroutine eval_function_expr: called CC=10 SCAR=25.3
Pod undocumented
2500 4967 my ($self, $node) = @_;
2501  
2502 my $fn = Zuzu::Value::Function->new(
2503 name => '<anon>',
2504 4967 ▶ params => [ @{ $node->params // [] } ],
Condition50%1/2
$node->params // []
l!l
49670
MC/DC0%0/1
$node->params // []
$node->params
Truth table50%1/2
A
A= $node->params
Aresult
11
00
2505 vararg => $node->vararg,
2506 named_vararg => $node->named_vararg,
2507 4967 ▶ param_types => { %{ $node->param_types // {} } },
Condition50%3/6
$node->param_types // {}
l!l
49670
$node->vararg_type // "Any"
l!l
49670
$node->named_vararg_type // "PairList"
l!l
49670
MC/DC0%0/1
$node->param_types // {}
$node->param_types
MC/DC0%0/1
$node->vararg_type // "Any"
$node->vararg_type
MC/DC0%0/1
$node->named_vararg_type // "PairList"
$node->named_vararg_type
Truth table50%1/2
A
A= $node->param_types
Aresult
11
00
Truth table50%1/2
A
A= $node->vararg_type
Aresult
11
00
Truth table50%1/2
A
A= $node->named_vararg_type
Aresult
11
00
2508 vararg_type => $node->vararg_type // 'Any',
2509 named_vararg_type => $node->named_vararg_type // 'PairList',
2510 4967 ▶ param_optional => { %{ $node->param_optional // {} } },
Condition50%1/2
$node->param_optional // {}
l!l
49670
MC/DC0%0/1
$node->param_optional // {}
$node->param_optional
Truth table50%1/2
A
A= $node->param_optional
Aresult
11
00
2511 4967 ▶ param_defaults => { %{ $node->param_defaults // {} } },
Branch: 1 branch
BranchTrueFalseTotal
$node->is_async ? : 3 4964 4967
Condition50%2/4
$node->param_defaults // {}
l!l
49670
$node->return_type // "Any"
l!l
49670
MC/DC0%0/1
$node->param_defaults // {}
$node->param_defaults
MC/DC0%0/1
$node->return_type // "Any"
$node->return_type
Truth table50%1/2
A
A= $node->param_defaults
Aresult
11
00
Truth table50%1/2
A
A= $node->return_type
Aresult
11
00
2512 return_type => $node->return_type // 'Any',
2513 body => $node->body,
2514 4967 closure_env => $self->_capture_env( $self->{_stack}[-1] ), # inlined $self->_env
2515 is_async => $node->is_async ? 1 : 0,
2516 source_node => $node,
2517 );
2518 4967 ▶ $fn->{_default_typecheck_safe} = { %{ $node->{_default_typecheck_safe} // {} } };
Condition50%1/2
$node->{"_default_typecheck_safe"} // {}
l!l
04967
MC/DC0%0/1
$node->{"_default_typecheck_safe"} // {}
$node->{"_default_typecheck_safe"}
Truth table50%1/2
A
A= $node->{"_default_typecheck_safe"}
Aresult
11
00
2519  
2520 4967 return $fn;
2521 }
2522  
2523 2382 ▶sub _install_trait_methods_for_class {
Subroutine _install_trait_methods_for_class: called CC=14 SCAR=28.5
2524 2382 my ( $self, $klass, $traits ) = @_;
2525  
2526 2382 ▶ for my $trait ( @{ $traits // [] } ) {
Condition50%1/2
$traits // []
l!l
23820
MC/DC0%0/1
$traits // []
$traits
Truth table50%1/2
A
A= $traits
Aresult
11
00
2527 108 ▶ for my $mname ( sort keys %{ $trait->methods // {} } ) {
Condition50%1/2
$trait->methods // {}
l!l
1080
MC/DC0%0/1
$trait->methods // {}
$trait->methods
Truth table50%1/2
A
A= $trait->methods
Aresult
11
00
2528 408 my $source_method = $trait->methods->{ $mname };
2529 my $trait_method = Zuzu::Value::Function->new(
2530 name => $source_method->name,
2531 408 ▶ params => [ @{ $source_method->params // [] } ],
Condition50%1/2
$source_method->params // []
l!l
4080
MC/DC0%0/1
$source_method->params // []
$source_method->params
Truth table50%1/2
A
A= $source_method->params
Aresult
11
00
2532 vararg => $source_method->vararg,
2533 named_vararg => $source_method->named_vararg,
2534 408 ▶ param_types => { %{ $source_method->param_types // {} } },
Condition50%3/6
$source_method->param_types // {}
l!l
4080
$source_method->vararg_type // "Any"
l!l
4080
$source_method->named_vararg_type // "PairList"
l!l
4080
MC/DC0%0/1
$source_method->param_types // {}
$source_method->param_types
MC/DC0%0/1
$source_method->vararg_type // "Any"
$source_method->vararg_type
MC/DC0%0/1
$source_method->named_vararg_type // "PairList"
$source_method->named_vararg_type
Truth table50%1/2
A
A= $source_method->param_types
Aresult
11
00
Truth table50%1/2
A
A= $source_method->vararg_type
Aresult
11
00
Truth table50%1/2
A
A= $source_method->named_vararg_type
Aresult
11
00
2535 vararg_type => $source_method->vararg_type // 'Any',
2536 named_vararg_type => $source_method->named_vararg_type // 'PairList',
2537 408 ▶ param_optional => { %{ $source_method->param_optional // {} } },
Condition50%1/2
$source_method->param_optional // {}
l!l
4080
MC/DC0%0/1
$source_method->param_optional // {}
$source_method->param_optional
Truth table50%1/2
A
A= $source_method->param_optional
Aresult
11
00
2538 408 ▶ param_defaults => { %{ $source_method->param_defaults // {} } },
Branch: 1 branch
BranchTrueFalseTotal
$source_method->is_async ? : 0 408 408
Condition50%2/4
$source_method->param_defaults // {}
l!l
4080
$source_method->return_type // "Any"
l!l
4080
MC/DC0%0/1
$source_method->param_defaults // {}
$source_method->param_defaults
MC/DC0%0/1
$source_method->return_type // "Any"
$source_method->return_type
Truth table50%1/2
A
A= $source_method->param_defaults
Aresult
11
00
Truth table50%1/2
A
A= $source_method->return_type
Aresult
11
00
2539 return_type => $source_method->return_type // 'Any',
2540 body => $source_method->body,
2541 closure_env => $source_method->closure_env,
2542 is_async => $source_method->is_async ? 1 : 0,
2543 );
2544 408 ▶ $trait_method->{_default_typecheck_safe} = { %{ $source_method->{_default_typecheck_safe} // {} } };
Condition50%1/2
$source_method->{"_default_typecheck_safe"} // {}
l!l
4080
MC/DC0%0/1
$source_method->{"_default_typecheck_safe"} // {}
$source_method->{"_default_typecheck_safe"}
Truth table50%1/2
A
A= $source_method->{"_default_typecheck_safe"}
Aresult
11
00
2545 408 $trait_method->{_owner_class} = $klass;
2546 408 $trait_method->{_method_name} = $mname;
2547 408 $trait_method->{_method_kind} = 'instance';
2548 408 $trait_method->{_method_source} = 'trait';
2549 408 $trait_method->{_uses_super} = $source_method->{_uses_super};
2550 408 push @{ $klass->trait_methods->{ $mname } }, $trait_method;
2551 }
2552 }
2553  
2554 2382 return;
2555 }
2556  
2557 2381 ▶sub eval_class_def {
Subroutine eval_class_def: called CC=18 SCAR=30.1
Pod documented
2558 2381 my ($self, $node) = @_;
2559  
2560 2381 my $parent;
2561 2381 ▶ if ( defined $node->parent ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $node->parent) { } 1345 1036 2381
2562 1345 $parent = $node->parent->evaluate($self);
2563 1345 ▶ die Zuzu::Error->new_runtime(message => "Parent type is not a Class", file => $node->file, line => $node->line)
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($parent) and $parent->isa("Zuzu::Value::Class") 0 1345 1345
Condition33%1/3
builtin::blessed($parent) and $parent->isa("Zuzu::Value::Class")
!ll&&!rl&&r
001345
MC/DC0%0/2
builtin::blessed($parent) and $parent->isa("Zuzu::Value::Class")
builtin::blessed($parent) $parent->isa("Zuzu::Value::Class")
Truth table33%1/3
A and B
A= builtin::blessed($parent)B= $parent->isa("Zuzu::Value::Class")
ABresult
0X0
100
111
2564 if !blessed($parent) or !$parent->isa('Zuzu::Value::Class');
2565 }
2566 else {
2567 1036 $parent = $self->{_builtin_classes}{Object};
2568 }
2569 2381 my @traits;
2570 2381 ▶ for my $tref ( @{ $node->traits // [] } ) {
Condition50%1/2
$node->traits // []
l!l
23810
MC/DC0%0/1
$node->traits // []
$node->traits
Truth table50%1/2
A
A= $node->traits
Aresult
11
00
2571 107 my $trait = $tref->evaluate($self);
2572 107 ▶ die Zuzu::Error->new_runtime(message => "Composed type is not a Trait", file => $node->file, line => $node->line)
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($trait) and $trait->isa("Zuzu::Value::Trait") 0 107 107
Condition33%1/3
builtin::blessed($trait) and $trait->isa("Zuzu::Value::Trait")
!ll&&!rl&&r
00107
MC/DC0%0/2
builtin::blessed($trait) and $trait->isa("Zuzu::Value::Trait")
builtin::blessed($trait) $trait->isa("Zuzu::Value::Trait")
Truth table33%1/3
A and B
A= builtin::blessed($trait)B= $trait->isa("Zuzu::Value::Trait")
ABresult
0X0
100
111
2573 if !blessed($trait) or !$trait->isa('Zuzu::Value::Trait');
2574 107 push @traits, $trait;
2575 }
2576  
2577 my $klass = Zuzu::Value::Class->new(
2578 name => $node->name,
2579 parent => $parent,
2580 traits => \@traits,
2581 2381 ▶ field_specs => [ @{ $node->fields // [] } ],
Condition50%1/2
$node->fields // []
l!l
23810
MC/DC0%0/1
$node->fields // []
$node->fields
Truth table50%1/2
A
A= $node->fields
Aresult
11
00
2582 methods => {},
2583 trait_methods => {},
2584 static_methods => {},
2585 nested_classes => {},
2586 closure_env => undef,
2587 source_node => $node,
2588 );
2589  
2590 2381 ▶ for my $m (@{ $node->methods // [] }) {
Condition50%1/2
$node->methods // []
l!l
23810
MC/DC0%0/1
$node->methods // []
$node->methods
Truth table50%1/2
A
A= $node->methods
Aresult
11
00
2591 18107 my $method_fn = $self->_function_from_method_decl( $m, $self->_env );
2592 18107 $method_fn->{_owner_class} = $klass;
2593 18107 $method_fn->{_method_name} = $m->name;
2594 18107 $method_fn->{_method_kind} = 'instance';
2595 18107 $method_fn->{_method_source} = 'class';
2596 18107 $method_fn->{_uses_super} = $m->uses_super;
2597 18107 $self->_install_method_function( $klass->methods, $m, $method_fn );
2598 }
2599 2381 $self->_install_trait_methods_for_class( $klass, \@traits );
2600 2381 ▶ for my $m (@{ $node->static_methods // [] }) {
Condition50%1/2
$node->static_methods // []
l!l
23810
MC/DC0%0/1
$node->static_methods // []
$node->static_methods
Truth table50%1/2
A
A= $node->static_methods
Aresult
11
00
2601 288 my $static_fn = $self->_function_from_method_decl( $m, $self->_env );
2602 288 $static_fn->{_owner_class} = $klass;
2603 288 $static_fn->{_method_name} = $m->name;
2604 288 $static_fn->{_method_kind} = 'static';
2605 288 $static_fn->{_method_source} = 'class';
2606 288 $static_fn->{_uses_super} = $m->uses_super;
2607 288 $self->_install_method_function( $klass->static_methods, $m, $static_fn );
2608 }
2609  
2610 2381 my $class_env = Zuzu::Env->_new_fast( $self->_env );
2611 2381 $class_env->declare('self', $klass, 1);
2612 2381 $self->_push_env($class_env);
2613 2381 ▶ for my $n (@{ $node->classes // [] }) {
Condition50%1/2
$node->classes // []
l!l
23810
MC/DC0%0/1
$node->classes // []
$node->classes
Truth table50%1/2
A
A= $node->classes
Aresult
11
00
2614 0 my $inner = $self->eval_class_def($n);
2615 0 $inner->name( $klass->name . '{"' . $n->name . '"}' );
2616 0 $klass->nested_classes->{ $n->name } = $inner;
2617 }
2618 2381 $self->_pop_env;
2619  
2620 2381 for my $method ( values %{ $klass->methods } ) {
2621 18106 $method->closure_env($class_env);
2622 }
2623 2381 for my $method ( values %{ $klass->static_methods } ) {
2624 287 $method->closure_env($class_env);
2625 }
2626 2381 $klass->closure_env($class_env);
2627  
2628 2381 my $ref = $self->_env->find_ref($node->name);
2629 2381 ▶ if (!$ref) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ref) 2381 0 2381
2630 2381 $self->_env->declare($node->name, undef, 1);
2631 2381 $ref = $self->_env->find_ref($node->name);
2632 }
2633 2381 $$ref = $klass;
2634  
2635 2381 return $klass;
2636 }
2637  
2638 68 ▶sub eval_trait_def {
Subroutine eval_trait_def: called CC=4 SCAR=13.9
Pod undocumented
2639 68 my ( $self, $node ) = @_;
2640  
2641 68 my $trait = Zuzu::Value::Trait->new(
2642 name => $node->name,
2643 methods => {},
2644 closure_env => $self->_env,
2645 source_node => $node,
2646 );
2647  
2648 68 ▶ for my $m ( @{ $node->methods // [] } ) {
Condition50%1/2
$node->methods // []
l!l
680
MC/DC0%0/1
$node->methods // []
$node->methods
Truth table50%1/2
A
A= $node->methods
Aresult
11
00
2649 255 my $method = $self->_function_from_method_decl( $m, $self->_env );
2650 255 $method->{_uses_super} = $m->uses_super;
2651 255 $self->_install_method_function( $trait->methods, $m, $method );
2652 }
2653  
2654 68 my $ref = $self->_env->find_ref($node->name);
2655 68 ▶ if ( !$ref ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ref) 68 0 68
2656 68 $self->_env->declare($node->name, undef, 1);
2657 68 $ref = $self->_env->find_ref($node->name);
2658 }
2659 68 $$ref = $trait;
2660  
2661 68 return $trait;
2662 }
2663  
2664 0 ▶sub eval_method_def {
Subroutine eval_method_def: not called CC=1 SCAR=6.9
Pod documented
2665 0 my ($self, $node) = @_;
2666  
2667 0 die Zuzu::Error->new_runtime(message => "Method declarations are only valid inside class declarations", file => $node->file, line => $node->line);
2668 }
2669  
2670 72791 ▶sub eval_return {
Subroutine eval_return: called CC=3 SCAR=11.0
Pod documented
2671 72791 my ($self, $node) = @_;
2672  
2673 72791 ▶ my $v = defined($node->expr) ? $node->expr->evaluate($self) : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $node->expr ? : 72791 0 72791
2674 72787 ▶ my $sig = bless({ _control => 'return', value => $v, skip_type_check => $node->{_skip_type_check} ? 1 : 0 }, 'Zuzu::Control');
Branch: 1 branch
BranchTrueFalseTotal
$node->{'_skip_type_check'} ? : 2 72785 72787
2675 72787 die $sig;
2676 }
2677  
2678 196 ▶sub eval_next {
Subroutine eval_next: called CC=1 SCAR=0.0
Pod documented
2679 196 my ($self, $node) = @_;
2680  
2681 196 die bless({ _control => 'next' }, 'Zuzu::Control');
2682 }
2683  
2684 0 ▶sub eval_continue {
Subroutine eval_continue: not called CC=1 SCAR=6.9
Pod undocumented
2685 0 my ( $self, $node ) = @_;
2686  
2687 0 die bless( { _control => 'continue' }, 'Zuzu::Control' );
2688 }
2689  
2690 1516 ▶sub eval_postfix_if {
Subroutine eval_postfix_if: called CC=5 SCAR=16.1
Pod undocumented
2691 1516 my ($self, $node) = @_;
2692  
2693 1516 ▶ my $ok = $self->_to_Boolean( $node->cond->evaluate($self) ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->_to_Boolean($node->cond->evaluate($self)) ? : 250 1266 1516
2694 1516 ▶ $ok = $ok ? 0 : 1 if $node->negate;
Branch: 2 branches
BranchTrueFalseTotal
if $node->negate 69 1447 1516
$ok ? : 31 38 69
2695  
2696 1516 ▶ return undef if !$ok;
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 1259 257 1516
2697  
2698 257 return $node->statement->evaluate($self);
2699 }
2700  
2701 56 ▶sub eval_try {
Subroutine eval_try: called CC=10 SCAR=23.9
Pod undocumented
2702 56 my ( $self, $node ) = @_;
2703  
2704 56 my $result;
2705 eval {
2706 56 $result = $node->block->evaluate($self);
2707 0 1;
2708 56 ▶ } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $result = $node->block->evaluate($self); 1 } } or do { my $e = $@; if (ref $e and $e->{"_control"}) { die $e; } ; my $thrown = $e; if (ref $e and $e->{"_zuzu_throw"}) { $thrown = $e->{"value"}; } else { $thrown = $self->_exception_value_from_error($e); } ; foreach my $catch (@{$node->catches // [];}) { my $type = $catch->type_expr->evaluate($self); next unless $self->_throw_matches_type($thrown, $type); my $env = "Zuzu::Env"->_new_fast($self->_env); $self->_push_env($env); $env->declare($catch->name, $thrown, 0); my $caught_result; eval { do { $caught_result = $catch->block->evaluate($self); 1 } } or do { my $inner = $@; $self->_pop_env; die $inner }; $self->_pop_env; return $caught_result; } ; die $e } 0 56 56
2709 56 my $e = $@;
2710 56 ▶ if ( ref($e) and $e->{_control} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $e and $e->{"_control"}) 0 56 56
Condition33%1/3
ref $e and $e->{"_control"}
!ll&&!rl&&r
0560
MC/DC0%0/2
ref $e and $e->{"_control"}
ref $e $e->{"_control"}
Truth table33%1/3
A and B
A= ref $eB= $e->{"_control"}
ABresult
0X0
100
111
2711 0 die $e;
2712 }
2713 56 my $thrown = $e;
2714 56 ▶ if ( ref($e) and $e->{_zuzu_throw} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $e and $e->{'_zuzu_throw'}) { } 7 49 56
Condition66%2/3
ref $e and $e->{"_zuzu_throw"}
!ll&&!rl&&r
0497
MC/DC50%1/2
ref $e and $e->{"_zuzu_throw"}
ref $e $e->{"_zuzu_throw"}
Truth table66%2/3
A and B
A= ref $eB= $e->{"_zuzu_throw"}
ABresult
0X0
100
111
2715 7 $thrown = $e->{value};
2716 }
2717 else {
2718 49 $thrown = $self->_exception_value_from_error( $e );
2719 }
2720 56 ▶ for my $catch ( @{ $node->catches // [] } ) {
Condition50%1/2
$node->catches // []
l!l
560
MC/DC0%0/1
$node->catches // []
$node->catches
Truth table50%1/2
A
A= $node->catches
Aresult
11
00
2721 58 my $type = $catch->type_expr->evaluate($self);
2722 58 ▶ next if !$self->_throw_matches_type( $thrown, $type );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_throw_matches_type($thrown, $type) 2 56 58
2723 56 my $env = Zuzu::Env->_new_fast( $self->_env );
2724 56 $self->_push_env($env);
2725 56 $env->declare( $catch->name, $thrown, 0 );
2726 56 my $caught_result;
2727 eval {
2728 56 $caught_result = $catch->block->evaluate($self);
2729 53 1;
2730 56 ▶ } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $caught_result = $catch->block->evaluate($self); 1 } } or do { my $inner = $@; $self->_pop_env; die $inner } 53 3 56
2731 3 my $inner = $@;
2732 3 $self->_pop_env;
2733 3 die $inner;
2734 };
2735 53 $self->_pop_env;
2736 53 return $caught_result;
2737 }
2738 0 die $e;
2739 };
2740  
2741 0 return $result;
2742 }
2743  
2744 49 ▶sub _exception_value_from_error {
Subroutine _exception_value_from_error: called CC=10 SCAR=25.9
2745 49 my ( $self, $error ) = @_;
2746  
2747 49 ▶ return $error if !blessed($error) or !$error->isa('Zuzu::Error');
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($error) and $error->isa("Zuzu::Error") 10 39 49
Condition66%2/3
builtin::blessed($error) and $error->isa("Zuzu::Error")
!ll&&!rl&&r
01039
MC/DC50%1/2
builtin::blessed($error) and $error->isa("Zuzu::Error")
builtin::blessed($error) $error->isa("Zuzu::Error")
Truth table66%2/3
A and B
A= builtin::blessed($error)B= $error->isa("Zuzu::Error")
ABresult
0X0
100
111
2748  
2749 39 ▶ my $class_name = ( $error->message // '' ) =~ /\ATypeException:/
Branch: 1 branch
BranchTrueFalseTotal
($error->message // '') =~ /\ATypeException:/ ? : 3 36 39
Condition50%1/2
$error->message // ""
l!l
390
MC/DC0%0/1
$error->message // ""
$error->message
Truth table50%1/2
A
A= $error->message
Aresult
11
00
2750 ? 'TypeException'
2751 : 'Exception';
2752 my $class = $self->{_builtin_classes}{$class_name}
2753 39 ▶ // $self->{_builtin_classes}{Exception};
Condition33%1/3
$self->{"_builtin_classes"}{$class_name} // $self->{"_builtin_classes"}{"Exception"}
l!l&&r!l&&!r
3900
MC/DC0%0/2
$self->{"_builtin_classes"}{$class_name} // $self->{"_builtin_classes"}{"Exception"}
$self->{"_builtin_classes"}{$class_name} $self->{"_builtin_classes"}{"Exception"}
Truth table33%1/3
A // B
A= $self->{"_builtin_classes"}{$class_name}B= $self->{"_builtin_classes"}{"Exception"}
ABresult
1X1
011
000
2754  
2755 39 ▶ return $self->_instantiate_builtin_object(
Branch: 1 branch
BranchTrueFalseTotal
defined $error->line ? : 39 0 39
Condition50%3/6
$error->message // "$error"
l!l
390
$error->file // "<runtime>"
l!l
390
$error->code // ""
l!l
390
MC/DC0%0/1
$error->message // "$error"
$error->message
MC/DC0%0/1
$error->file // "<runtime>"
$error->file
MC/DC0%0/1
$error->code // ""
$error->code
Truth table50%1/2
A
A= $error->message
Aresult
11
00
Truth table50%1/2
A
A= $error->file
Aresult
11
00
Truth table50%1/2
A
A= $error->code
Aresult
11
00
2756 $class,
2757 {
2758 message => $error->message // "$error",
2759 file => $error->file // '<runtime>',
2760 line => defined $error->line ? 0 + $error->line : 0,
2761 code => $error->code // '',
2762 kind => $error->kind,
2763 },
2764 );
2765 }
2766  
2767 0 ▶sub eval_catch {
Subroutine eval_catch: not called CC=1 SCAR=6.9
Pod undocumented
2768 0 my ( $self, $node ) = @_;
2769  
2770 0 die Zuzu::Error->new_runtime(
2771 message => "catch clauses are only valid inside try statements",
2772 file => $node->file,
2773 line => $node->line,
2774 );
2775 }
2776  
2777 7 ▶sub eval_throw {
Subroutine eval_throw: called CC=1 SCAR=0.0
Pod undocumented
2778 7 my ( $self, $node ) = @_;
2779  
2780 7 my $value = $node->expr->evaluate($self);
2781 7 die {
2782 _zuzu_throw => 1,
2783 value => $value,
2784 };
2785 }
2786  
2787 5 ▶sub eval_die {
Subroutine eval_die: called CC=3 SCAR=11.2
Pod undocumented
2788 5 my ( $self, $node ) = @_;
2789  
2790 5 my $value = $node->expr->evaluate($self);
2791 5 ▶ if ( not blessed($value) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (builtin::blessed($value)) 5 0 5
2792 5 ▶ my $message = defined $value ? $self->_to_String($value) : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $value ? : 5 0 5
2793 $value = $self->_instantiate_builtin_object(
2794 $self->{_builtin_classes}{Exception},
2795 {
2796 5 message => $message,
2797 file => $node->file,
2798 line => $node->line,
2799 },
2800 );
2801 }
2802 die {
2803 5 _zuzu_throw => 1,
2804 value => $value,
2805 };
2806 }
2807  
2808 2 ▶sub eval_debug {
Subroutine eval_debug: called CC=4 SCAR=14.0
Pod undocumented
2809 2 my ( $self, $node ) = @_;
2810  
2811 2 ▶ my $level = 0 + ( $node->level_expr->evaluate($self) // 0 );
Condition50%1/2
$node->level_expr->evaluate($self) // 0
l!l
20
MC/DC0%0/1
$node->level_expr->evaluate($self) // 0
$node->level_expr->evaluate($self)
Truth table50%1/2
A
A= $node->level_expr->evaluate($self)
Aresult
11
00
2812 2 ▶ return undef if $level > $Zuzu::Runtime::DEBUG_LEVEL;
Branch: 1 branch
BranchTrueFalseTotal
if $level > $Zuzu::Runtime::DEBUG_LEVEL 1 1 2
2813 1 my $message = $node->message_expr->evaluate($self);
2814 1 ▶ $message = defined $message ? $self->_to_String($message) : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $message ? : 1 0 1
2815 1 print STDERR "$message\n";
2816  
2817 1 return undef;
2818 }
2819  
2820 2 ▶sub eval_assert {
Subroutine eval_assert: called CC=5 SCAR=16.8
Pod undocumented
2821 2 my ( $self, $node ) = @_;
2822  
2823 2 ▶ return undef if $Zuzu::Runtime::DEBUG_LEVEL <= 0;
Branch: 1 branch
BranchTrueFalseTotal
if $Zuzu::Runtime::DEBUG_LEVEL <= 0 1 1 2
2824 1 ▶ my $ok = $self->_to_Boolean( $node->expr->evaluate($self) ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->_to_Boolean($node->expr->evaluate($self)) ? : 0 1 1
2825 1 ▶ return undef if $ok;
Branch: 1 branch
BranchTrueFalseTotal
if $ok 0 1 1
2826  
2827 my $assert_class = $self->{_builtin_classes}{AssertionException}
2828 1 ▶ // $self->{_builtin_classes}{Exception};
Condition33%1/3
$self->{"_builtin_classes"}{"AssertionException"} // $self->{"_builtin_classes"}{"Exception"}
l!l&&r!l&&!r
100
MC/DC0%0/2
$self->{"_builtin_classes"}{"AssertionException"} // $self->{"_builtin_classes"}{"Exception"}
$self->{"_builtin_classes"}{"AssertionException"} $self->{"_builtin_classes"}{"Exception"}
Truth table33%1/3
A // B
A= $self->{"_builtin_classes"}{"AssertionException"}B= $self->{"_builtin_classes"}{"Exception"}
ABresult
1X1
011
000
2829 1 my $error = $self->_instantiate_builtin_object(
2830 $assert_class,
2831 {
2832 message => 'Assertion failed',
2833 },
2834 );
2835 1 die {
2836 _zuzu_throw => 1,
2837 value => $error,
2838 };
2839 }
2840  
2841 85 ▶sub eval_last {
Subroutine eval_last: called CC=1 SCAR=0.0
Pod documented
2842 85 my ($self, $node) = @_;
2843  
2844 85 die bless({ _control => 'last' }, 'Zuzu::Control');
2845 }
2846  
2847 31778 ▶sub eval_expr_stmt {
Subroutine eval_expr_stmt: called CC=1 SCAR=0.0
Pod documented
2848 31778 my ($self, $node) = @_;
2849  
2850 31778 return $node->expr->evaluate($self);
2851 }
2852  
2853 2308 ▶sub eval_import {
Subroutine eval_import: called CC=17 SCAR=28.3
Pod documented
2854 2308 my ($self, $node) = @_;
2855  
2856 2308 ▶ if ( defined $node->condition_expr ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $node->condition_expr) 3 2305 2308
2857 3 ▶ my $pass = $self->_to_Boolean( $node->condition_expr->evaluate($self) ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->_to_Boolean($node->condition_expr->evaluate($self)) ? : 1 2 3
2858 3 ▶ $pass = $node->condition_positive ? $pass : !$pass;
Branch: 1 branch
BranchTrueFalseTotal
$node->condition_positive ? : 2 1 3
2859 3 ▶ if ( !$pass ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($pass) 1 2 3
2860 1 $self->_bind_import_null_constants($node);
2861 1 return undef;
2862 }
2863 }
2864  
2865 2307 my ($mod_env, $exports);
2866 2307 ▶ if ( $node->try_mode ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->try_mode) { } 111 2196 2307
2867 111 my $ok = eval {
2868 111 $mod_env = $self->_load_module($node->module, $node->file, $node->line);
2869 109 ▶ $exports = $self->{_module_exports}{ $node->module } // {};
Condition50%1/2
$self->{"_module_exports"}{$node->module} // {}
l!l
1090
MC/DC0%0/1
$self->{"_module_exports"}{$node->module} // {}
$self->{"_module_exports"}{$node->module}
Truth table50%1/2
A
A= $self->{"_module_exports"}{$node->module}
Aresult
11
00
2870 109 1;
2871 };
2872 111 ▶ if ( !$ok ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ok) 2 109 111
2873 2 $self->_bind_import_null_constants($node);
2874 2 return undef;
2875 }
2876 }
2877 else {
2878 2196 $mod_env = $self->_load_module($node->module, $node->file, $node->line);
2879 2190 ▶ $exports = $self->{_module_exports}{ $node->module } // {};
Condition50%1/2
$self->{"_module_exports"}{$node->module} // {}
l!l
21900
MC/DC0%0/1
$self->{"_module_exports"}{$node->module} // {}
$self->{"_module_exports"}{$node->module}
Truth table50%1/2
A
A= $self->{"_module_exports"}{$node->module}
Aresult
11
00
2880 }
2881  
2882 # star import excludes leading underscore
2883 2299 for my $it (@{$node->items}) {
2884 4443 ▶ if ($it->{star}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($it->{"star"}) 175 4268 4443
2885 175 for my $name ( sort CORE::keys %{ $exports } ) {
2886 3348 ▶ next if $name =~ /\A_/;
Branch: 1 branch
BranchTrueFalseTotal
if $name =~ /\A_/ 1304 2044 3348
2887 2044 my $ref = $mod_env->{slots}{$name};
2888 2044 ▶ my $is_const = $mod_env->{const}{$name} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$mod_env->{'const'}{$name} ? : 2029 15 2044
2889 2044 $self->_assert_import_target_available( $name, $ref, $node );
2890 2043 $self->_env->alias_to_ref($name, $ref, $is_const);
2891 }
2892 174 next;
2893 }
2894 4268 my $src = $it->{name};
2895 4268 my $dst = $it->{alias};
2896 die Zuzu::Error->new_runtime(message => "Module '".$node->module."' has no export '$src'", file => $node->file, line => $node->line)
2897 4268 ▶ if !$exports->{$src};
Branch: 1 branch
BranchTrueFalseTotal
unless $exports->{$src} 1 4267 4268
2898 4267 my $ref = $mod_env->find_ref($src);
2899 4267 ▶ die Zuzu::Error->new_runtime(message => "Module '".$node->module."' has no export '$src'", file => $node->file, line => $node->line) if !$ref;
Branch: 1 branch
BranchTrueFalseTotal
unless $ref 0 4267 4267
2900 4267 my $is_const;
2901 # determine constness at module scope
2902 4267 ▶ $is_const = $mod_env->{const}{$src} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$mod_env->{'const'}{$src} ? : 4264 3 4267
2903 4267 $self->_assert_import_target_available( $dst, $ref, $node );
2904 4267 $self->_env->alias_to_ref($dst, $ref, $is_const);
2905 }
2906  
2907 2297 return undef;
2908 }
2909  
2910 3 ▶sub _bind_import_null_constants {
Subroutine _bind_import_null_constants: called CC=4 SCAR=14.0
2911 3 my ( $self, $node ) = @_;
2912  
2913 3 for my $it ( @{ $node->items } ) {
2914 3 ▶ next if $it->{star};
Branch: 1 branch
BranchTrueFalseTotal
if $it->{"star"} 0 3 3
2915 3 my $dst = $it->{alias};
2916 die Zuzu::Error->new_runtime(
2917 message => "Import conflict: '$dst' is already declared in this scope",
2918 file => $node->file,
2919 line => $node->line,
2920 3 ▶ ) if exists $self->_env->{slots}{$dst};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->_env->{"slots"}{$dst} 0 3 3
2921 3 $self->_env->declare( $dst, undef, 1 );
2922 }
2923  
2924 3 return;
2925 }
2926  
2927 6311 ▶sub _assert_import_target_available {
Subroutine _assert_import_target_available: called CC=9 SCAR=23.9
2928 6311 my ( $self, $target, $ref, $node ) = @_;
2929  
2930 6311 ▶ return if !exists $self->_env->{slots}{$target};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->_env->{"slots"}{$target} 6303 8 6311
2931  
2932 8 my $existing = $self->_env->{slots}{$target};
2933 8 ▶ return if defined $existing and defined $ref and $existing == $ref;
Branch: 1 branch
BranchTrueFalseTotal
if defined $existing and defined $ref and $existing == $ref 1 7 8
Condition50%3/6
defined $existing and defined $ref and $existing == $ref
!ll&&!rl&&r
071
defined $existing and defined $ref
!ll&&!rl&&r
008
MC/DC33%1/3
defined $existing and defined $ref and $existing == $ref
defined $existing defined $ref $existing == $ref
Truth table50%2/4
A and B and C
A= defined $existingB= defined $refC= $existing == $ref
ABCresult
0XX0
10X0
1100
1111
2934 7 ▶ if ( $self->{_builtin_global_names}{$target} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_builtin_global_names"}{$target}) 6 1 7
2935 6 my $builtin_ref = $self->{_global}{slots}{$target};
2936 6 ▶ return if defined $existing
Branch: 1 branch
BranchTrueFalseTotal
if defined $existing and defined $builtin_ref and $existing == $builtin_ref 6 0 6
Condition33%2/6
defined $existing and defined $builtin_ref and $existing == $builtin_ref
!ll&&!rl&&r
006
defined $existing and defined $builtin_ref
!ll&&!rl&&r
006
MC/DC0%0/3
defined $existing and defined $builtin_ref and $existing == $builtin_ref
defined $existing defined $builtin_ref $existing == $builtin_ref
Truth table25%1/4
A and B and C
A= defined $existingB= defined $builtin_refC= $existing == $builtin_ref
ABCresult
0XX0
10X0
1100
1111
2937 and defined $builtin_ref
2938 and $existing == $builtin_ref;
2939 }
2940  
2941 1 die Zuzu::Error->new_runtime(
2942 message => "Import conflict: '$target' is already declared in this scope",
2943 file => $node->file,
2944 line => $node->line,
2945 );
2946 }
2947  
2948 102635 ▶sub eval_literal { $_[1]->value }
Subroutine eval_literal: called CC=1 SCAR=0.0
Pod documented
2949  
2950 0 ▶sub eval_regexp_literal {
Subroutine eval_regexp_literal: not called CC=8 SCAR=42.8
Pod undocumented
2951 0 my ( $self, $node ) = @_;
2952  
2953 0 my $pattern = '';
2954 0 ▶ for my $part ( @{ $node->parts // [] } ) {
Condition0%0/2
$node->parts // []
l!l
00
MC/DC0%0/1
$node->parts // []
$node->parts
Truth table0%0/2
A
A= $node->parts
Aresult
11
00
2955 0 ▶ if ( ref $part eq 'HASH' and exists $part->{expr} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $part eq 'HASH' and exists $part->{'expr'}) { } 0 0 0
Condition0%0/3
ref $part eq "HASH" and exists $part->{"expr"}
!ll&&!rl&&r
000
MC/DC0%0/2
ref $part eq "HASH" and exists $part->{"expr"}
ref $part eq "HASH" exists $part->{"expr"}
Truth table0%0/3
A and B
A= ref $part eq "HASH"B= exists $part->{"expr"}
ABresult
0X0
100
111
2956 $pattern .= $self->_to_OperatorString(
2957 0 $part->{expr}->evaluate($self),
2958 $node->file,
2959 $node->line,
2960 );
2961 }
2962 else {
2963 $pattern .= ref $part eq 'HASH' && exists $part->{text}
2964 ? $part->{text}
2965 0 ▶ : $part;
Branch: 1 branch
BranchTrueFalseTotal
ref $part eq 'HASH' && exists $part->{'text'} ? : 0 0 0
Condition0%0/3
ref $part eq "HASH" and exists $part->{"text"}
!ll&&!rl&&r
000
MC/DC0%0/2
ref $part eq "HASH" and exists $part->{"text"}
ref $part eq "HASH" exists $part->{"text"}
Truth table0%0/3
A and B
A= ref $part eq "HASH"B= exists $part->{"text"}
ABresult
0X0
100
111
2966 }
2967 }
2968  
2969 0 ▶ return Zuzu::Value::Regexp->new(
Condition0%0/2
$node->flags // ""
l!l
00
MC/DC0%0/1
$node->flags // ""
$node->flags
Truth table0%0/2
A
A= $node->flags
Aresult
11
00
2970 pattern => $pattern,
2971 flags => $node->flags // '',
2972 );
2973 }
2974  
2975 348163 ▶sub eval_var {
Subroutine eval_var: called CC=10 SCAR=23.5
Pod documented
2976 348163 my ($self, $node) = @_;
2977  
2978 348163 my $env;
2979 348163 my $name = $node->{name};
2980 348163 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (defined $node->{"_env_depth"} and defined $node->{"_binding_name"} and $node->{"_binding_name"} eq $name) 286727 61436 348163
Condition66%4/6
defined $node->{"_env_depth"} and defined $node->{"_binding_name"} and $node->{"_binding_name"} eq $name
!ll&&!rl&&r
614360286727
defined $node->{"_env_depth"} and defined $node->{"_binding_name"}
!ll&&!rl&&r
614360286727
MC/DC33%1/3
defined $node->{"_env_depth"} and defined $node->{"_binding_name"} and $node->{"_binding_name"} eq $name
defined $node->{"_env_depth"} defined $node->{"_binding_name"} $node->{"_binding_name"} eq $name
Truth table50%2/4
A and B and C
A= defined $node->{"_env_depth"}B= defined $node->{"_binding_name"}C= $node->{"_binding_name"} eq $name
ABCresult
0XX0
10X0
1100
1111
2981 defined $node->{_env_depth}
2982 and defined $node->{_binding_name}
2983 and $node->{_binding_name} eq $name
2984 ) {
2985 286727 $env = $self->{_stack}[-1];
2986 286727 for ( 1 .. $node->{_env_depth} ) {
2987 303121 ▶ last if !defined $env;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $env 0 303121 303121
2988 303121 $env = $env->{parent};
2989 }
2990 286652 return ${ $env->{slots}{$name} }
2991 286727 ▶ if defined $env and exists $env->{slots}{$name};
Branch: 1 branch
BranchTrueFalseTotal
if defined $env and exists $env->{"slots"}{$name} 286652 75 286727
Condition66%2/3
defined $env and exists $env->{"slots"}{$name}
!ll&&!rl&&r
075286652
MC/DC50%1/2
defined $env and exists $env->{"slots"}{$name}
defined $env exists $env->{"slots"}{$name}
Truth table66%2/3
A and B
A= defined $envB= exists $env->{"slots"}{$name}
ABresult
0X0
100
111
2992 }
2993  
2994 61511 $env = $self->{_stack}[-1];
2995 61511 ▶ while ($env) {
Branch: 1 branch
BranchTrueFalseTotal
if ($env) 92577 0 92577
2996 61511 return ${ $env->{slots}{$name} }
2997 92577 ▶ if exists $env->{slots}{$name};
Branch: 1 branch
BranchTrueFalseTotal
if exists $env->{"slots"}{$name} 61511 31066 92577
2998 31066 $env = $env->{parent};
2999 }
3000  
3001 0 die Zuzu::Error->new_runtime(
3002 message => "Undeclared variable '$name'",
3003 file => $node->file,
3004 line => $node->line,
3005 );
3006 }
3007  
3008 2850 ▶sub eval_array {
Subroutine eval_array: called CC=5 SCAR=16.2
Pod documented
3009 2850 my ($self, $node) = @_;
3010  
3011 2850 my @vals;
3012 2850 for my $item ( @{ $node->items } ) {
3013 16128 ▶ if ( blessed($item) and $item->isa('Zuzu::AST::Expr::Range') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($item) and $item->isa("Zuzu::AST::Expr::Range")) 3 16125 16128
Condition66%2/3
builtin::blessed($item) and $item->isa("Zuzu::AST::Expr::Range")
!ll&&!rl&&r
0161253
MC/DC50%1/2
builtin::blessed($item) and $item->isa("Zuzu::AST::Expr::Range")
builtin::blessed($item) $item->isa("Zuzu::AST::Expr::Range")
Truth table66%2/3
A and B
A= builtin::blessed($item)B= $item->isa("Zuzu::AST::Expr::Range")
ABresult
0X0
100
111
3014 3 my $range_values = $item->evaluate($self);
3015 3 ▶ push @vals, @{ $range_values->items // [] };
Condition50%1/2
$range_values->items // []
l!l
30
MC/DC0%0/1
$range_values->items // []
$range_values->items
Truth table50%1/2
A
A= $range_values->items
Aresult
11
00
3016 3 next;
3017 }
3018 16125 push @vals, $item->evaluate($self);
3019 }
3020  
3021 2850 return Zuzu::Value::Array->new(items => \@vals);
3022 }
3023  
3024 7 ▶sub eval_range {
Subroutine eval_range: called CC=2 SCAR=6.9
Pod undocumented
3025 7 my ( $self, $node ) = @_;
3026  
3027 7 my $start = $self->_range_bound_to_int(
3028 $node->start->evaluate($self),
3029 $node->file,
3030 $node->line,
3031 );
3032 7 my $end = $self->_range_bound_to_int(
3033 $node->end->evaluate($self),
3034 $node->file,
3035 $node->line,
3036 );
3037 7 my @values;
3038 7 ▶ if ( $start <= $end ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($start <= $end) { } 4 3 7
3039 4 @values = ( $start .. $end );
3040 }
3041 else {
3042 3 @values = reverse( $end .. $start );
3043 }
3044  
3045 7 return Zuzu::Value::Array->new( items => \@values );
3046 }
3047  
3048 14 ▶sub _range_bound_to_int {
Subroutine _range_bound_to_int: called CC=2 SCAR=7.2
3049 14 my ( $self, $value, $file, $line ) = @_;
3050  
3051 14 my $num = $self->_to_Number($value);
3052 14 my $int = int $num;
3053 14 ▶ if ( $num != $int ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($num != $int) 0 14 14
3054 0 die Zuzu::Error->new_runtime(
3055 message => "Range bounds must be integers",
3056 file => $file,
3057 line => $line,
3058 );
3059 }
3060  
3061 14 return $int;
3062 }
3063  
3064 3495 ▶sub eval_dict {
Subroutine eval_dict: called CC=3 SCAR=11.0
Pod documented
3065 3495 my ($self, $node) = @_;
3066  
3067 3495 my %m;
3068 3495 for my $p (@{$node->pairs}) {
3069 10516 my ($kexpr, $vexpr) = @$p;
3070 10516 my $k = $kexpr->evaluate($self);
3071 10516 ▶ $k = defined($k) ? "$k" : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $k ? : 10516 0 10516
3072 10516 my $v = $vexpr->evaluate($self);
3073 10516 $m{$k} = $v;
3074 }
3075  
3076 3495 return Zuzu::Value::Dict->new(map => \%m);
3077 }
3078  
3079 35 ▶sub eval_pairlist {
Subroutine eval_pairlist: called CC=3 SCAR=11.0
Pod undocumented
3080 35 my ( $self, $node ) = @_;
3081  
3082 35 my @list;
3083 35 for my $pair ( @{ $node->pairs } ) {
3084 56 my ( $key_expr, $value_expr ) = @{ $pair };
3085 56 my $key = $key_expr->evaluate($self);
3086 56 ▶ $key = defined($key) ? "$key" : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $key ? : 56 0 56
3087 56 my $value = $value_expr->evaluate($self);
3088 56 push @list, [ $key, $value ];
3089 }
3090  
3091 35 return Zuzu::Value::PairList->new( list => \@list );
3092 }
3093  
3094 41 ▶sub eval_set {
Subroutine eval_set: called CC=5 SCAR=16.1
Pod undocumented
3095 41 my ($self, $node) = @_;
3096  
3097 41 my @vals;
3098 41 for my $item ( @{ $node->items } ) {
3099 81 ▶ if ( blessed($item) and $item->isa('Zuzu::AST::Expr::Range') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($item) and $item->isa("Zuzu::AST::Expr::Range")) 2 79 81
Condition66%2/3
builtin::blessed($item) and $item->isa("Zuzu::AST::Expr::Range")
!ll&&!rl&&r
0792
MC/DC50%1/2
builtin::blessed($item) and $item->isa("Zuzu::AST::Expr::Range")
builtin::blessed($item) $item->isa("Zuzu::AST::Expr::Range")
Truth table66%2/3
A and B
A= builtin::blessed($item)B= $item->isa("Zuzu::AST::Expr::Range")
ABresult
0X0
100
111
3100 2 my $range_values = $item->evaluate($self);
3101 2 ▶ push @vals, @{ $range_values->items // [] };
Condition50%1/2
$range_values->items // []
l!l
20
MC/DC0%0/1
$range_values->items // []
$range_values->items
Truth table50%1/2
A
A= $range_values->items
Aresult
11
00
3102 2 next;
3103 }
3104 79 push @vals, $item->evaluate($self);
3105 }
3106 41 my $set = Zuzu::Value::Set->new(items => []);
3107 41 $set->add(@vals);
3108  
3109 41 return $set;
3110 }
3111  
3112 20 ▶sub eval_bag {
Subroutine eval_bag: called CC=5 SCAR=16.2
Pod undocumented
3113 20 my ($self, $node) = @_;
3114  
3115 20 my @vals;
3116 20 for my $item ( @{ $node->items } ) {
3117 34 ▶ if ( blessed($item) and $item->isa('Zuzu::AST::Expr::Range') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($item) and $item->isa("Zuzu::AST::Expr::Range")) 2 32 34
Condition66%2/3
builtin::blessed($item) and $item->isa("Zuzu::AST::Expr::Range")
!ll&&!rl&&r
0322
MC/DC50%1/2
builtin::blessed($item) and $item->isa("Zuzu::AST::Expr::Range")
builtin::blessed($item) $item->isa("Zuzu::AST::Expr::Range")
Truth table66%2/3
A and B
A= builtin::blessed($item)B= $item->isa("Zuzu::AST::Expr::Range")
ABresult
0X0
100
111
3118 2 my $range_values = $item->evaluate($self);
3119 2 ▶ push @vals, @{ $range_values->items // [] };
Condition50%1/2
$range_values->items // []
l!l
20
MC/DC0%0/1
$range_values->items // []
$range_values->items
Truth table50%1/2
A
A= $range_values->items
Aresult
11
00
3120 2 next;
3121 }
3122 32 push @vals, $item->evaluate($self);
3123 }
3124  
3125 20 return Zuzu::Value::Bag->new(items => \@vals);
3126 }
3127  
3128 0 ▶sub _stable_value_key {
Subroutine _stable_value_key: not called CC=1 SCAR=6.9
3129 0 my ( $self, $v ) = @_;
3130  
3131 0 return stable_value_key( $v );
3132 }
3133  
3134 18116 ▶sub _value_equal {
Subroutine _value_equal: called CC=1 SCAR=0.0
3135 18116 my ( $self, $a, $b ) = @_;
3136  
3137 18116 return value_equal( $a, $b );
3138 }
3139  
3140 65 ▶sub _collection_items {
Subroutine _collection_items: called CC=16 SCAR=37.1
3141 65 my ( $self, $v ) = @_;
3142  
3143 65 my $as_array = $self->_unwrap_builtin_collection( $v, 'Array' );
3144 65 ▶ return $as_array->resolved_items if $as_array;
Branch: 1 branch
BranchTrueFalseTotal
if $as_array 44 21 65
3145 21 my $as_set = $self->_unwrap_builtin_collection( $v, 'Set' );
3146 21 ▶ return $as_set->resolved_items if $as_set;
Branch: 1 branch
BranchTrueFalseTotal
if $as_set 19 2 21
3147 2 my $as_bag = $self->_unwrap_builtin_collection( $v, 'Bag' );
3148 2 ▶ return $as_bag->resolved_items if $as_bag;
Branch: 1 branch
BranchTrueFalseTotal
if $as_bag 0 2 2
3149 2 my $as_dict = $self->_unwrap_builtin_collection( $v, 'Dict' );
3150 0 ▶ return CORE::keys %{ $as_dict->map } if $as_dict;
Branch: 1 branch
BranchTrueFalseTotal
if $as_dict 0 2 2
3151 2 my $as_pairlist = $self->_unwrap_builtin_collection( $v, 'PairList' );
3152 0 ▶ return map { $_->[0] } @{ $as_pairlist->list } if $as_pairlist;
Branch: 1 branch
BranchTrueFalseTotal
if $as_pairlist 0 2 2
3153  
3154 2 ▶ if ( blessed($v) and $v->isa('Zuzu::Value::Array') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($v) and $v->isa("Zuzu::Value::Array")) 0 2 2
Condition33%1/3
builtin::blessed($v) and $v->isa("Zuzu::Value::Array")
!ll&&!rl&&r
200
MC/DC0%0/2
builtin::blessed($v) and $v->isa("Zuzu::Value::Array")
builtin::blessed($v) $v->isa("Zuzu::Value::Array")
Truth table33%1/3
A and B
A= builtin::blessed($v)B= $v->isa("Zuzu::Value::Array")
ABresult
0X0
100
111
3155 0 return $v->resolved_items;
3156 }
3157 2 ▶ if ( blessed($v) and $v->isa('Zuzu::Value::Set') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($v) and $v->isa("Zuzu::Value::Set")) 0 2 2
Condition33%1/3
builtin::blessed($v) and $v->isa("Zuzu::Value::Set")
!ll&&!rl&&r
200
MC/DC0%0/2
builtin::blessed($v) and $v->isa("Zuzu::Value::Set")
builtin::blessed($v) $v->isa("Zuzu::Value::Set")
Truth table33%1/3
A and B
A= builtin::blessed($v)B= $v->isa("Zuzu::Value::Set")
ABresult
0X0
100
111
3158 0 return $v->resolved_items;
3159 }
3160 2 ▶ if ( blessed($v) and $v->isa('Zuzu::Value::Bag') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($v) and $v->isa("Zuzu::Value::Bag")) 0 2 2
Condition33%1/3
builtin::blessed($v) and $v->isa("Zuzu::Value::Bag")
!ll&&!rl&&r
200
MC/DC0%0/2
builtin::blessed($v) and $v->isa("Zuzu::Value::Bag")
builtin::blessed($v) $v->isa("Zuzu::Value::Bag")
Truth table33%1/3
A and B
A= builtin::blessed($v)B= $v->isa("Zuzu::Value::Bag")
ABresult
0X0
100
111
3161 0 return $v->resolved_items;
3162 }
3163 2 ▶ if ( blessed($v) and $v->isa('Zuzu::Value::Dict') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($v) and $v->isa("Zuzu::Value::Dict")) 0 2 2
Condition33%1/3
builtin::blessed($v) and $v->isa("Zuzu::Value::Dict")
!ll&&!rl&&r
200
MC/DC0%0/2
builtin::blessed($v) and $v->isa("Zuzu::Value::Dict")
builtin::blessed($v) $v->isa("Zuzu::Value::Dict")
Truth table33%1/3
A and B
A= builtin::blessed($v)B= $v->isa("Zuzu::Value::Dict")
ABresult
0X0
100
111
3164 0 return CORE::keys %{ $v->map };
3165 }
3166 2 ▶ if ( blessed($v) and $v->isa('Zuzu::Value::PairList') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($v) and $v->isa("Zuzu::Value::PairList")) 0 2 2
Condition33%1/3
builtin::blessed($v) and $v->isa("Zuzu::Value::PairList")
!ll&&!rl&&r
200
MC/DC0%0/2
builtin::blessed($v) and $v->isa("Zuzu::Value::PairList")
builtin::blessed($v) $v->isa("Zuzu::Value::PairList")
Truth table33%1/3
A and B
A= builtin::blessed($v)B= $v->isa("Zuzu::Value::PairList")
ABresult
0X0
100
111
3167 0 return map { $_->[0] } @{ $v->list };
3168 }
3169  
3170 2 return ();
3171 }
3172  
3173 20 ▶sub _coerce_set {
Subroutine _coerce_set: called CC=7 SCAR=25.2
3174 20 my ( $self, $v, $file, $line ) = @_;
3175  
3176 20 my $set_like = $self->_unwrap_builtin_collection( $v, 'Set' );
3177 20 ▶ return $set_like if $set_like;
Branch: 1 branch
BranchTrueFalseTotal
if $set_like 18 2 20
3178 2 my @items = $self->_collection_items($v);
3179 2 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
unless (@items or $self->_unwrap_builtin_collection($v, "Array") or $self->_unwrap_builtin_collection($v, "Bag") or $self->_unwrap_builtin_collection($v, "Dict") or $self->_unwrap_builtin_collection($v, "PairList")) 2 0 2
Condition33%4/12
@items or $self->_unwrap_builtin_collection($v, "Array") or $self->_unwrap_builtin_collection($v, "Bag") or $self->_unwrap_builtin_collection($v, "Dict") or $self->_unwrap_builtin_collection($v, "PairList")
l!l&&r!l&&!r
002
@items or $self->_unwrap_builtin_collection($v, "Array") or $self->_unwrap_builtin_collection($v, "Bag") or $self->_unwrap_builtin_collection($v, "Dict")
l!l&&r!l&&!r
002
@items or $self->_unwrap_builtin_collection($v, "Array") or $self->_unwrap_builtin_collection($v, "Bag")
l!l&&r!l&&!r
002
@items or $self->_unwrap_builtin_collection($v, "Array")
l!l&&r!l&&!r
002
MC/DC0%0/5
@items or $self->_unwrap_builtin_collection($v, "Array") or $self->_unwrap_builtin_collection($v, "Bag") or $self->_unwrap_builtin_collection($v, "Dict") or $self->_unwrap_builtin_collection($v, "PairList")
@items $self->_unwrap_builtin_collection($v, "Array") $self->_unwrap_builtin_collection($v, "Bag") $self->_unwrap_builtin_collection($v, "Dict") $self->_unwrap_builtin_collection($v, "PairList")
Truth table16%1/6
A or B or C or D or E
A= @itemsB= $self->_unwrap_builtin_collection($v, "Array")C= $self->_unwrap_builtin_collection($v, "Bag")D= $self->_unwrap_builtin_collection($v, "Dict")E= $self->_unwrap_builtin_collection($v, "PairList")
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
3180 !@items
3181 and !$self->_unwrap_builtin_collection( $v, 'Array' )
3182 and !$self->_unwrap_builtin_collection( $v, 'Bag' )
3183 and !$self->_unwrap_builtin_collection( $v, 'Dict' )
3184 and !$self->_unwrap_builtin_collection( $v, 'PairList' )
3185 ) {
3186 2 die Zuzu::Error->new_runtime(
3187 message => "Set operator expects Array, Dict, Set, or Bag",
3188 file => $file,
3189 line => $line,
3190 );
3191 }
3192 0 my $set = Zuzu::Value::Set->new( items => [] );
3193 0 $set->add( @items );
3194  
3195 0 return $set;
3196 }
3197  
3198 72 ▶sub _in_collection {
Subroutine _in_collection: called CC=17 SCAR=42.4
3199 72 my ( $self, $needle, $col, $file, $line ) = @_;
3200  
3201 72 my $dict_like = $self->_unwrap_builtin_collection( $col, 'Dict' );
3202 72 ▶ if ( $dict_like ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dict_like) 9 63 72
3203 9 ▶ my $k = defined($needle) ? "$needle" : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $needle ? : 9 0 9
3204 9 return _boolify( exists $dict_like->map->{$k} );
3205 }
3206 63 my $pairlist_like = $self->_unwrap_builtin_collection( $col, 'PairList' );
3207 63 ▶ if ( $pairlist_like ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pairlist_like) 0 63 63
3208 0 ▶ my $k = defined($needle) ? "$needle" : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $needle ? : 0 0 0
3209 0 for my $pair ( @{ $pairlist_like->list } ) {
3210 0 ▶ return $TRUE if $pair->[0] eq $k;
Branch: 1 branch
BranchTrueFalseTotal
if $pair->[0] eq $k 0 0 0
3211 }
3212  
3213 0 return $FALSE;
3214 }
3215 63 for my $v ( $self->_collection_items($col) ) {
3216 179 ▶ return $TRUE if $self->_value_equal($needle, $v);
Branch: 1 branch
BranchTrueFalseTotal
if $self->_value_equal($needle, $v) 39 140 179
3217 }
3218 24 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_unwrap_builtin_collection($col, "Array") or $self->_unwrap_builtin_collection($col, "Set") or $self->_unwrap_builtin_collection($col, "Bag") or $self->_unwrap_builtin_collection($col, "Dict") or $self->_unwrap_builtin_collection($col, "PairList")) 24 0 24
Condition41%5/12
$self->_unwrap_builtin_collection($col, "Array") or $self->_unwrap_builtin_collection($col, "Set") or $self->_unwrap_builtin_collection($col, "Bag") or $self->_unwrap_builtin_collection($col, "Dict") or $self->_unwrap_builtin_collection($col, "PairList")
l!l&&r!l&&!r
2400
$self->_unwrap_builtin_collection($col, "Array") or $self->_unwrap_builtin_collection($col, "Set") or $self->_unwrap_builtin_collection($col, "Bag") or $self->_unwrap_builtin_collection($col, "Dict")
l!l&&r!l&&!r
2400
$self->_unwrap_builtin_collection($col, "Array") or $self->_unwrap_builtin_collection($col, "Set") or $self->_unwrap_builtin_collection($col, "Bag")
l!l&&r!l&&!r
2400
$self->_unwrap_builtin_collection($col, "Array") or $self->_unwrap_builtin_collection($col, "Set")
l!l&&r!l&&!r
1860
MC/DC0%0/5
$self->_unwrap_builtin_collection($col, "Array") or $self->_unwrap_builtin_collection($col, "Set") or $self->_unwrap_builtin_collection($col, "Bag") or $self->_unwrap_builtin_collection($col, "Dict") or $self->_unwrap_builtin_collection($col, "PairList")
$self->_unwrap_builtin_collection($col, "Array") $self->_unwrap_builtin_collection($col, "Set") $self->_unwrap_builtin_collection($col, "Bag") $self->_unwrap_builtin_collection($col, "Dict") $self->_unwrap_builtin_collection($col, "PairList")
Truth table33%2/6
A or B or C or D or E
A= $self->_unwrap_builtin_collection($col, "Array")B= $self->_unwrap_builtin_collection($col, "Set")C= $self->_unwrap_builtin_collection($col, "Bag")D= $self->_unwrap_builtin_collection($col, "Dict")E= $self->_unwrap_builtin_collection($col, "PairList")
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
3219 $self->_unwrap_builtin_collection( $col, 'Array' )
3220 or $self->_unwrap_builtin_collection( $col, 'Set' )
3221 or $self->_unwrap_builtin_collection( $col, 'Bag' )
3222 or $self->_unwrap_builtin_collection( $col, 'Dict' )
3223 or $self->_unwrap_builtin_collection( $col, 'PairList' )
3224 ) {
3225 24 return $FALSE;
3226 }
3227 0 ▶ if ( !ref($col) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $col) 0 0 0
3228 0 ▶ my $s = defined($col) ? "$col" : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $col ? : 0 0 0
3229 0 ▶ my $n = defined($needle) ? "$needle" : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $needle ? : 0 0 0
3230 0 return _boolify( index( $s, $n ) >= 0 );
3231 }
3232 0 die Zuzu::Error->new_runtime(
3233 message => "in expects a collection or string",
3234 file => $file,
3235 line => $line,
3236 );
3237 }
3238  
3239 5 ▶sub _set_union {
Subroutine _set_union: called CC=1 SCAR=0.0
3240 5 my ( $self, $left, $right, $file, $line ) = @_;
3241 5 my $lset = $self->_coerce_set($left, $file, $line);
3242 3 my $rset = $self->_coerce_set($right, $file, $line);
3243 3 my $out = Zuzu::Value::Set->new( items => [ @{ $lset->items } ] );
3244 3 $out->add( @{ $rset->items } );
3245  
3246 3 return $out;
3247 }
3248  
3249 1 ▶sub _set_intersection {
Subroutine _set_intersection: called CC=3 SCAR=11.0
3250 1 my ( $self, $left, $right, $file, $line ) = @_;
3251 1 my $lset = $self->_coerce_set($left, $file, $line);
3252 1 my $rset = $self->_coerce_set($right, $file, $line);
3253 1 my @out;
3254 1 for my $v ( @{ $lset->items } ) {
3255 3 ▶ push @out, $v if $self->_in_collection( $v, $rset, $file, $line );
Branch: 1 branch
BranchTrueFalseTotal
if $self->_in_collection($v, $rset, $file, $line) 1 2 3
3256 }
3257  
3258 1 return Zuzu::Value::Set->new( items => \@out );
3259 }
3260  
3261 5 ▶sub _set_difference {
Subroutine _set_difference: called CC=3 SCAR=11.0
3262 5 my ( $self, $left, $right, $file, $line ) = @_;
3263 5 my $lset = $self->_coerce_set($left, $file, $line);
3264 5 my $rset = $self->_coerce_set($right, $file, $line);
3265 5 my @out;
3266 5 for my $v ( @{ $lset->items } ) {
3267 13 ▶ push @out, $v if !$self->_in_collection( $v, $rset, $file, $line );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_in_collection($v, $rset, $file, $line) 2 11 13
3268 }
3269  
3270 5 return Zuzu::Value::Set->new( items => \@out );
3271 }
3272  
3273 23727 ▶sub eval_index {
Subroutine eval_index: called CC=16 SCAR=29.6
Pod documented
3274 23727 my ($self, $node) = @_;
3275  
3276 23727 my $target = $node->array->evaluate($self);
3277 23727 ▶ my $idx = 0 + ($node->index->evaluate($self) // 0);
Condition50%1/2
$node->index->evaluate($self) // 0
l!l
237270
MC/DC0%0/1
$node->index->evaluate($self) // 0
$node->index->evaluate($self)
Truth table50%1/2
A
A= $node->index->evaluate($self)
Aresult
11
00
3278 23727 my $arr = $self->_unwrap_builtin_collection( $target, 'Array' );
3279 23727 ▶ if ( defined $arr ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $arr) 23720 7 23727
3280 0 ▶ $idx += scalar @{ $arr->items } if $idx < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $idx < 0 0 23720 23720
3281 23720 ▶ return $arr->get($idx) if exists $arr->items->[$idx];
Branch: 1 branch
BranchTrueFalseTotal
if exists $arr->items->[$idx] 23720 0 23720
3282  
3283 0 return undef;
3284 }
3285 7 ▶ if ( blessed($target) and $target->isa('Zuzu::Value::BinaryString') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($target) and $target->isa("Zuzu::Value::BinaryString")) 3 4 7
Condition100%3/3
builtin::blessed($target) and $target->isa("Zuzu::Value::BinaryString")
!ll&&!rl&&r
223
MC/DC100%2/2
builtin::blessed($target) and $target->isa("Zuzu::Value::BinaryString")
builtin::blessed($target) $target->isa("Zuzu::Value::BinaryString")
Truth table100%3/3
A and B
A= builtin::blessed($target)B= $target->isa("Zuzu::Value::BinaryString")
ABresult
0X0
100
111
3286 3 ▶ my $bytes = $target->bytes // '';
Condition50%1/2
$target->bytes // ""
l!l
30
MC/DC0%0/1
$target->bytes // ""
$target->bytes
Truth table50%1/2
A
A= $target->bytes
Aresult
11
00
3287 3 my $len = length( $bytes );
3288 3 ▶ $idx += $len if $idx < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $idx < 0 1 2 3
3289 3 ▶ return undef if $idx < 0 or $idx >= $len;
Branch: 1 branch
BranchTrueFalseTotal
if $idx < 0 or $idx >= $len 0 3 3
Condition33%1/3
$idx < 0 or $idx >= $len
l!l&&r!l&&!r
003
MC/DC0%0/2
$idx < 0 or $idx >= $len
$idx < 0 $idx >= $len
Truth table33%1/3
A or B
A= $idx < 0B= $idx >= $len
ABresult
1X1
011
000
3290  
3291 3 return Zuzu::Value::BinaryString->new(
3292 bytes => substr( $bytes, $idx, 1 ),
3293 );
3294 }
3295 4 ▶ if ( defined($target) and !ref($target) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $target and not ref $target) 2 2 4
Condition66%2/3
defined $target and not ref $target
!ll&&!rl&&r
022
MC/DC50%1/2
defined $target and not ref $target
defined $target not ref $target
Truth table66%2/3
A and not(B)
A= defined $targetB= not ref $target
ABresult
0X0
100
111
3296 2 my $text = "$target";
3297 2 my $len = length($text);
3298 2 ▶ $idx += $len if $idx < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $idx < 0 1 1 2
3299 2 ▶ return undef if $idx < 0 or $idx >= $len;
Branch: 1 branch
BranchTrueFalseTotal
if $idx < 0 or $idx >= $len 0 2 2
Condition33%1/3
$idx < 0 or $idx >= $len
l!l&&r!l&&!r
002
MC/DC0%0/2
$idx < 0 or $idx >= $len
$idx < 0 $idx >= $len
Truth table33%1/3
A or B
A= $idx < 0B= $idx >= $len
ABresult
1X1
011
000
3300  
3301 2 return substr( $text, $idx, 1 );
3302 }
3303 2 die Zuzu::Error->new_runtime(message => "Indexing expects Array, String, or BinaryString", file => $node->file, line => $node->line);
3304 }
3305  
3306 7 ▶sub eval_slice {
Subroutine eval_slice: called CC=22 SCAR=33.2
Pod undocumented
3307 7 my ($self, $node) = @_;
3308  
3309 7 my $col = $node->collection->evaluate($self);
3310 7 ▶ my $start = defined $node->start ? 0 + ($node->start->evaluate($self) // 0) : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $node->start ? : 7 0 7
Condition50%1/2
$node->start->evaluate($self) // 0
l!l
70
MC/DC0%0/1
$node->start->evaluate($self) // 0
$node->start->evaluate($self)
Truth table50%1/2
A
A= $node->start->evaluate($self)
Aresult
11
00
3311 7 ▶ my $len = defined $node->length ? 0 + ($node->length->evaluate($self) // 0) : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $node->length ? : 5 2 7
Condition50%1/2
$node->length->evaluate($self) // 0
l!l
50
MC/DC0%0/1
$node->length->evaluate($self) // 0
$node->length->evaluate($self)
Truth table50%1/2
A
A= $node->length->evaluate($self)
Aresult
11
00
3312 7 my $arr = $self->_unwrap_builtin_collection( $col, 'Array' );
3313 7 ▶ if ( $arr ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($arr) 1 6 7
3314 1 my @vals = @{ $arr->items };
3315 1 ▶ $start = 0 if $start < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $start < 0 0 1 1
3316 1 ▶ my @out = defined $len
Branch: 1 branch
BranchTrueFalseTotal
defined $len ? : 1 0 1
3317 ? splice( @vals, $start, $len )
3318 : splice( @vals, $start );
3319  
3320 1 return Zuzu::Value::Array->new(items => \@out);
3321 }
3322 6 ▶ if ( blessed($col) and $col->isa('Zuzu::Value::BinaryString') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($col) and $col->isa("Zuzu::Value::BinaryString")) 3 3 6
Condition66%2/3
builtin::blessed($col) and $col->isa("Zuzu::Value::BinaryString")
!ll&&!rl&&r
303
MC/DC50%1/2
builtin::blessed($col) and $col->isa("Zuzu::Value::BinaryString")
builtin::blessed($col) $col->isa("Zuzu::Value::BinaryString")
Truth table66%2/3
A and B
A= builtin::blessed($col)B= $col->isa("Zuzu::Value::BinaryString")
ABresult
0X0
100
111
3323 3 ▶ my $bytes = $col->bytes // '';
Condition50%1/2
$col->bytes // ""
l!l
30
MC/DC0%0/1
$col->bytes // ""
$col->bytes
Truth table50%1/2
A
A= $col->bytes
Aresult
11
00
3324 3 my $size = length( $bytes );
3325 3 ▶ $start += $size if $start < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $start < 0 1 2 3
3326 3 ▶ $start = 0 if $start < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $start < 0 0 3 3
3327 3 ▶ $start = $size if $start > $size;
Branch: 1 branch
BranchTrueFalseTotal
if $start > $size 0 3 3
3328 3 ▶ my $slice = defined $len
Branch: 1 branch
BranchTrueFalseTotal
defined $len ? : 2 1 3
3329 ? substr( $bytes, $start, $len )
3330 : substr( $bytes, $start );
3331  
3332 3 return Zuzu::Value::BinaryString->new( bytes => $slice );
3333 }
3334 3 ▶ if ( defined($col) and !ref($col) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $col and not ref $col) 3 0 3
Condition33%1/3
defined $col and not ref $col
!ll&&!rl&&r
003
MC/DC0%0/2
defined $col and not ref $col
defined $col not ref $col
Truth table33%1/3
A and not(B)
A= defined $colB= not ref $col
ABresult
0X0
100
111
3335 3 ▶ my $text = defined($col) ? "$col" : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $col ? : 3 0 3
3336 3 my $size = length($text);
3337 3 ▶ $start += $size if $start < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $start < 0 1 2 3
3338 3 ▶ $start = 0 if $start < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $start < 0 0 3 3
3339 3 ▶ $start = $size if $start > $size;
Branch: 1 branch
BranchTrueFalseTotal
if $start > $size 0 3 3
3340  
3341 3 ▶ return defined $len
Branch: 1 branch
BranchTrueFalseTotal
defined $len ? : 2 1 3
3342 ? substr( $text, $start, $len )
3343 : substr( $text, $start );
3344 }
3345 0 die Zuzu::Error->new_runtime(message => "Slice expects Array, String, or BinaryString", file => $node->file, line => $node->line);
3346 }
3347  
3348 9389 ▶sub eval_dict_get {
Subroutine eval_dict_get: called CC=12 SCAR=37.0
Pod documented
3349 9389 my ($self, $node) = @_;
3350  
3351 9389 my $d = $node->dict->evaluate($self);
3352 9389 my $k = $node->key->evaluate($self);
3353 9389 ▶ $k = defined($k) ? "$k" : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $k ? : 9389 0 9389
3354 9389 my $dict = $self->_unwrap_builtin_collection( $d, 'Dict' );
3355 9389 ▶ if ( $dict ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dict) 2130 7259 9389
3356 2130 ▶ return slot_value( \$dict->map->{$k} ) if exists $dict->map->{$k};
Branch: 1 branch
BranchTrueFalseTotal
if exists $dict->map->{$k} 2130 0 2130
3357  
3358 0 return undef;
3359 }
3360 7259 my $pairlist = $self->_unwrap_builtin_collection( $d, 'PairList' );
3361 7259 ▶ if ( $pairlist ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pairlist) 22 7237 7259
3362 22 return $pairlist->get( $k );
3363 }
3364 7237 ▶ if ( blessed($d) and $d->isa('Zuzu::Value::Object') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($d) and $d->isa("Zuzu::Value::Object")) 7237 0 7237
Condition33%1/3
builtin::blessed($d) and $d->isa("Zuzu::Value::Object")
!ll&&!rl&&r
007237
MC/DC0%0/2
builtin::blessed($d) and $d->isa("Zuzu::Value::Object")
builtin::blessed($d) $d->isa("Zuzu::Value::Object")
Truth table33%1/3
A and B
A= builtin::blessed($d)B= $d->isa("Zuzu::Value::Object")
ABresult
0X0
100
111
3365 7237 return $self->_object_get($d, $k);
3366 }
3367 0 ▶ if ( blessed($d) and $d->isa('Zuzu::Value::Class') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($d) and $d->isa("Zuzu::Value::Class")) 0 0 0
Condition0%0/3
builtin::blessed($d) and $d->isa("Zuzu::Value::Class")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($d) and $d->isa("Zuzu::Value::Class")
builtin::blessed($d) $d->isa("Zuzu::Value::Class")
Truth table0%0/3
A and B
A= builtin::blessed($d)B= $d->isa("Zuzu::Value::Class")
ABresult
0X0
100
111
3368 0 ▶ return $d->nested_classes->{$k} if exists $d->nested_classes->{$k};
Branch: 1 branch
BranchTrueFalseTotal
if exists $d->nested_classes->{$k} 0 0 0
3369 0 my $sm = $self->_lookup_method($d, $k, 1);
3370 0 ▶ if ($sm) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sm) 0 0 0
3371 0 $sm->{_is_method} = 1;
3372  
3373 0 return $sm;
3374 }
3375 0 my $im = $self->_lookup_method($d, $k, 0);
3376 0 ▶ if ($im) {
Branch: 1 branch
BranchTrueFalseTotal
if ($im) 0 0 0
3377 0 $im->{_is_method} = 1;
3378  
3379 0 return $im;
3380 }
3381 }
3382 0 die Zuzu::Error->new_runtime(message => "Dict-style access expects Dict, PairList, Object, or Class", file => $node->file, line => $node->line);
3383 }
3384  
3385 34082 ▶sub eval_unary {
Subroutine eval_unary: called CC=31 SCAR=36.1
Pod documented
3386 34082 my ($self, $node) = @_;
3387  
3388 34082 ▶ if ( $node->op eq '\\' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->op eq "\\") 23 34059 34082
3389 23 ▶ if ( $self->_is_path_lvalue_expr( $node->expr ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_is_path_lvalue_expr($node->expr)) 3 20 23
3390 3 my $target = $self->_resolve_lvalue_target( $node->expr );
3391 3 ▶ return $target->{refs} if $target->{kind} eq 'path_multi_ref';
Branch: 1 branch
BranchTrueFalseTotal
if $target->{"kind"} eq "path_multi_ref" 1 2 3
3392 2 ▶ return undef if $target->{kind} eq 'path_maybe_ref' && !$target->{matched};
Branch: 1 branch
BranchTrueFalseTotal
if $target->{"kind"} eq "path_maybe_ref" and not $target->{"matched"} 1 1 2
Condition66%2/3
$target->{"kind"} eq "path_maybe_ref" and not $target->{"matched"}
!ll&&!rl&&r
101
MC/DC50%1/2
$target->{"kind"} eq "path_maybe_ref" and not $target->{"matched"}
$target->{"kind"} eq "path_maybe_ref" not $target->{"matched"}
Truth table66%2/3
A and not(B)
A= $target->{"kind"} eq "path_maybe_ref"B= not $target->{"matched"}
ABresult
0X0
100
111
3393 1 ▶ return $target->{ref_fn} if exists $target->{ref_fn};
Branch: 1 branch
BranchTrueFalseTotal
if exists $target->{"ref_fn"} 1 0 1
3394 }
3395 20 return $self->_make_lvalue_ref_closure( $node );
3396 }
3397  
3398 34059 my $v = $node->expr->evaluate($self);
3399 34029 my $op = $node->op;
3400  
3401 34029 ▶ return +$self->_to_Number($v) if $op eq '+';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "+" 0 34029 34029
3402  
3403 34029 ▶ return -$self->_to_Number($v) if $op eq '-';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "-" 25 34004 34029
3404  
3405 34004 ▶ return _boolify( ! $self->_to_Boolean($v) ) if $op eq '!' || $op eq '¬' || $op eq 'not';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "!" or $op eq "\x{ac}" or $op eq "not" 2939 31065 34004
Condition83%5/6
$op eq "!" or $op eq "\x{ac}" or $op eq "not"
l!l&&r!l&&!r
2293731065
$op eq "!" or $op eq "\x{ac}"
l!l&&r!l&&!r
2034002
MC/DC66%2/3
$op eq "!" or $op eq "\x{ac}" or $op eq "not"
$op eq "!" $op eq "\x{ac}" $op eq "not"
Truth table75%3/4
A or B or C
A= $op eq "!"B= $op eq "\x{ac}"C= $op eq "not"
ABCresult
1XX1
01X1
0011
0000
3406 31065 ▶ return $self->_bitwise_not_value( $v, $node->file, $node->line ) if $op eq '~';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "~" 9 31056 31065
3407 31056 ▶ return abs( $self->_to_Number($v) ) if $op eq 'abs';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "abs" 0 31056 31056
3408 31056 ▶ return sqrt( $self->_to_Number($v) ) if $op eq 'sqrt' || $op eq '√';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "sqrt" or $op eq "\x{221a}" 0 31056 31056
Condition33%1/3
$op eq "sqrt" or $op eq "\x{221a}"
l!l&&r!l&&!r
0031056
MC/DC0%0/2
$op eq "sqrt" or $op eq "\x{221a}"
$op eq "sqrt" $op eq "\x{221a}"
Truth table33%1/3
A or B
A= $op eq "sqrt"B= $op eq "\x{221a}"
ABresult
1X1
011
000
3409 31056 ▶ return int( $self->_to_Number($v) ) if $op eq 'floor' || $op eq 'int';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "floor" or $op eq "int" 140 30916 31056
Condition66%2/3
$op eq "floor" or $op eq "int"
l!l&&r!l&&!r
140030916
MC/DC50%1/2
$op eq "floor" or $op eq "int"
$op eq "floor" $op eq "int"
Truth table66%2/3
A or B
A= $op eq "floor"B= $op eq "int"
ABresult
1X1
011
000
3410 30916 ▶ return _zuzu_ceil( $self->_to_Number($v) ) if $op eq 'ceil';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "ceil" 1 30915 30916
3411 30915 ▶ return _zuzu_round( $self->_to_Number($v) ) if $op eq 'round';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "round" 3 30912 30915
3412 30912 ▶ if ( $op eq 'uc' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "uc") 1 30911 30912
3413 1 ▶ if ( blessed($v) and $v->isa('Zuzu::Value::BinaryString') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($v) and $v->isa("Zuzu::Value::BinaryString")) 1 0 1
Condition33%1/3
builtin::blessed($v) and $v->isa("Zuzu::Value::BinaryString")
!ll&&!rl&&r
001
MC/DC0%0/2
builtin::blessed($v) and $v->isa("Zuzu::Value::BinaryString")
builtin::blessed($v) $v->isa("Zuzu::Value::BinaryString")
Truth table33%1/3
A and B
A= builtin::blessed($v)B= $v->isa("Zuzu::Value::BinaryString")
ABresult
0X0
100
111
3414 1 die Zuzu::Error->new_runtime(
3415 message => "TypeException: uc expects String, got BinaryString",
3416 file => $node->file,
3417 line => $node->line,
3418 );
3419 }
3420 0 return uc( $self->_to_OperatorString( $v, $node->file, $node->line ) );
3421 }
3422 30911 ▶ if ( $op eq 'lc' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "lc") 2 30909 30911
3423 2 ▶ if ( blessed($v) and $v->isa('Zuzu::Value::BinaryString') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($v) and $v->isa("Zuzu::Value::BinaryString")) 1 1 2
Condition66%2/3
builtin::blessed($v) and $v->isa("Zuzu::Value::BinaryString")
!ll&&!rl&&r
101
MC/DC50%1/2
builtin::blessed($v) and $v->isa("Zuzu::Value::BinaryString")
builtin::blessed($v) $v->isa("Zuzu::Value::BinaryString")
Truth table66%2/3
A and B
A= builtin::blessed($v)B= $v->isa("Zuzu::Value::BinaryString")
ABresult
0X0
100
111
3424 1 die Zuzu::Error->new_runtime(
3425 message => "TypeException: lc expects String, got BinaryString",
3426 file => $node->file,
3427 line => $node->line,
3428 );
3429 }
3430 1 return lc( $self->_to_OperatorString( $v, $node->file, $node->line ) );
3431 }
3432 30909 ▶ if ( $op eq 'length' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "length") 30891 18 30909
3433 30891 ▶ if ( blessed($v) and $v->isa('Zuzu::Value::BinaryString') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($v) and $v->isa("Zuzu::Value::BinaryString")) 11 30880 30891
Condition66%2/3
builtin::blessed($v) and $v->isa("Zuzu::Value::BinaryString")
!ll&&!rl&&r
30880011
MC/DC50%1/2
builtin::blessed($v) and $v->isa("Zuzu::Value::BinaryString")
builtin::blessed($v) $v->isa("Zuzu::Value::BinaryString")
Truth table66%2/3
A and B
A= builtin::blessed($v)B= $v->isa("Zuzu::Value::BinaryString")
ABresult
0X0
100
111
3434 11 return $v->byte_length;
3435 }
3436 30880 return length( $self->_to_OperatorString( $v, $node->file, $node->line ) );
3437 }
3438 18 ▶ if ( $op eq '#' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "#") 0 18 18
3439 0 return $self->_cardinality_value( $v, $node->file, $node->line );
3440 }
3441 18 ▶ return $self->_type_name($v) if $op eq 'typeof';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "typeof" 18 0 18
3442 0 die Zuzu::Error->new_runtime(message => "Unsupported unary op '$op'", file => $node->file, line => $node->line);
3443 }
3444  
3445 0 ▶sub _cardinality_value {
Subroutine _cardinality_value: not called CC=10 SCAR=47.0
3446 0 my ( $self, $value, $file, $line ) = @_;
3447  
3448 0 ▶ if ( blessed($value) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($value)) 0 0 0
3449 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($value->isa("Zuzu::Value::Array") or $value->isa("Zuzu::Value::Dict") or $value->isa("Zuzu::Value::PairList") or $value->isa("Zuzu::Value::Set") or $value->isa("Zuzu::Value::Bag")) 0 0 0
Condition0%0/12
$value->isa("Zuzu::Value::Array") or $value->isa("Zuzu::Value::Dict") or $value->isa("Zuzu::Value::PairList") or $value->isa("Zuzu::Value::Set") or $value->isa("Zuzu::Value::Bag")
l!l&&r!l&&!r
000
$value->isa("Zuzu::Value::Array") or $value->isa("Zuzu::Value::Dict") or $value->isa("Zuzu::Value::PairList") or $value->isa("Zuzu::Value::Set")
l!l&&r!l&&!r
000
$value->isa("Zuzu::Value::Array") or $value->isa("Zuzu::Value::Dict") or $value->isa("Zuzu::Value::PairList")
l!l&&r!l&&!r
000
$value->isa("Zuzu::Value::Array") or $value->isa("Zuzu::Value::Dict")
l!l&&r!l&&!r
000
MC/DC0%0/5
$value->isa("Zuzu::Value::Array") or $value->isa("Zuzu::Value::Dict") or $value->isa("Zuzu::Value::PairList") or $value->isa("Zuzu::Value::Set") or $value->isa("Zuzu::Value::Bag")
$value->isa("Zuzu::Value::Array") $value->isa("Zuzu::Value::Dict") $value->isa("Zuzu::Value::PairList") $value->isa("Zuzu::Value::Set") $value->isa("Zuzu::Value::Bag")
Truth table0%0/6
A or B or C or D or E
A= $value->isa("Zuzu::Value::Array")B= $value->isa("Zuzu::Value::Dict")C= $value->isa("Zuzu::Value::PairList")D= $value->isa("Zuzu::Value::Set")E= $value->isa("Zuzu::Value::Bag")
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
3450 $value->isa('Zuzu::Value::Array')
3451 or $value->isa('Zuzu::Value::Dict')
3452 or $value->isa('Zuzu::Value::PairList')
3453 or $value->isa('Zuzu::Value::Set')
3454 or $value->isa('Zuzu::Value::Bag')
3455 ) {
3456 0 return $value->count;
3457 }
3458 0 ▶ if ( $value->isa('Zuzu::Value::Object') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value->isa("Zuzu::Value::Object")) 0 0 0
3459 0 my $method = $self->_lookup_method( $value->class, 'count', 0 );
3460 0 ▶ return $self->_call_method(
Branch: 1 branch
BranchTrueFalseTotal
if $method 0 0 0
3461 $method,
3462 $value,
3463 [],
3464 $EMPTY_HASH,
3465 $EMPTY_ARRAY,
3466 $file,
3467 $line,
3468 ) if $method;
3469 }
3470 0 ▶ if ( $value->isa('Zuzu::Value::BinaryString') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value->isa("Zuzu::Value::BinaryString")) 0 0 0
3471 0 return $value->byte_length;
3472 }
3473 }
3474  
3475 0 return length( $self->_to_OperatorString( $value, $file, $line ) );
3476 }
3477  
3478 20 ▶sub _make_lvalue_ref_closure {
Subroutine _make_lvalue_ref_closure: called CC=1 SCAR=2.4
3479 20 my ( $self, $node ) = @_;
3480  
3481 20 my $captured_env = $self->_env;
3482 20 my $target = $node->expr;
3483  
3484 20 my $fn = Zuzu::Value::Function->new(
3485 name => '<ref>',
3486 params => [],
3487 vararg => '__args',
3488 body => undef,
3489 closure_env => $captured_env,
3490 );
3491 32 ▶ $fn->{_native} = sub {
Subroutine __ANON__: called CC=35 SCAR=60.3
3492 32 my @args = @_;
3493 32 my $call_env = Zuzu::Env->_new_fast( $captured_env );
3494 32 $self->_push_env( $call_env );
3495 32 $call_env->declare( '__argc__', 0 + scalar @args, 1, 'Number' );
3496  
3497 32 my $ret;
3498 eval {
3499 32 ▶ if ( scalar @args == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @args == 0) { } 13 19 32
3500 13 $ret = $target->evaluate($self);
3501 }
3502 else {
3503 19 my $target_info = $self->_resolve_lvalue_target( $target );
3504 my (
3505 $ref, $name, $target_env, $file, $line, $slice_col,
3506 $string_ref, $string_index, $binary_string,
3507 $binary_string_index, $pairlist, $pairlist_key
3508 )
3509 = (
3510 $target_info->{ref},
3511 $target_info->{name},
3512 $target_info->{env},
3513 $target_info->{file},
3514 $target_info->{line},
3515 $target_info->{slice_col},
3516 $target_info->{string_ref},
3517 $target_info->{kind} && $target_info->{kind} eq 'string_index',
3518 $target_info->{binary_string},
3519 $target_info->{kind} && $target_info->{kind} eq 'binary_string_index',
3520 $target_info->{pairlist},
3521 $target_info->{pairlist_key},
3522 19 ▶ );
Condition33%2/6
$target_info->{'kind'} && $target_info->{'kind'} eq 'string_index'
!ll&&!rl&&r
0190
$target_info->{'kind'} && $target_info->{'kind'} eq 'binary_string_index'
!ll&&!rl&&r
0190
MC/DC0%0/2
$target_info->{'kind'} && $target_info->{'kind'} eq 'string_index'
$target_info->{'kind'} $target_info->{'kind'} eq 'string_index'
MC/DC0%0/2
$target_info->{'kind'} && $target_info->{'kind'} eq 'binary_string_index'
$target_info->{'kind'} $target_info->{'kind'} eq 'binary_string_index'
Truth table33%1/3
A && B
A= $target_info->{'kind'}B= $target_info->{'kind'} eq 'string_index'
ABresult
0X0
100
111
Truth table33%1/3
A && B
A= $target_info->{'kind'}B= $target_info->{'kind'} eq 'binary_string_index'
ABresult
0X0
100
111
3523 die Zuzu::Error->new_runtime(
3524 message => "Cannot assign to const field",
3525 file => $file,
3526 line => $line,
3527 19 ▶ ) if $target_info->{const};
Branch: 1 branch
BranchTrueFalseTotal
if $target_info->{"const"} 0 19 19
3528  
3529 19 ▶ if ( defined $name ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $name) 0 19 19
3530 my $const_here = defined $target_env
3531 0 ▶ ? $target_env->{const}{$name}
Branch: 1 branch
BranchTrueFalseTotal
defined $target_env ? : 0 0 0
3532 : $self->_env->is_const_here($name);
3533 0 ▶ if ( ! defined $const_here and ! defined $target_env ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $const_here or defined $target_env) 0 0 0
Condition0%0/3
defined $const_here or defined $target_env
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $const_here or defined $target_env
defined $const_here defined $target_env
Truth table0%0/3
A or B
A= defined $const_hereB= defined $target_env
ABresult
1X1
011
000
3534 0 my $env = $self->_env;
3535 0 ▶ while ( $env ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($env) 0 0 0
3536 0 ▶ if ( exists $env->{slots}{$name} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $env->{"slots"}{$name}) 0 0 0
3537 0 $const_here = $env->{const}{$name};
3538 0 last;
3539 }
3540 0 $env = $env->{parent};
3541 }
3542 }
3543 0 ▶ die Zuzu::Error->new_runtime(
Branch: 1 branch
BranchTrueFalseTotal
if $const_here 0 0 0
3544 message => "Cannot assign to const '$name'",
3545 file => $file,
3546 line => $line,
3547 ) if $const_here;
3548 }
3549 19 my $newval = $args[0];
3550 my $weak_write = $target_info->{weak_storage}
3551 19 ▶ || ( @args > 1 && Zuzu::Util::boolify( $args[1] ) )
Branch: 1 branch
BranchTrueFalseTotal
$target_info->{'weak_storage'} || @args > 1 && Zuzu::Util::boolify($args[1]) ? : 3 16 19
Condition66%4/6
$target_info->{"weak_storage"} or @args > 1 and Zuzu::Util::boolify($args[1])
l!l&&r!l&&!r
0316
@args > 1 and Zuzu::Util::boolify($args[1])
!ll&&!rl&&r
1603
MC/DC33%1/3
$target_info->{"weak_storage"} or @args > 1 and Zuzu::Util::boolify($args[1])
$target_info->{"weak_storage"} @args > 1 Zuzu::Util::boolify($args[1])
Truth table50%2/4
A or B and C
A= $target_info->{"weak_storage"}B= @args > 1C= Zuzu::Util::boolify($args[1])
ABCresult
1XX1
0111
00X0
0100
3552 ? 1
3553 : 0;
3554 19 ▶ if ( $target_info->{kind} && $target_info->{kind} eq 'path_single_ref' ) {
Branch: 7 branches
BranchTrueFalseTotal
if ($target_info->{'kind'} and $target_info->{'kind'} eq 'path_single_ref') { } 0 19 19
elsif ($target_info->{'kind'} and $target_info->{'kind'} eq 'path_maybe_ref') { } 0 19 19
elsif ($target_info->{'kind'} and $target_info->{'kind'} eq 'path_multi_ref') { } 0 19 19
elsif ($pairlist) { } 0 19 19
elsif ($slice_col) { } 0 19 19
elsif ($string_ref) { } 0 19 19
elsif ($binary_string) { } 0 19 19
Condition33%1/3
$target_info->{"kind"} and $target_info->{"kind"} eq "path_single_ref"
!ll&&!rl&&r
0190
MC/DC0%0/2
$target_info->{"kind"} and $target_info->{"kind"} eq "path_single_ref"
$target_info->{"kind"} $target_info->{"kind"} eq "path_single_ref"
Truth table33%1/3
A and B
A= $target_info->{"kind"}B= $target_info->{"kind"} eq "path_single_ref"
ABresult
0X0
100
111
3555 0 $ret = $self->_call_ref_closure_set( $target_info->{ref_fn}, $newval, $file, $line );
3556 }
3557 ▶ elsif ( $target_info->{kind} && $target_info->{kind} eq 'path_maybe_ref' ) {
Condition33%1/3
$target_info->{"kind"} and $target_info->{"kind"} eq "path_maybe_ref"
!ll&&!rl&&r
0190
MC/DC0%0/2
$target_info->{"kind"} and $target_info->{"kind"} eq "path_maybe_ref"
$target_info->{"kind"} $target_info->{"kind"} eq "path_maybe_ref"
Truth table33%1/3
A and B
A= $target_info->{"kind"}B= $target_info->{"kind"} eq "path_maybe_ref"
ABresult
0X0
100
111
3558 $ret = ! $target_info->{matched}
3559 ? undef
3560 0 ▶ : $self->_call_ref_closure_set( $target_info->{ref_fn}, $newval, $file, $line );
Branch: 1 branch
BranchTrueFalseTotal
!$target_info->{'matched'} ? : 0 0 0
3561 }
3562 ▶ elsif ( $target_info->{kind} && $target_info->{kind} eq 'path_multi_ref' ) {
Condition33%1/3
$target_info->{"kind"} and $target_info->{"kind"} eq "path_multi_ref"
!ll&&!rl&&r
0190
MC/DC0%0/2
$target_info->{"kind"} and $target_info->{"kind"} eq "path_multi_ref"
$target_info->{"kind"} $target_info->{"kind"} eq "path_multi_ref"
Truth table33%1/3
A and B
A= $target_info->{"kind"}B= $target_info->{"kind"} eq "path_multi_ref"
ABresult
0X0
100
111
3563 0 die Zuzu::Error->new_runtime(
3564 message => "Reference operator expects a single assignable target",
3565 file => $file,
3566 line => $line,
3567 );
3568 }
3569 elsif ( $pairlist ) {
3570 0 $pairlist->_append( $pairlist_key, $newval, $weak_write );
3571 0 $ret = $newval;
3572 }
3573 elsif ( $slice_col ) {
3574 0 ▶ my $start = defined $target->start
Branch: 1 branch
BranchTrueFalseTotal
defined $target->start ? : 0 0 0
Condition0%0/2
$target->start->evaluate($self) // 0
l!l
00
MC/DC0%0/1
$target->start->evaluate($self) // 0
$target->start->evaluate($self)
Truth table0%0/2
A
A= $target->start->evaluate($self)
Aresult
11
00
3575 ? 0 + ( $target->start->evaluate($self) // 0 )
3576 : 0;
3577 0 my $len;
3578 0 ▶ if ( defined $target->length ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $target->length) { } 0 0 0
3579 0 ▶ $len = 0 + ( $target->length->evaluate($self) // 0 );
Condition0%0/2
$target->length->evaluate($self) // 0
l!l
00
MC/DC0%0/1
$target->length->evaluate($self) // 0
$target->length->evaluate($self)
Truth table0%0/2
A
A= $target->length->evaluate($self)
Aresult
11
00
3580 }
3581 else {
3582 0 $len = scalar( @{ $slice_col->items } ) - $start;
3583 }
3584 0 ▶ die Zuzu::Error->new_runtime(
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($newval) and $newval->isa("Zuzu::Value::Array") 0 0 0
Condition0%0/3
builtin::blessed($newval) and $newval->isa("Zuzu::Value::Array")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($newval) and $newval->isa("Zuzu::Value::Array")
builtin::blessed($newval) $newval->isa("Zuzu::Value::Array")
Truth table0%0/3
A and B
A= builtin::blessed($newval)B= $newval->isa("Zuzu::Value::Array")
ABresult
0X0
100
111
3585 message => "Slice assignment RHS must be Array",
3586 file => $file,
3587 line => $line,
3588 ) if ! blessed($newval) or ! $newval->isa('Zuzu::Value::Array');
3589 0 splice @{ $slice_col->items }, $start, $len, @{ $newval->items };
3590 0 $ret = $newval;
3591 }
3592 elsif ( $string_ref ) {
3593 0 ▶ if ( $string_index ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($string_index) { } 0 0 0
3594 0 $self->_assign_string_index(
3595 $string_ref,
3596 $target,
3597 $newval,
3598 $name,
3599 $target_env,
3600 $file,
3601 $line,
3602 );
3603 }
3604 else {
3605 0 $self->_assign_string_slice(
3606 $string_ref,
3607 $target,
3608 $newval,
3609 $name,
3610 $target_env,
3611 $file,
3612 $line,
3613 );
3614 }
3615 0 $ret = $newval;
3616 }
3617 elsif ( $binary_string ) {
3618 0 ▶ if ( $binary_string_index ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($binary_string_index) { } 0 0 0
3619 0 $self->_assign_binary_string_index(
3620 $binary_string,
3621 $target,
3622 $newval,
3623 $file,
3624 $line,
3625 );
3626 }
3627 else {
3628 0 $self->_assign_binary_string_slice(
3629 $binary_string,
3630 $target,
3631 $newval,
3632 $file,
3633 $line,
3634 );
3635 }
3636 0 $ret = $newval;
3637 }
3638 else {
3639 19 store_value( $ref, $newval, $weak_write );
3640 19 $ret = $newval;
3641 }
3642 }
3643 32 1;
3644 32 ▶ } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { if (scalar @args == 0) { $ret = $target->evaluate($self); } else { my $target_info = $self->_resolve_lvalue_target($target); () = ($target_info->{"ref"}, $target_info->{"name"}, $target_info->{"env"}, $target_info->{"file"}, $target_info->{"line"}, $target_info->{"slice_col"}, $target_info->{"string_ref"}, $target_info->{"kind"} && $target_info->{"kind"} eq "string_index", $target_info->{"binary_string"}, $target_info->{"kind"} && $target_info->{"kind"} eq "binary_string_index", $target_info->{"pairlist"}, $target_info->{"pairlist_key"}); die "Zuzu::Error"->new_runtime("message", "Cannot assign to const field", "file", $file, "line", $line) if $target_info->{"const"}; if (defined $name) { my $const_here = defined $target_env ? $target_env->{"const"}{$name} : $self->_env->is_const_here($name); unless (defined $const_here or defined $target_env) { my $env = $self->_env; while ($env) { if (exists $env->{"slots"}{$name}) { $const_here = $env->{"const"}{$name}; last; } ; $env = $env->{"parent"}; } ; } ; die "Zuzu::Error"->new_runtime("message", "Cannot assign to const '${name}'", "file", $file, "line", $line) if $const_here; } ; my $newval = $args[0]; my $weak_write = $target_info->{"weak_storage"} || @args > 1 && Zuzu::Util::boolify($args[1]) ? 1 : 0; if ($target_info->{"kind"} and $target_info->{"kind"} eq "path_single_ref") { $ret = $self->_call_ref_closure_set($target_info->{"ref_fn"}, $newval, $file, $line); } elsif ($target_info->{"kind"} and $target_info->{"kind"} eq "path_maybe_ref") { $ret = !$target_info->{"matched"} ? undef : $self->_call_ref_closure_set($target_info->{"ref_fn"}, $newval, $file, $line); } elsif ($target_info->{"kind"} and $target_info->{"kind"} eq "path_multi_ref") { die "Zuzu::Error"->new_runtime("message", "Reference operator expects a single assignable target", "file", $file, "line", $line); } elsif ($pairlist) { $pairlist->_append($pairlist_key, $newval, $weak_write); $ret = $newval; } elsif ($slice_col) { my $start = defined $target->start ? 0 + ($target->start->evaluate($self) // 0) : 0; my $len; if (defined $target->length) { $len = 0 + ($target->length->evaluate($self) // 0); } else { $len = scalar(@{$slice_col->items;}) - $start; } ; die "Zuzu::Error"->new_runtime("message", "Slice assignment RHS must be Array", "file", $file, "line", $line) unless builtin::blessed($newval) and $newval->isa("Zuzu::Value::Array"); splice @{$slice_col->items;}, $start, $len, @{$newval->items;}; $ret = $newval; } elsif ($string_ref) { if ($string_index) { $self->_assign_string_index($string_ref, $target, $newval, $name, $target_env, $file, $line); } else { $self->_assign_string_slice($string_ref, $target, $newval, $name, $target_env, $file, $line); } ; $ret = $newval; } elsif ($binary_string) { if ($binary_string_index) { $self->_assign_binary_string_index($binary_string, $target, $newval, $file, $line); } else { $self->_assign_binary_string_slice($binary_string, $target, $newval, $file, $line); } ; $ret = $newval; } else { store_value($ref, $newval, $weak_write); $ret = $newval; } ; } ; 1 } } or do { my $e = $@; $self->_pop_env; die $e } 32 0 32
3645 0 my $e = $@;
3646 0 $self->_pop_env;
3647 0 die $e;
3648 };
3649  
3650 32 $self->_pop_env;
3651 32 return $ret;
3652 20 };
3653  
3654 20 return $fn;
3655 }
3656  
3657 46791 ▶sub _type_name {
Subroutine _type_name: called CC=31 SCAR=35.0
3658 46791 my ( $self, $x ) = @_;
3659  
3660 46791 ▶ return 'Null' if !defined $x;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $x 19 46772 46791
3661  
3662 46772 my ( $array_like, $dict_like, $pairlist_like, $set_like, $bag_like )
3663 = $self->_builtin_collection_views($x);
3664 46772 ▶ return 'Array' if $array_like;
Branch: 1 branch
BranchTrueFalseTotal
if $array_like 365 46407 46772
3665 46407 ▶ return 'Dict' if $dict_like;
Branch: 1 branch
BranchTrueFalseTotal
if $dict_like 1032 45375 46407
3666 45375 ▶ return 'PairList' if $pairlist_like;
Branch: 1 branch
BranchTrueFalseTotal
if $pairlist_like 54 45321 45375
3667 45321 ▶ return 'Set' if $set_like;
Branch: 1 branch
BranchTrueFalseTotal
if $set_like 47 45274 45321
3668 45274 ▶ return 'Bag' if $bag_like;
Branch: 1 branch
BranchTrueFalseTotal
if $bag_like 33 45241 45274
3669 45241 ▶ return 'Regexp' if blessed($x) and $x->isa('Zuzu::Value::Regexp');
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($x) and $x->isa("Zuzu::Value::Regexp") 2 45239 45241
Condition100%3/3
builtin::blessed($x) and $x->isa("Zuzu::Value::Regexp")
!ll&&!rl&&r
24162210772
MC/DC100%2/2
builtin::blessed($x) and $x->isa("Zuzu::Value::Regexp")
builtin::blessed($x) $x->isa("Zuzu::Value::Regexp")
Truth table100%3/3
A and B
A= builtin::blessed($x)B= $x->isa("Zuzu::Value::Regexp")
ABresult
0X0
100
111
3670 45239 ▶ return 'Regexp' if ref($x) eq 'Regexp';
Branch: 1 branch
BranchTrueFalseTotal
if ref $x eq "Regexp" 0 45239 45239
3671 45239 ▶ return 'BinaryString' if blessed($x) and $x->isa('Zuzu::Value::BinaryString');
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($x) and $x->isa("Zuzu::Value::BinaryString") 38 45201 45239
Condition100%3/3
builtin::blessed($x) and $x->isa("Zuzu::Value::BinaryString")
!ll&&!rl&&r
241622103938
MC/DC100%2/2
builtin::blessed($x) and $x->isa("Zuzu::Value::BinaryString")
builtin::blessed($x) $x->isa("Zuzu::Value::BinaryString")
Truth table100%3/3
A and B
A= builtin::blessed($x)B= $x->isa("Zuzu::Value::BinaryString")
ABresult
0X0
100
111
3672 45201 ▶ return 'Task' if blessed($x) and $x->isa('Zuzu::Value::Task');
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($x) and $x->isa("Zuzu::Value::Task") 0 45201 45201
Condition66%2/3
builtin::blessed($x) and $x->isa("Zuzu::Value::Task")
!ll&&!rl&&r
24162210390
MC/DC0%0/2
builtin::blessed($x) and $x->isa("Zuzu::Value::Task")
builtin::blessed($x) $x->isa("Zuzu::Value::Task")
Truth table66%2/3
A and B
A= builtin::blessed($x)B= $x->isa("Zuzu::Value::Task")
ABresult
0X0
100
111
3673  
3674 45201 ▶ return 'Method' if blessed($x) and $x->isa('Zuzu::Value::Function') and $x->{_is_method};
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($x) and $x->isa("Zuzu::Value::Function") and $x->{"_is_method"} 0 45201 45201
Condition83%5/6
builtin::blessed($x) and $x->isa("Zuzu::Value::Function") and $x->{"_is_method"}
!ll&&!rl&&r
3982053810
builtin::blessed($x) and $x->isa("Zuzu::Value::Function")
!ll&&!rl&&r
24162156585381
MC/DC0%0/3
builtin::blessed($x) and $x->isa("Zuzu::Value::Function") and $x->{"_is_method"}
builtin::blessed($x) $x->isa("Zuzu::Value::Function") $x->{"_is_method"}
Truth table75%3/4
A and B and C
A= builtin::blessed($x)B= $x->isa("Zuzu::Value::Function")C= $x->{"_is_method"}
ABCresult
0XX0
10X0
1100
1111
3675 45201 ▶ return 'Function' if blessed($x) and $x->isa('Zuzu::Value::Function');
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($x) and $x->isa("Zuzu::Value::Function") 5381 39820 45201
Condition100%3/3
builtin::blessed($x) and $x->isa("Zuzu::Value::Function")
!ll&&!rl&&r
24162156585381
MC/DC100%2/2
builtin::blessed($x) and $x->isa("Zuzu::Value::Function")
builtin::blessed($x) $x->isa("Zuzu::Value::Function")
Truth table100%3/3
A and B
A= builtin::blessed($x)B= $x->isa("Zuzu::Value::Function")
ABresult
0X0
100
111
3676 39820 ▶ return 'Class' if blessed($x) and $x->isa('Zuzu::Value::Class');
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($x) and $x->isa("Zuzu::Value::Class") 3 39817 39820
Condition100%3/3
builtin::blessed($x) and $x->isa("Zuzu::Value::Class")
!ll&&!rl&&r
24162156553
MC/DC100%2/2
builtin::blessed($x) and $x->isa("Zuzu::Value::Class")
builtin::blessed($x) $x->isa("Zuzu::Value::Class")
Truth table100%3/3
A and B
A= builtin::blessed($x)B= $x->isa("Zuzu::Value::Class")
ABresult
0X0
100
111
3677 39817 ▶ return $x->class->name if blessed($x) and $x->isa('Zuzu::Value::Object') and blessed($x->class);
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($x) and $x->isa("Zuzu::Value::Object") and builtin::blessed($x->class) 21 39796 39817
Condition83%5/6
builtin::blessed($x) and $x->isa("Zuzu::Value::Object") and builtin::blessed($x->class)
!ll&&!rl&&r
39796021
builtin::blessed($x) and $x->isa("Zuzu::Value::Object")
!ll&&!rl&&r
241621563421
MC/DC66%2/3
builtin::blessed($x) and $x->isa("Zuzu::Value::Object") and builtin::blessed($x->class)
builtin::blessed($x) $x->isa("Zuzu::Value::Object") builtin::blessed($x->class)
Truth table75%3/4
A and B and C
A= builtin::blessed($x)B= $x->isa("Zuzu::Value::Object")C= builtin::blessed($x->class)
ABCresult
0XX0
10X0
1100
1111
3678 39796 ▶ return 'Object' if blessed($x) and $x->isa('Zuzu::Value::Object');
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($x) and $x->isa("Zuzu::Value::Object") 0 39796 39796
Condition66%2/3
builtin::blessed($x) and $x->isa("Zuzu::Value::Object")
!ll&&!rl&&r
24162156340
MC/DC0%0/2
builtin::blessed($x) and $x->isa("Zuzu::Value::Object")
builtin::blessed($x) $x->isa("Zuzu::Value::Object")
Truth table66%2/3
A and B
A= builtin::blessed($x)B= $x->isa("Zuzu::Value::Object")
ABresult
0X0
100
111
3679 39796 ▶ return 'Boolean' if blessed($x) and $x->isa('Zuzu::Value::Boolean');
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($x) and $x->isa("Zuzu::Value::Boolean") 15634 24162 39796
Condition66%2/3
builtin::blessed($x) and $x->isa("Zuzu::Value::Boolean")
!ll&&!rl&&r
24162015634
MC/DC50%1/2
builtin::blessed($x) and $x->isa("Zuzu::Value::Boolean")
builtin::blessed($x) $x->isa("Zuzu::Value::Boolean")
Truth table66%2/3
A and B
A= builtin::blessed($x)B= $x->isa("Zuzu::Value::Boolean")
ABresult
0X0
100
111
3680 24162 ▶ return 'Number' if !ref($x) and equality_type( $x ) eq 'Number';
Branch: 1 branch
BranchTrueFalseTotal
if not ref $x and equality_type($x) eq "Number" 6426 17736 24162
Condition66%2/3
not ref $x and equality_type($x) eq "Number"
!ll&&!rl&&r
0177366426
MC/DC50%1/2
not ref $x and equality_type($x) eq "Number"
not ref $x equality_type($x) eq "Number"
Truth table66%2/3
not(A) and B
A= not ref $xB= equality_type($x) eq "Number"
ABresult
0X0
100
111
3681  
3682 17736 ▶ return 'String' if !ref($x);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $x 17736 0 17736
3683  
3684 0 return 'Object';
3685 }
3686  
3687 142013 ▶sub _assert_declared_type {
Subroutine _assert_declared_type: called CC=6 SCAR=18.5
3688 142013 my ( $self, $declared_type, $value, $file, $line, $name ) = @_;
3689  
3690 142013 ▶ $declared_type //= 'Any';
Condition50%1/2
$declared_type //= "Any"
l!l
1420130
MC/DC0%0/1
$declared_type //= "Any"
$declared_type
Truth table50%1/2
A
A= $declared_type
Aresult
11
00
3691 142013 ▶ return if $declared_type eq 'Any';
Branch: 1 branch
BranchTrueFalseTotal
if $declared_type eq "Any" 97065 44948 142013
3692 44948 ▶ return if $self->_value_matches_declared_type( $declared_type, $value );
Branch: 1 branch
BranchTrueFalseTotal
if $self->_value_matches_declared_type($declared_type, $value) 44937 11 44948
3693  
3694 11 my $actual = $self->_type_name($value);
3695 11 ▶ my $label = defined $name && $name ne '' ? "'$name'" : 'value';
Branch: 1 branch
BranchTrueFalseTotal
defined $name && $name ne '' ? : 11 0 11
Condition33%1/3
defined $name and $name ne ""
!ll&&!rl&&r
0011
MC/DC0%0/2
defined $name and $name ne ""
defined $name $name ne ""
Truth table33%1/3
A and B
A= defined $nameB= $name ne ""
ABresult
0X0
100
111
3696 11 my $message = "TypeException: $label must be $declared_type, got $actual";
3697 11 die Zuzu::Error->new_runtime(
3698 message => $message,
3699 file => $file,
3700 line => $line,
3701 );
3702 }
3703  
3704 44948 ▶sub _value_matches_declared_type {
Subroutine _value_matches_declared_type: called CC=21 SCAR=58.8
3705 44948 my ( $self, $declared_type, $value ) = @_;
3706  
3707 44948 ▶ return $TRUE if $declared_type eq 'Any';
Branch: 1 branch
BranchTrueFalseTotal
if $declared_type eq "Any" 0 44948 44948
3708 44948 ▶ if ( exists $self->{_builtin_classes}{$declared_type} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"_builtin_classes"}{$declared_type}) 44948 0 44948
3709 44948 return $self->_value_matches_class( $value, $self->{_builtin_classes}{$declared_type} );
3710 }
3711  
3712 0 my $ref = $self->_env->find_ref($declared_type);
3713 0 ▶ return $FALSE if ! $ref;
Branch: 1 branch
BranchTrueFalseTotal
unless $ref 0 0 0
3714 0 my $target = $$ref;
3715  
3716 0 ▶ if ( blessed($target) and $target->isa('Zuzu::Value::Class') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($target) and $target->isa("Zuzu::Value::Class")) 0 0 0
Condition0%0/3
builtin::blessed($target) and $target->isa("Zuzu::Value::Class")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($target) and $target->isa("Zuzu::Value::Class")
builtin::blessed($target) $target->isa("Zuzu::Value::Class")
Truth table0%0/3
A and B
A= builtin::blessed($target)B= $target->isa("Zuzu::Value::Class")
ABresult
0X0
100
111
3717 0 ▶ return $FALSE if ! blessed($value) or ! $value->isa('Zuzu::Value::Object');
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($value) and $value->isa("Zuzu::Value::Object") 0 0 0
Condition0%0/3
builtin::blessed($value) and $value->isa("Zuzu::Value::Object")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($value) and $value->isa("Zuzu::Value::Object")
builtin::blessed($value) $value->isa("Zuzu::Value::Object")
Truth table0%0/3
A and B
A= builtin::blessed($value)B= $value->isa("Zuzu::Value::Object")
ABresult
0X0
100
111
3718 0 my $klass = $value->class;
3719 0 ▶ while ($klass) {
Branch: 1 branch
BranchTrueFalseTotal
if ($klass) 0 0 0
3720 0 ▶ return $TRUE if $klass == $target;
Branch: 1 branch
BranchTrueFalseTotal
if $klass == $target 0 0 0
3721 0 $klass = $klass->parent;
3722 }
3723 0 return $FALSE;
3724 }
3725  
3726 0 ▶ if ( blessed($target) and $target->isa('Zuzu::Value::Trait') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($target) and $target->isa("Zuzu::Value::Trait")) 0 0 0
Condition0%0/3
builtin::blessed($target) and $target->isa("Zuzu::Value::Trait")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($target) and $target->isa("Zuzu::Value::Trait")
builtin::blessed($target) $target->isa("Zuzu::Value::Trait")
Truth table0%0/3
A and B
A= builtin::blessed($target)B= $target->isa("Zuzu::Value::Trait")
ABresult
0X0
100
111
3727 0 ▶ return $FALSE if ! blessed($value) or ! $value->isa('Zuzu::Value::Object');
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($value) and $value->isa("Zuzu::Value::Object") 0 0 0
Condition0%0/3
builtin::blessed($value) and $value->isa("Zuzu::Value::Object")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($value) and $value->isa("Zuzu::Value::Object")
builtin::blessed($value) $value->isa("Zuzu::Value::Object")
Truth table0%0/3
A and B
A= builtin::blessed($value)B= $value->isa("Zuzu::Value::Object")
ABresult
0X0
100
111
3728 0 my %seen;
3729 0 my @queue = ($value->class);
3730 0 ▶ while (@queue) {
Branch: 1 branch
BranchTrueFalseTotal
if (@queue) 0 0 0
3731 0 my $klass = shift @queue;
3732 0 ▶ next if ! defined $klass;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $klass 0 0 0
3733 0 ▶ next if $seen{$klass}++;
Branch: 1 branch
BranchTrueFalseTotal
if $seen{$klass}++ 0 0 0
3734 0 ▶ for my $trait ( @{ $klass->traits // [] } ) {
Condition0%0/2
$klass->traits // []
l!l
00
MC/DC0%0/1
$klass->traits // []
$klass->traits
Truth table0%0/2
A
A= $klass->traits
Aresult
11
00
3735 0 ▶ return $TRUE if $trait == $target;
Branch: 1 branch
BranchTrueFalseTotal
if $trait == $target 0 0 0
3736 }
3737 0 ▶ push @queue, $klass->parent if defined $klass->parent;
Branch: 1 branch
BranchTrueFalseTotal
if defined $klass->parent 0 0 0
3738 }
3739 0 return $FALSE;
3740 }
3741  
3742 0 return $FALSE;
3743 }
3744  
3745 1 ▶sub _zuzu_ceil {
Subroutine _zuzu_ceil: called CC=3 SCAR=11.4
3746 1 my ( $n ) = @_;
3747 1 my $i = int($n);
3748 1 ▶ return $i if $n == $i;
Branch: 1 branch
BranchTrueFalseTotal
if $n == $i 0 1 1
3749 1 ▶ return $n > 0 ? $i + 1 : $i;
Branch: 1 branch
BranchTrueFalseTotal
$n > 0 ? : 1 0 1
3750 }
3751  
3752 3 ▶sub _zuzu_round {
Subroutine _zuzu_round: called CC=2 SCAR=7.2
3753 3 my ( $n ) = @_;
3754 3 ▶ return int($n + ( $n >= 0 ? 0.5 : -0.5 ) );
Branch: 1 branch
BranchTrueFalseTotal
$n >= 0 ? : 3 0 3
3755 }
3756  
3757 22495 ▶sub eval_incdec {
Subroutine eval_incdec: called CC=25 SCAR=33.4
Pod undocumented
3758 22495 my ($self, $node) = @_;
3759  
3760 22495 my $target = $self->_resolve_lvalue_target($node->target);
3761 my ($ref, $name, $target_env, $file, $line)
3762 22495 = @{$target}{qw(ref name env file line)};
3763 my $const_here = defined $target_env
3764 22495 ▶ ? $target_env->{const}{$name}
Branch: 1 branch
BranchTrueFalseTotal
defined $target_env ? : 22490 5 22495
3765 : $self->_env->is_const_here($name);
3766 22495 ▶ if (!defined $const_here and !defined $target_env) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $const_here or defined $target_env) 5 22490 22495
Condition66%2/3
defined $const_here or defined $target_env
l!l&&r!l&&!r
2249005
MC/DC50%1/2
defined $const_here or defined $target_env
defined $const_here defined $target_env
Truth table66%2/3
A or B
A= defined $const_hereB= defined $target_env
ABresult
1X1
011
000
3767 5 my $env = $self->_env;
3768 5 ▶ while ($env) {
Branch: 1 branch
BranchTrueFalseTotal
if ($env) 5 5 10
3769 69 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
3770 0 ▶ if (exists $env->{slots}{$name}) { $const_here = $env->{const}{$name}; last; }
Branch: 1 branch
BranchTrueFalseTotal
if (exists $env->{"slots"}{$name}) 0 5 5
3771 5 $env = $env->{parent};
3772 }
3773 }
3774 22495 ▶ die Zuzu::Error->new_runtime(message => "Cannot assign to const '$name'", file => $file, line => $line) if $const_here;
Branch: 1 branch
BranchTrueFalseTotal
if $const_here 0 22495 22495
3775  
3776 22495 ▶ if ( $target->{kind} && $target->{kind} eq 'path_maybe_ref' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target->{"kind"} and $target->{"kind"} eq "path_maybe_ref") 2 22493 22495
Condition66%2/3
$target->{"kind"} and $target->{"kind"} eq "path_maybe_ref"
!ll&&!rl&&r
0224932
MC/DC50%1/2
$target->{"kind"} and $target->{"kind"} eq "path_maybe_ref"
$target->{"kind"} $target->{"kind"} eq "path_maybe_ref"
Truth table66%2/3
A and B
A= $target->{"kind"}B= $target->{"kind"} eq "path_maybe_ref"
ABresult
0X0
100
111
3777 2 ▶ return $FALSE if !$target->{matched};
Branch: 1 branch
BranchTrueFalseTotal
unless $target->{"matched"} 1 1 2
3778 my $old = $self->_to_Number(
3779 1 $self->_call_ref_closure_get( $target->{ref_fn}, $file, $line )
3780 );
3781 1 ▶ my $new = ($node->op eq '++') ? ($old + 1) : ($old - 1);
Branch: 1 branch
BranchTrueFalseTotal
$node->op eq '++' ? : 1 0 1
3782 1 $self->_call_ref_closure_set( $target->{ref_fn}, $new, $file, $line );
3783 1 return $TRUE;
3784 }
3785  
3786 22493 ▶ if ( $target->{kind} && $target->{kind} eq 'path_single_ref' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target->{"kind"} and $target->{"kind"} eq "path_single_ref") 1 22492 22493
Condition66%2/3
$target->{"kind"} and $target->{"kind"} eq "path_single_ref"
!ll&&!rl&&r
0224921
MC/DC50%1/2
$target->{"kind"} and $target->{"kind"} eq "path_single_ref"
$target->{"kind"} $target->{"kind"} eq "path_single_ref"
Truth table66%2/3
A and B
A= $target->{"kind"}B= $target->{"kind"} eq "path_single_ref"
ABresult
0X0
100
111
3787 my $old = $self->_to_Number(
3788 1 $self->_call_ref_closure_get( $target->{ref_fn}, $file, $line )
3789 );
3790 1 ▶ my $new = ($node->op eq '++') ? ($old + 1) : ($old - 1);
Branch: 1 branch
BranchTrueFalseTotal
$node->op eq '++' ? : 1 0 1
3791 1 $self->_call_ref_closure_set( $target->{ref_fn}, $new, $file, $line );
3792 1 ▶ return $node->postfix ? $old : $new;
Branch: 1 branch
BranchTrueFalseTotal
$node->postfix ? : 0 1 1
3793 }
3794  
3795 22492 ▶ if ( $target->{kind} && $target->{kind} eq 'path_multi_ref' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target->{"kind"} and $target->{"kind"} eq "path_multi_ref") 2 22490 22492
Condition66%2/3
$target->{"kind"} and $target->{"kind"} eq "path_multi_ref"
!ll&&!rl&&r
0224902
MC/DC50%1/2
$target->{"kind"} and $target->{"kind"} eq "path_multi_ref"
$target->{"kind"} $target->{"kind"} eq "path_multi_ref"
Truth table66%2/3
A and B
A= $target->{"kind"}B= $target->{"kind"} eq "path_multi_ref"
ABresult
0X0
100
111
3796 2 my @old;
3797 my @new;
3798 2 for my $ref_fn ( @{ $target->{refs}->items } ) {
3799 4 my $old = $self->_to_Number(
3800 $self->_call_ref_closure_get( $ref_fn, $file, $line )
3801 );
3802 4 ▶ my $new = ($node->op eq '++') ? ($old + 1) : ($old - 1);
Branch: 1 branch
BranchTrueFalseTotal
$node->op eq '++' ? : 4 0 4
3803 4 $self->_call_ref_closure_set( $ref_fn, $new, $file, $line );
3804 4 push @old, $old;
3805 4 push @new, $new;
3806 }
3807 2 ▶ return Zuzu::Value::Array->new(
Branch: 1 branch
BranchTrueFalseTotal
$node->postfix ? : 2 0 2
3808 items => $node->postfix ? \@old : \@new,
3809 );
3810 }
3811  
3812 22490 my $old = $self->_to_Number($$ref);
3813 22490 ▶ my $new = ($node->op eq '++') ? ($old + 1) : ($old - 1);
Branch: 1 branch
BranchTrueFalseTotal
$node->op eq '++' ? : 22487 3 22490
3814 my $declared_type = defined $name
3815 ? (
3816 defined $target_env
3817 22490 ▶ ? ( $target_env->{types}{$name} // 'Any' )
Branch: 2 branches
BranchTrueFalseTotal
defined $name ? : 22490 0 22490
defined $target_env ? : 22490 0 22490
Condition50%1/2
$target_env->{"types"}{$name} // "Any"
l!l
224900
MC/DC0%0/1
$target_env->{"types"}{$name} // "Any"
$target_env->{"types"}{$name}
Truth table50%1/2
A
A= $target_env->{"types"}{$name}
Aresult
11
00
3818 : $self->_env->declared_type_for($name)
3819 )
3820 : 'Any';
3821 22490 $self->_assert_declared_type( $declared_type, $new, $file, $line, $name );
3822 22490 $$ref = $new;
3823  
3824 22490 ▶ return $node->postfix ? $old : $new;
Branch: 1 branch
BranchTrueFalseTotal
$node->postfix ? : 22396 94 22490
3825 }
3826  
3827 850 ▶sub eval_ternary {
Subroutine eval_ternary: called CC=4 SCAR=13.9
Pod undocumented
3828 850 my ($self, $node) = @_;
3829  
3830 850 my $cond_value = $node->cond->evaluate($self);
3831 850 ▶ if (!defined $node->if_true) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $node->if_true) 247 603 850
3832 247 ▶ return defined($cond_value)
Branch: 1 branch
BranchTrueFalseTotal
defined $cond_value ? : 247 0 247
3833 ? $cond_value
3834 : $node->if_false->evaluate($self);
3835 }
3836  
3837 603 ▶ if ( $self->_to_Boolean($cond_value) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_to_Boolean($cond_value)) 390 213 603
3838 390 return $node->if_true->evaluate($self);
3839 }
3840  
3841 213 return $node->if_false->evaluate($self);
3842 }
3843  
3844 112988 ▶sub eval_binary {
Subroutine eval_binary: called CC=69 SCAR=69.8
Pod documented
3845 112988 my ($self, $node) = @_;
3846  
3847 112988 my $op = $node->op;
3848  
3849 # boolean keywords come as KW tokens in parser; treat them here too
3850 112988 ▶ if ($op eq 'and' || $op eq '⋀') {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "and" or $op eq "\x{22c0}") 2293 110695 112988
Condition66%2/3
$op eq "and" or $op eq "\x{22c0}"
l!l&&r!l&&!r
22930110695
MC/DC50%1/2
$op eq "and" or $op eq "\x{22c0}"
$op eq "and" $op eq "\x{22c0}"
Truth table66%2/3
A or B
A= $op eq "and"B= $op eq "\x{22c0}"
ABresult
1X1
011
000
3851 2293 my $l = $node->left->evaluate($self);
3852  
3853 2293 ▶ return $self->_to_Boolean($l)
Branch: 1 branch
BranchTrueFalseTotal
$self->_to_Boolean($l) ? : 1131 1162 2293
3854 ? _boolify( $self->_to_Boolean( $node->right->evaluate($self) ) )
3855 : $FALSE;
3856 }
3857 110695 ▶ if ($op eq 'and?' || $op eq '⋀?') {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "and?" or $op eq "\x{22c0}?") 0 110695 110695
Condition33%1/3
$op eq "and?" or $op eq "\x{22c0}?"
l!l&&r!l&&!r
00110695
MC/DC0%0/2
$op eq "and?" or $op eq "\x{22c0}?"
$op eq "and?" $op eq "\x{22c0}?"
Truth table33%1/3
A or B
A= $op eq "and?"B= $op eq "\x{22c0}?"
ABresult
1X1
011
000
3858 0 my $l = $node->left->evaluate($self);
3859  
3860 0 ▶ return $self->_to_Boolean($l) ? $node->right->evaluate($self) : $l;
Branch: 1 branch
BranchTrueFalseTotal
$self->_to_Boolean($l) ? : 0 0 0
3861 }
3862 110695 ▶ if ($op eq 'nand' || $op eq '⊼') {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "nand" or $op eq "\x{22bc}") 0 110695 110695
Condition33%1/3
$op eq "nand" or $op eq "\x{22bc}"
l!l&&r!l&&!r
00110695
MC/DC0%0/2
$op eq "nand" or $op eq "\x{22bc}"
$op eq "nand" $op eq "\x{22bc}"
Truth table33%1/3
A or B
A= $op eq "nand"B= $op eq "\x{22bc}"
ABresult
1X1
011
000
3863 0 my $l = $node->left->evaluate($self);
3864  
3865 0 ▶ return $TRUE if !$self->_to_Boolean($l);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_to_Boolean($l) 0 0 0
3866  
3867 0 ▶ return $self->_to_Boolean( $node->right->evaluate($self) ) ? $FALSE : $TRUE;
Branch: 1 branch
BranchTrueFalseTotal
$self->_to_Boolean($node->right->evaluate($self)) ? : 0 0 0
3868 }
3869 110695 ▶ if ($op eq 'nand?' || $op eq '⊼?') {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "nand?" or $op eq "\x{22bc}?") 0 110695 110695
Condition33%1/3
$op eq "nand?" or $op eq "\x{22bc}?"
l!l&&r!l&&!r
00110695
MC/DC0%0/2
$op eq "nand?" or $op eq "\x{22bc}?"
$op eq "nand?" $op eq "\x{22bc}?"
Truth table33%1/3
A or B
A= $op eq "nand?"B= $op eq "\x{22bc}?"
ABresult
1X1
011
000
3870 0 my $l = $node->left->evaluate($self);
3871 0 my $r = $node->right->evaluate($self);
3872  
3873 0 ▶ return $self->_to_Boolean($l)
Branch: 3 branches
BranchTrueFalseTotal
$self->_to_Boolean($l) ? : 0 0 0
$self->_to_Boolean($r) ? : 0 0 0
$self->_to_Boolean($r) ? : 0 0 0
3874 ? ( $self->_to_Boolean($r) ? $FALSE : $TRUE )
3875 : ( $self->_to_Boolean($r) ? $r : $TRUE );
3876 }
3877 110695 ▶ if ($op eq 'xor' || $op eq '⊻') {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "xor" or $op eq "\x{22bb}") 76 110619 110695
Condition100%3/3
$op eq "xor" or $op eq "\x{22bb}"
l!l&&r!l&&!r
742110619
MC/DC100%2/2
$op eq "xor" or $op eq "\x{22bb}"
$op eq "xor" $op eq "\x{22bb}"
Truth table100%3/3
A or B
A= $op eq "xor"B= $op eq "\x{22bb}"
ABresult
1X1
011
000
3878 76 ▶ my $l = $self->_to_Boolean( $node->left->evaluate($self) ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->_to_Boolean($node->left->evaluate($self)) ? : 2 74 76
3879 76 ▶ my $r = $self->_to_Boolean( $node->right->evaluate($self) ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->_to_Boolean($node->right->evaluate($self)) ? : 2 74 76
3880  
3881 76 ▶ return ($l xor $r) ? $TRUE : $FALSE;
Branch: 1 branch
BranchTrueFalseTotal
$l ^^ $r ? : 0 76 76
Condition50%2/4
$l xor $r
l&&rl&&!r!l&&r!l&&!r
20074
MC/DC0%0/2
$l xor $r
$l $r
Truth table50%2/4
A xor B
A= $lB= $r
ABresult
110
101
011
000
3882 }
3883 110619 ▶ if ($op eq 'xor?' || $op eq '⊻?') {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "xor?" or $op eq "\x{22bb}?") 0 110619 110619
Condition33%1/3
$op eq "xor?" or $op eq "\x{22bb}?"
l!l&&r!l&&!r
00110619
MC/DC0%0/2
$op eq "xor?" or $op eq "\x{22bb}?"
$op eq "xor?" $op eq "\x{22bb}?"
Truth table33%1/3
A or B
A= $op eq "xor?"B= $op eq "\x{22bb}?"
ABresult
1X1
011
000
3884 0 my $l = $node->left->evaluate($self);
3885 0 my $r = $node->right->evaluate($self);
3886  
3887 0 ▶ return $self->_to_Boolean($l)
Branch: 3 branches
BranchTrueFalseTotal
$self->_to_Boolean($l) ? : 0 0 0
$self->_to_Boolean($r) ? : 0 0 0
$self->_to_Boolean($r) ? : 0 0 0
3888 ? ( $self->_to_Boolean($r) ? $FALSE : $l )
3889 : ( $self->_to_Boolean($r) ? $r : $FALSE );
3890 }
3891 110619 ▶ if ($op eq 'xnor' || $op eq '↔') {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "xnor" or $op eq "\x{2194}") 0 110619 110619
Condition33%1/3
$op eq "xnor" or $op eq "\x{2194}"
l!l&&r!l&&!r
00110619
MC/DC0%0/2
$op eq "xnor" or $op eq "\x{2194}"
$op eq "xnor" $op eq "\x{2194}"
Truth table33%1/3
A or B
A= $op eq "xnor"B= $op eq "\x{2194}"
ABresult
1X1
011
000
3892 0 ▶ my $l = $self->_to_Boolean( $node->left->evaluate($self) ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->_to_Boolean($node->left->evaluate($self)) ? : 0 0 0
3893 0 ▶ my $r = $self->_to_Boolean( $node->right->evaluate($self) ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->_to_Boolean($node->right->evaluate($self)) ? : 0 0 0
3894  
3895 0 ▶ return $l == $r ? $TRUE : $FALSE;
Branch: 1 branch
BranchTrueFalseTotal
$l == $r ? : 0 0 0
3896 }
3897 110619 ▶ if ($op eq 'xnor?' || $op eq '↔?') {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "xnor?" or $op eq "\x{2194}?") 0 110619 110619
Condition33%1/3
$op eq "xnor?" or $op eq "\x{2194}?"
l!l&&r!l&&!r
00110619
MC/DC0%0/2
$op eq "xnor?" or $op eq "\x{2194}?"
$op eq "xnor?" $op eq "\x{2194}?"
Truth table33%1/3
A or B
A= $op eq "xnor?"B= $op eq "\x{2194}?"
ABresult
1X1
011
000
3898 0 my $l = $node->left->evaluate($self);
3899 0 my $r = $node->right->evaluate($self);
3900  
3901 0 ▶ return $self->_to_Boolean($l)
Branch: 2 branches
BranchTrueFalseTotal
$self->_to_Boolean($l) ? : 0 0 0
$self->_to_Boolean($r) ? : 0 0 0
3902 ? $r
3903 : ( $self->_to_Boolean($r) ? $l : $TRUE );
3904 }
3905 110619 ▶ if ($op eq 'nor' || $op eq '⊽') {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "nor" or $op eq "\x{22bd}") 0 110619 110619
Condition33%1/3
$op eq "nor" or $op eq "\x{22bd}"
l!l&&r!l&&!r
00110619
MC/DC0%0/2
$op eq "nor" or $op eq "\x{22bd}"
$op eq "nor" $op eq "\x{22bd}"
Truth table33%1/3
A or B
A= $op eq "nor"B= $op eq "\x{22bd}"
ABresult
1X1
011
000
3906 0 my $l = $node->left->evaluate($self);
3907  
3908 0 ▶ return $FALSE if $self->_to_Boolean($l);
Branch: 1 branch
BranchTrueFalseTotal
if $self->_to_Boolean($l) 0 0 0
3909  
3910 0 ▶ return $self->_to_Boolean( $node->right->evaluate($self) ) ? $FALSE : $TRUE;
Branch: 1 branch
BranchTrueFalseTotal
$self->_to_Boolean($node->right->evaluate($self)) ? : 0 0 0
3911 }
3912 110619 ▶ if ($op eq 'nor?' || $op eq '⊽?') {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "nor?" or $op eq "\x{22bd}?") 0 110619 110619
Condition33%1/3
$op eq "nor?" or $op eq "\x{22bd}?"
l!l&&r!l&&!r
00110619
MC/DC0%0/2
$op eq "nor?" or $op eq "\x{22bd}?"
$op eq "nor?" $op eq "\x{22bd}?"
Truth table33%1/3
A or B
A= $op eq "nor?"B= $op eq "\x{22bd}?"
ABresult
1X1
011
000
3913 0 my $l = $node->left->evaluate($self);
3914 0 my $r = $node->right->evaluate($self);
3915  
3916 0 ▶ return $self->_to_Boolean($l)
Branch: 3 branches
BranchTrueFalseTotal
$self->_to_Boolean($l) ? : 0 0 0
$self->_to_Boolean($r) ? : 0 0 0
$self->_to_Boolean($r) ? : 0 0 0
3917 ? ( $self->_to_Boolean($r) ? $FALSE : $r )
3918 : ( $self->_to_Boolean($r) ? $l : $TRUE );
3919 }
3920 110619 ▶ if ($op eq 'onlyif' || $op eq '⊨') {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "onlyif" or $op eq "\x{22a8}") 0 110619 110619
Condition33%1/3
$op eq "onlyif" or $op eq "\x{22a8}"
l!l&&r!l&&!r
00110619
MC/DC0%0/2
$op eq "onlyif" or $op eq "\x{22a8}"
$op eq "onlyif" $op eq "\x{22a8}"
Truth table33%1/3
A or B
A= $op eq "onlyif"B= $op eq "\x{22a8}"
ABresult
1X1
011
000
3921 0 my $l = $node->left->evaluate($self);
3922  
3923 0 ▶ return $TRUE if !$self->_to_Boolean($l);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_to_Boolean($l) 0 0 0
3924  
3925 0 return _boolify( $self->_to_Boolean( $node->right->evaluate($self) ) );
3926 }
3927 110619 ▶ if ($op eq 'onlyif?' || $op eq '⊨?') {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "onlyif?" or $op eq "\x{22a8}?") 0 110619 110619
Condition33%1/3
$op eq "onlyif?" or $op eq "\x{22a8}?"
l!l&&r!l&&!r
00110619
MC/DC0%0/2
$op eq "onlyif?" or $op eq "\x{22a8}?"
$op eq "onlyif?" $op eq "\x{22a8}?"
Truth table33%1/3
A or B
A= $op eq "onlyif?"B= $op eq "\x{22a8}?"
ABresult
1X1
011
000
3928 0 my $l = $node->left->evaluate($self);
3929  
3930 0 ▶ return $self->_to_Boolean($l) ? $node->right->evaluate($self) : $TRUE;
Branch: 1 branch
BranchTrueFalseTotal
$self->_to_Boolean($l) ? : 0 0 0
3931 }
3932 110619 ▶ if ($op eq 'butnot' || $op eq '⊭') {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "butnot" or $op eq "\x{22ad}") 0 110619 110619
Condition33%1/3
$op eq "butnot" or $op eq "\x{22ad}"
l!l&&r!l&&!r
00110619
MC/DC0%0/2
$op eq "butnot" or $op eq "\x{22ad}"
$op eq "butnot" $op eq "\x{22ad}"
Truth table33%1/3
A or B
A= $op eq "butnot"B= $op eq "\x{22ad}"
ABresult
1X1
011
000
3933 0 my $l = $node->left->evaluate($self);
3934  
3935 0 ▶ return $FALSE if !$self->_to_Boolean($l);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_to_Boolean($l) 0 0 0
3936  
3937 0 ▶ return $self->_to_Boolean( $node->right->evaluate($self) ) ? $FALSE : $TRUE;
Branch: 1 branch
BranchTrueFalseTotal
$self->_to_Boolean($node->right->evaluate($self)) ? : 0 0 0
3938 }
3939 110619 ▶ if ($op eq 'butnot?' || $op eq '⊭?') {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "butnot?" or $op eq "\x{22ad}?") 0 110619 110619
Condition33%1/3
$op eq "butnot?" or $op eq "\x{22ad}?"
l!l&&r!l&&!r
00110619
MC/DC0%0/2
$op eq "butnot?" or $op eq "\x{22ad}?"
$op eq "butnot?" $op eq "\x{22ad}?"
Truth table33%1/3
A or B
A= $op eq "butnot?"B= $op eq "\x{22ad}?"
ABresult
1X1
011
000
3940 0 my $l = $node->left->evaluate($self);
3941  
3942 0 ▶ return $l if !$self->_to_Boolean($l);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_to_Boolean($l) 0 0 0
3943  
3944 0 ▶ return $self->_to_Boolean( $node->right->evaluate($self) ) ? $FALSE : $l;
Branch: 1 branch
BranchTrueFalseTotal
$self->_to_Boolean($node->right->evaluate($self)) ? : 0 0 0
3945 }
3946 110619 ▶ if ($op eq 'or' || $op eq '⋁') {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "or" or $op eq "\x{22c1}") 389 110230 110619
Condition66%2/3
$op eq "or" or $op eq "\x{22c1}"
l!l&&r!l&&!r
3890110230
MC/DC50%1/2
$op eq "or" or $op eq "\x{22c1}"
$op eq "or" $op eq "\x{22c1}"
Truth table66%2/3
A or B
A= $op eq "or"B= $op eq "\x{22c1}"
ABresult
1X1
011
000
3947 389 my $l = $node->left->evaluate($self);
3948  
3949 389 ▶ return $self->_to_Boolean($l) ? $TRUE : _boolify( $self->_to_Boolean( $node->right->evaluate($self) ) );
Branch: 1 branch
BranchTrueFalseTotal
$self->_to_Boolean($l) ? : 57 332 389
3950 }
3951 110230 ▶ if ($op eq 'or?' || $op eq '⋁?') {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "or?" or $op eq "\x{22c1}?") 0 110230 110230
Condition33%1/3
$op eq "or?" or $op eq "\x{22c1}?"
l!l&&r!l&&!r
00110230
MC/DC0%0/2
$op eq "or?" or $op eq "\x{22c1}?"
$op eq "or?" $op eq "\x{22c1}?"
Truth table33%1/3
A or B
A= $op eq "or?"B= $op eq "\x{22c1}?"
ABresult
1X1
011
000
3952 0 my $l = $node->left->evaluate($self);
3953  
3954 0 ▶ return $self->_to_Boolean($l) ? $l : $node->right->evaluate($self);
Branch: 1 branch
BranchTrueFalseTotal
$self->_to_Boolean($l) ? : 0 0 0
3955 }
3956 110230 ▶ if ( $op eq '▷' or $op eq '|>' or $op eq '◁' or $op eq '<|' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "\x{25b7}" or $op eq "|>" or $op eq "\x{25c1}" or $op eq "<|") 9 110221 110230
Condition88%8/9
$op eq "\x{25b7}" or $op eq "|>" or $op eq "\x{25c1}" or $op eq "<|"
l!l&&r!l&&!r
81110221
$op eq "\x{25b7}" or $op eq "|>" or $op eq "\x{25c1}"
l!l&&r!l&&!r
80110222
$op eq "\x{25b7}" or $op eq "|>"
l!l&&r!l&&!r
44110222
MC/DC75%3/4
$op eq "\x{25b7}" or $op eq "|>" or $op eq "\x{25c1}" or $op eq "<|"
$op eq "\x{25b7}" $op eq "|>" $op eq "\x{25c1}" $op eq "<|"
Truth table80%4/5
A or B or C or D
A= $op eq "\x{25b7}"B= $op eq "|>"C= $op eq "\x{25c1}"D= $op eq "<|"
ABCDresult
1XXX1
01XX1
001X1
00011
00000
3957 9 return $self->_eval_chain_operator($node);
3958 }
3959  
3960 110221 my $l = $node->left->evaluate($self);
3961 110221 my $r = $node->right->evaluate($self);
3962  
3963 110191 return $self->_eval_binary_op_values( $op, $l, $r, $node->file, $node->line );
3964 }
3965  
3966 9 ▶sub _eval_chain_operator {
Subroutine _eval_chain_operator: called CC=4 SCAR=13.9
3967 9 my ( $self, $node ) = @_;
3968  
3969 9 my $op = $node->op;
3970 9 my ( $value, $expr );
3971 9 ▶ if ( $op eq '▷' or $op eq '|>' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "\x{25b7}" or $op eq '|>') { } 8 1 9
Condition100%3/3
$op eq "\x{25b7}" or $op eq "|>"
l!l&&r!l&&!r
441
MC/DC100%2/2
$op eq "\x{25b7}" or $op eq "|>"
$op eq "\x{25b7}" $op eq "|>"
Truth table100%3/3
A or B
A= $op eq "\x{25b7}"B= $op eq "|>"
ABresult
1X1
011
000
3972 8 $value = $node->left->evaluate($self);
3973 8 $expr = $node->right;
3974 }
3975 else {
3976 1 $value = $node->right->evaluate($self);
3977 1 $expr = $node->left;
3978 }
3979  
3980 9 my $env = Zuzu::Env->_new_fast( $self->{_stack}[-1] );
3981 9 $self->_push_env($env);
3982 9 $env->declare( '^^', $value, 1, 'Any' );
3983 9 my $result;
3984 9 my $ok = eval {
3985 9 $result = $expr->evaluate($self);
3986 9 1;
3987 };
3988 9 my $err = $@;
3989 9 $self->_pop_env;
3990 9 ▶ die $err if !$ok;
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 0 9 9
3991  
3992 9 return $result;
3993 }
3994  
3995 1 ▶sub _switch_matches {
Subroutine _switch_matches: called CC=2 SCAR=7.1
3996 1 my ( $self, $op, $left, $right, $file, $line ) = @_;
3997  
3998 1 my $result = $self->_eval_binary_op_values( $op, $left, $right, $file, $line );
3999  
4000 1 ▶ return $self->_to_Boolean($result) ? $TRUE : $FALSE;
Branch: 1 branch
BranchTrueFalseTotal
$self->_to_Boolean($result) ? : 1 0 1
4001 }
4002  
4003 110192 ▶sub _eval_binary_op_values {
Subroutine _eval_binary_op_values: called CC=147 SCAR=69.6
4004 110192 my ( $self, $op, $l, $r, $file, $line ) = @_;
4005  
4006 110192 ▶ if ( $op eq 'default' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "default") 11 110181 110192
4007 11 return $self->_default_collection_values( $l, $r, $file, $line );
4008 }
4009  
4010 110181 ▶ if ($op eq '+' ) { return $self->_to_Number($l) + $self->_to_Number($r); }
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "+") 38027 72154 110181
4011 72154 ▶ if ($op eq '-' ) { return $self->_to_Number($l) - $self->_to_Number($r); }
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "-") 294 71860 72154
4012 71860 ▶ if ($op eq '*' || $op eq '×') { return $self->_to_Number($l) * $self->_to_Number($r); }
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "*" or $op eq "\x{d7}") 50 71810 71860
Condition66%2/3
$op eq "*" or $op eq "\x{d7}"
l!l&&r!l&&!r
50071810
MC/DC50%1/2
$op eq "*" or $op eq "\x{d7}"
$op eq "*" $op eq "\x{d7}"
Truth table66%2/3
A or B
A= $op eq "*"B= $op eq "\x{d7}"
ABresult
1X1
011
000
4013 71810 ▶ if ($op eq '/' || $op eq '÷') { return $self->_to_Number($l) / $self->_to_Number($r); }
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "/" or $op eq "\x{f7}") 142 71668 71810
Condition66%2/3
$op eq "/" or $op eq "\x{f7}"
l!l&&r!l&&!r
142071668
MC/DC50%1/2
$op eq "/" or $op eq "\x{f7}"
$op eq "/" $op eq "\x{f7}"
Truth table66%2/3
A or B
A= $op eq "/"B= $op eq "\x{f7}"
ABresult
1X1
011
000
4014 71668 ▶ if ($op eq 'mod') { return POSIX::fmod( $self->_to_Number($l), $self->_to_Number($r) ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "mod") 19 71649 71668
4015 0 ▶ if ($op eq '**') { return $self->_to_Number($l) ** $self->_to_Number($r); }
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "**") 0 71649 71649
4016 71649 ▶ if ($op eq '&' || $op eq '|' || $op eq '^') {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "&" or $op eq "|" or $op eq "^") 226 71423 71649
Condition100%6/6
$op eq "&" or $op eq "|" or $op eq "^"
l!l&&r!l&&!r
1606671423
$op eq "&" or $op eq "|"
l!l&&r!l&&!r
156471489
MC/DC100%3/3
$op eq "&" or $op eq "|" or $op eq "^"
$op eq "&" $op eq "|" $op eq "^"
Truth table100%4/4
A or B or C
A= $op eq "&"B= $op eq "|"C= $op eq "^"
ABCresult
1XX1
01X1
0011
0000
4017 226 return $self->_bitwise_binary_op( $op, $l, $r, $file, $line );
4018 }
4019 71423 ▶ if ($op eq '<<' || $op eq '«' || $op eq '>>' || $op eq '»') {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "<<" or $op eq "\x{ab}" or $op eq ">>" or $op eq "\x{bb}") 0 71423 71423
Condition33%3/9
$op eq "<<" or $op eq "\x{ab}" or $op eq ">>" or $op eq "\x{bb}"
l!l&&r!l&&!r
0071423
$op eq "<<" or $op eq "\x{ab}" or $op eq ">>"
l!l&&r!l&&!r
0071423
$op eq "<<" or $op eq "\x{ab}"
l!l&&r!l&&!r
0071423
MC/DC0%0/4
$op eq "<<" or $op eq "\x{ab}" or $op eq ">>" or $op eq "\x{bb}"
$op eq "<<" $op eq "\x{ab}" $op eq ">>" $op eq "\x{bb}"
Truth table20%1/5
A or B or C or D
A= $op eq "<<"B= $op eq "\x{ab}"C= $op eq ">>"D= $op eq "\x{bb}"
ABCDresult
1XXX1
01XX1
001X1
00011
00000
4020 0 return $self->_shift_binary_op( $op, $l, $r, $file, $line );
4021 }
4022  
4023 71423 ▶ if ( $op eq '_' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "_") 615 70808 71423
4024 615 ▶ my $left_is_binary = ( blessed($l) and $l->isa('Zuzu::Value::BinaryString') ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($l) && $l->isa('Zuzu::Value::BinaryString') ? : 2 613 615
Condition100%3/3
builtin::blessed($l) and $l->isa("Zuzu::Value::BinaryString")
!ll&&!rl&&r
61122
MC/DC100%2/2
builtin::blessed($l) and $l->isa("Zuzu::Value::BinaryString")
builtin::blessed($l) $l->isa("Zuzu::Value::BinaryString")
Truth table100%3/3
A and B
A= builtin::blessed($l)B= $l->isa("Zuzu::Value::BinaryString")
ABresult
0X0
100
111
4025 615 ▶ my $right_is_binary = ( blessed($r) and $r->isa('Zuzu::Value::BinaryString') ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($r) && $r->isa('Zuzu::Value::BinaryString') ? : 2 613 615
Condition66%2/3
builtin::blessed($r) and $r->isa("Zuzu::Value::BinaryString")
!ll&&!rl&&r
61302
MC/DC50%1/2
builtin::blessed($r) and $r->isa("Zuzu::Value::BinaryString")
builtin::blessed($r) $r->isa("Zuzu::Value::BinaryString")
Truth table66%2/3
A and B
A= builtin::blessed($r)B= $r->isa("Zuzu::Value::BinaryString")
ABresult
0X0
100
111
4026  
4027 615 ▶ if ( $left_is_binary and $right_is_binary ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($left_is_binary and $right_is_binary) 0 615 615
Condition66%2/3
$left_is_binary and $right_is_binary
!ll&&!rl&&r
61320
MC/DC0%0/2
$left_is_binary and $right_is_binary
$left_is_binary $right_is_binary
Truth table66%2/3
A and B
A= $left_is_binaryB= $right_is_binary
ABresult
0X0
100
111
4028 0 ▶ return Zuzu::Value::BinaryString->new(
Condition0%0/4
$l->bytes // ""
l!l
00
$r->bytes // ""
l!l
00
MC/DC0%0/1
$l->bytes // ""
$l->bytes
MC/DC0%0/1
$r->bytes // ""
$r->bytes
Truth table0%0/2
A
A= $l->bytes
Aresult
11
00
Truth table0%0/2
A
A= $r->bytes
Aresult
11
00
4029 bytes => ( $l->bytes // '' ) . ( $r->bytes // '' ),
4030 );
4031 }
4032 615 ▶ if ( $left_is_binary or $right_is_binary ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($left_is_binary or $right_is_binary) 4 611 615
Condition100%3/3
$left_is_binary or $right_is_binary
l!l&&r!l&&!r
22611
MC/DC100%2/2
$left_is_binary or $right_is_binary
$left_is_binary $right_is_binary
Truth table100%3/3
A or B
A= $left_is_binaryB= $right_is_binary
ABresult
1X1
011
000
4033 4 ▶ my $binary = $left_is_binary ? $l : $r;
Branch: 1 branch
BranchTrueFalseTotal
$left_is_binary ? : 2 2 4
4034 4 ▶ if ( ! $binary->is_ascii ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($binary->is_ascii) 2 2 4
4035 2 die Zuzu::Error->new_runtime(
4036 message => "TypeException: Cannot implicitly concatenate non-ASCII BinaryString with String; use to_string(...)",
4037 file => $file,
4038 line => $line,
4039 );
4040 }
4041 2 ▶ my $text = $left_is_binary
Branch: 1 branch
BranchTrueFalseTotal
$left_is_binary ? : 1 1 2
4042 ? $self->_to_OperatorString( $r, $file, $line )
4043 : $self->_to_OperatorString( $l, $file, $line );
4044 2 ▶ my $ascii = $binary->bytes // '';
Condition50%1/2
$binary->bytes // ""
l!l
20
MC/DC0%0/1
$binary->bytes // ""
$binary->bytes
Truth table50%1/2
A
A= $binary->bytes
Aresult
11
00
4045  
4046 2 ▶ return $left_is_binary ? ( $ascii . $text ) : ( $text . $ascii );
Branch: 1 branch
BranchTrueFalseTotal
$left_is_binary ? : 1 1 2
4047 }
4048  
4049 611 return $self->_to_OperatorString( $l, $file, $line )
4050 . $self->_to_OperatorString( $r, $file, $line );
4051 }
4052  
4053 70808 ▶ if ($op eq '∣' || $op eq 'divides' || $op eq '∤') {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "\x{2223}" or $op eq "divides" or $op eq "\x{2224}") 0 70808 70808
Condition33%2/6
$op eq "\x{2223}" or $op eq "divides" or $op eq "\x{2224}"
l!l&&r!l&&!r
0070808
$op eq "\x{2223}" or $op eq "divides"
l!l&&r!l&&!r
0070808
MC/DC0%0/3
$op eq "\x{2223}" or $op eq "divides" or $op eq "\x{2224}"
$op eq "\x{2223}" $op eq "divides" $op eq "\x{2224}"
Truth table25%1/4
A or B or C
A= $op eq "\x{2223}"B= $op eq "divides"C= $op eq "\x{2224}"
ABCresult
1XX1
01X1
0011
0000
4054 # The left operand is the divisor: a ∣ b tests b mod a.
4055 0 my $remainder = POSIX::fmod( $self->_to_Number($r), $self->_to_Number($l) );
4056 0 ▶ return $remainder if $op eq '∤';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "\x{2224}" 0 0 0
4057 0 return _boolify( $remainder == 0 );
4058 }
4059  
4060 # numeric comparisons
4061 70808 ▶ if ($op eq '=') { return _boolify( $self->_to_Number($l) == $self->_to_Number($r) ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "=") 182 70626 70808
4062 0 ▶ if ($op eq '≠') { return _boolify( $self->_to_Number($l) != $self->_to_Number($r) ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "\x{2260}") 0 70626 70626
4063 70626 ▶ if ($op eq '<') { return _boolify( $self->_to_Number($l) < $self->_to_Number($r) ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "<") 29672 40954 70626
4064 40954 ▶ if ($op eq '<=' || $op eq '≤') { return _boolify( $self->_to_Number($l) <= $self->_to_Number($r) ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "<=" or $op eq "\x{2264}") 7267 33687 40954
Condition66%2/3
$op eq "<=" or $op eq "\x{2264}"
l!l&&r!l&&!r
7267033687
MC/DC50%1/2
$op eq "<=" or $op eq "\x{2264}"
$op eq "<=" $op eq "\x{2264}"
Truth table66%2/3
A or B
A= $op eq "<="B= $op eq "\x{2264}"
ABresult
1X1
011
000
4065 33687 ▶ if ($op eq '>') { return _boolify( $self->_to_Number($l) > $self->_to_Number($r) ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq ">") 370 33317 33687
4066 33317 ▶ if ($op eq '>=' || $op eq '≥') { return _boolify( $self->_to_Number($l) >= $self->_to_Number($r) ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq ">=" or $op eq "\x{2265}") 181 33136 33317
Condition66%2/3
$op eq ">=" or $op eq "\x{2265}"
l!l&&r!l&&!r
181033136
MC/DC50%1/2
$op eq ">=" or $op eq "\x{2265}"
$op eq ">=" $op eq "\x{2265}"
Truth table66%2/3
A or B
A= $op eq ">="B= $op eq "\x{2265}"
ABresult
1X1
011
000
4067 33136 ▶ if ($op eq '<=>' || $op eq '≶' || $op eq '≷') {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "<=>" or $op eq "\x{2276}" or $op eq "\x{2277}") 11788 21348 33136
Condition66%4/6
$op eq "<=>" or $op eq "\x{2276}" or $op eq "\x{2277}"
l!l&&r!l&&!r
11788021348
$op eq "<=>" or $op eq "\x{2276}"
l!l&&r!l&&!r
11788021348
MC/DC33%1/3
$op eq "<=>" or $op eq "\x{2276}" or $op eq "\x{2277}"
$op eq "<=>" $op eq "\x{2276}" $op eq "\x{2277}"
Truth table50%2/4
A or B or C
A= $op eq "<=>"B= $op eq "\x{2276}"C= $op eq "\x{2277}"
ABCresult
1XX1
01X1
0011
0000
4068 11788 my $ln = $self->_to_Number($l);
4069 11788 my $rn = $self->_to_Number($r);
4070  
4071 11788 return ($ln <=> $rn);
4072 }
4073  
4074 # type-aware equality skeleton: same ref type and same string/num
4075 21348 ▶ if ($op eq '==' || $op eq '≡') {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "==" or $op eq "\x{2261}") 14056 7292 21348
Condition100%3/3
$op eq "==" or $op eq "\x{2261}"
l!l&&r!l&&!r
37140197292
MC/DC100%2/2
$op eq "==" or $op eq "\x{2261}"
$op eq "==" $op eq "\x{2261}"
Truth table100%3/3
A or B
A= $op eq "=="B= $op eq "\x{2261}"
ABresult
1X1
011
000
4076 14056 ▶ return $self->_value_equal( $l, $r ) ? $TRUE : $FALSE;
Branch: 1 branch
BranchTrueFalseTotal
$self->_value_equal($l, $r) ? : 865 13191 14056
4077 }
4078 7292 ▶ if ($op eq '!=' || $op eq '≢') {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "!=" or $op eq "\x{2262}") 3881 3411 7292
Condition100%3/3
$op eq "!=" or $op eq "\x{2262}"
l!l&&r!l&&!r
1238693411
MC/DC100%2/2
$op eq "!=" or $op eq "\x{2262}"
$op eq "!=" $op eq "\x{2262}"
Truth table100%3/3
A or B
A= $op eq "!="B= $op eq "\x{2262}"
ABresult
1X1
011
000
4079 3881 ▶ return $self->_value_equal( $l, $r ) ? $FALSE : $TRUE;
Branch: 1 branch
BranchTrueFalseTotal
$self->_value_equal($l, $r) ? : 3022 859 3881
4080 }
4081  
4082 3411 ▶ if ( $op eq '~' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "~") 1132 2279 3411
4083 1132 my $target = $self->_to_OperatorString( $l, $file, $line );
4084 1132 my $regexp = $self->_coerce_regexp( $r, $file, $line );
4085 1132 ▶ if ( $self->_regexp_is_global($r) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_regexp_is_global($r)) 0 1132 1132
4086 0 my @all_matches;
4087 0 ▶ while ( $target =~ /$regexp/g ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target =~ /$regexp/g) 0 0 0
4088 0 push @all_matches, Zuzu::Value::Array->new( items => [ $self->_current_match_values($target) ] );
4089 }
4090 0 ▶ return $FALSE if !@all_matches;
Branch: 1 branch
BranchTrueFalseTotal
unless @all_matches 0 0 0
4091  
4092 0 return Zuzu::Value::Array->new( items => \@all_matches );
4093 }
4094 1132 my @matches = ( $target =~ $regexp );
4095 1132 ▶ if ( !@matches and $target !~ $regexp ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@matches or $target =~ /$regexp/) 1097 35 1132
Condition66%2/3
@matches or $target =~ /$regexp/
l!l&&r!l&&!r
3501097
MC/DC50%1/2
@matches or $target =~ /$regexp/
@matches $target =~ /$regexp/
Truth table66%2/3
A or B
A= @matchesB= $target =~ /$regexp/
ABresult
1X1
011
000
4096 1097 return $FALSE;
4097 }
4098  
4099 35 my $full = $&;
4100 35 unshift @matches, $full;
4101  
4102 35 return Zuzu::Value::Array->new( items => \@matches );
4103 }
4104 2279 ▶ if ( $op eq '@' or $op eq '@?' or $op eq '@@' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "\@" or $op eq "\@?" or $op eq "\@\@") 17 2262 2279
Condition100%6/6
$op eq "\@" or $op eq "\@?" or $op eq "\@\@"
l!l&&r!l&&!r
1162262
$op eq "\@" or $op eq "\@?"
l!l&&r!l&&!r
832268
MC/DC100%3/3
$op eq "\@" or $op eq "\@?" or $op eq "\@\@"
$op eq "\@" $op eq "\@?" $op eq "\@\@"
Truth table100%4/4
A or B or C
A= $op eq "\@"B= $op eq "\@?"C= $op eq "\@\@"
ABCresult
1XX1
01X1
0011
0000
4105 17 return $self->_eval_path_operator( $op, $l, $r, $file, $line );
4106 }
4107  
4108 2262 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge" or $op eq "lt" or $op eq "le" or $op eq "cmp" or $op eq "eqi" or $op eq "nei" or $op eq "gti" or $op eq "gei" or $op eq "lti" or $op eq "lei" or $op eq "cmpi") 524 1738 2262
Condition69%27/39
$op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge" or $op eq "lt" or $op eq "le" or $op eq "cmp" or $op eq "eqi" or $op eq "nei" or $op eq "gti" or $op eq "gei" or $op eq "lti" or $op eq "lei" or $op eq "cmpi"
l!l&&r!l&&!r
52401738
$op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge" or $op eq "lt" or $op eq "le" or $op eq "cmp" or $op eq "eqi" or $op eq "nei" or $op eq "gti" or $op eq "gei" or $op eq "lti" or $op eq "lei"
l!l&&r!l&&!r
52401738
$op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge" or $op eq "lt" or $op eq "le" or $op eq "cmp" or $op eq "eqi" or $op eq "nei" or $op eq "gti" or $op eq "gei" or $op eq "lti"
l!l&&r!l&&!r
52401738
$op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge" or $op eq "lt" or $op eq "le" or $op eq "cmp" or $op eq "eqi" or $op eq "nei" or $op eq "gti" or $op eq "gei"
l!l&&r!l&&!r
52401738
$op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge" or $op eq "lt" or $op eq "le" or $op eq "cmp" or $op eq "eqi" or $op eq "nei" or $op eq "gti"
l!l&&r!l&&!r
52401738
$op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge" or $op eq "lt" or $op eq "le" or $op eq "cmp" or $op eq "eqi" or $op eq "nei"
l!l&&r!l&&!r
52401738
$op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge" or $op eq "lt" or $op eq "le" or $op eq "cmp" or $op eq "eqi"
l!l&&r!l&&!r
52401738
$op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge" or $op eq "lt" or $op eq "le" or $op eq "cmp"
l!l&&r!l&&!r
52401738
$op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge" or $op eq "lt" or $op eq "le"
l!l&&r!l&&!r
52401738
$op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge" or $op eq "lt"
l!l&&r!l&&!r
52401738
$op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge"
l!l&&r!l&&!r
52401738
$op eq "eq" or $op eq "ne" or $op eq "gt"
l!l&&r!l&&!r
52401738
$op eq "eq" or $op eq "ne"
l!l&&r!l&&!r
52311738
MC/DC14%2/14
$op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge" or $op eq "lt" or $op eq "le" or $op eq "cmp" or $op eq "eqi" or $op eq "nei" or $op eq "gti" or $op eq "gei" or $op eq "lti" or $op eq "lei" or $op eq "cmpi"
$op eq "eq" $op eq "ne" $op eq "gt" $op eq "ge" $op eq "lt" $op eq "le" $op eq "cmp" $op eq "eqi" $op eq "nei" $op eq "gti" $op eq "gei" $op eq "lti" $op eq "lei" $op eq "cmpi"
Truth table20%3/15
A or B or C or D or E or F or G or H or I or J or K or L or M or N
A= $op eq "eq"B= $op eq "ne"C= $op eq "gt"D= $op eq "ge"E= $op eq "lt"F= $op eq "le"G= $op eq "cmp"H= $op eq "eqi"I= $op eq "nei"J= $op eq "gti"K= $op eq "gei"L= $op eq "lti"M= $op eq "lei"N= $op eq "cmpi"
ABCDEFGHIJKLMNresult
1XXXXXXXXXXXXX1
01XXXXXXXXXXXX1
001XXXXXXXXXXX1
0001XXXXXXXXXX1
00001XXXXXXXXX1
000001XXXXXXXX1
0000001XXXXXXX1
00000001XXXXXX1
000000001XXXXX1
0000000001XXXX1
00000000001XXX1
000000000001XX1
0000000000001X1
000000000000011
000000000000000
4109 $op eq 'eq' or $op eq 'ne' or $op eq 'gt' or $op eq 'ge'
4110 or $op eq 'lt' or $op eq 'le' or $op eq 'cmp'
4111 or $op eq 'eqi' or $op eq 'nei' or $op eq 'gti'
4112 or $op eq 'gei' or $op eq 'lti' or $op eq 'lei'
4113 or $op eq 'cmpi'
4114 ) {
4115 524 my $ls = $self->_to_OperatorString( $l, $file, $line );
4116 524 my $rs = $self->_to_OperatorString( $r, $file, $line );
4117  
4118 524 ▶ if ($op eq 'eq') { return $ls eq $rs ? $TRUE : $FALSE; }
Branch: 2 branches
BranchTrueFalseTotal
if ($op eq "eq") 523 1 524
$ls eq $rs ? : 127 396 523
4119 1 ▶ if ($op eq 'ne') { return $ls ne $rs ? $TRUE : $FALSE; }
Branch: 2 branches
BranchTrueFalseTotal
if ($op eq "ne") 1 0 1
$ls ne $rs ? : 0 1 1
4120 0 ▶ if ($op eq 'gt') { return $ls gt $rs ? $TRUE : $FALSE; }
Branch: 2 branches
BranchTrueFalseTotal
if ($op eq "gt") 0 0 0
$ls gt $rs ? : 0 0 0
4121 0 ▶ if ($op eq 'ge') { return $ls ge $rs ? $TRUE : $FALSE; }
Branch: 2 branches
BranchTrueFalseTotal
if ($op eq "ge") 0 0 0
$ls ge $rs ? : 0 0 0
4122 0 ▶ if ($op eq 'lt') { return $ls lt $rs ? $TRUE : $FALSE; }
Branch: 2 branches
BranchTrueFalseTotal
if ($op eq "lt") 0 0 0
$ls lt $rs ? : 0 0 0
4123 0 ▶ if ($op eq 'le') { return $ls le $rs ? $TRUE : $FALSE; }
Branch: 2 branches
BranchTrueFalseTotal
if ($op eq "le") 0 0 0
$ls le $rs ? : 0 0 0
4124 0 ▶ if ($op eq 'cmp') { return $ls cmp $rs; }
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "cmp") 0 0 0
4125  
4126 0 my $lsi = CORE::fc( $ls );
4127 0 my $rsi = CORE::fc( $rs );
4128  
4129 0 ▶ if ($op eq 'eqi') { return $lsi eq $rsi ? $TRUE : $FALSE; }
Branch: 2 branches
BranchTrueFalseTotal
if ($op eq "eqi") 0 0 0
$lsi eq $rsi ? : 0 0 0
4130 0 ▶ if ($op eq 'nei') { return $lsi ne $rsi ? $TRUE : $FALSE; }
Branch: 2 branches
BranchTrueFalseTotal
if ($op eq "nei") 0 0 0
$lsi ne $rsi ? : 0 0 0
4131 0 ▶ if ($op eq 'gti') { return $lsi gt $rsi ? $TRUE : $FALSE; }
Branch: 2 branches
BranchTrueFalseTotal
if ($op eq "gti") 0 0 0
$lsi gt $rsi ? : 0 0 0
4132 0 ▶ if ($op eq 'gei') { return $lsi ge $rsi ? $TRUE : $FALSE; }
Branch: 2 branches
BranchTrueFalseTotal
if ($op eq "gei") 0 0 0
$lsi ge $rsi ? : 0 0 0
4133 0 ▶ if ($op eq 'lti') { return $lsi lt $rsi ? $TRUE : $FALSE; }
Branch: 2 branches
BranchTrueFalseTotal
if ($op eq "lti") 0 0 0
$lsi lt $rsi ? : 0 0 0
4134 0 ▶ if ($op eq 'lei') { return $lsi le $rsi ? $TRUE : $FALSE; }
Branch: 2 branches
BranchTrueFalseTotal
if ($op eq "lei") 0 0 0
$lsi le $rsi ? : 0 0 0
4135 0 ▶ if ($op eq 'cmpi') { return $lsi cmp $rsi; }
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "cmpi") 0 0 0
4136 }
4137  
4138 1738 ▶ if ($op eq 'in' || $op eq '∈') {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "in" or $op eq "\x{2208}") 54 1684 1738
Condition100%3/3
$op eq "in" or $op eq "\x{2208}"
l!l&&r!l&&!r
42121684
MC/DC100%2/2
$op eq "in" or $op eq "\x{2208}"
$op eq "in" $op eq "\x{2208}"
Truth table100%3/3
A or B
A= $op eq "in"B= $op eq "\x{2208}"
ABresult
1X1
011
000
4139 54 return $self->_in_collection( $l, $r, $file, $line );
4140 }
4141 1684 ▶ if ($op eq '∉') {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "\x{2209}") 2 1682 1684
4142 2 ▶ return $self->_in_collection( $l, $r, $file, $line ) ? $FALSE : $TRUE;
Branch: 1 branch
BranchTrueFalseTotal
$self->_in_collection($l, $r, $file, $line) ? : 2 0 2
4143 }
4144 1682 ▶ if ($op eq 'union' || $op eq '⋃') {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "union" or $op eq "\x{22c3}") 5 1677 1682
Condition66%2/3
$op eq "union" or $op eq "\x{22c3}"
l!l&&r!l&&!r
501677
MC/DC50%1/2
$op eq "union" or $op eq "\x{22c3}"
$op eq "union" $op eq "\x{22c3}"
Truth table66%2/3
A or B
A= $op eq "union"B= $op eq "\x{22c3}"
ABresult
1X1
011
000
4145 5 return $self->_set_union( $l, $r, $file, $line );
4146 }
4147 1677 ▶ if ($op eq 'intersection' || $op eq '⋂') {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "intersection" or $op eq "\x{22c2}") 1 1676 1677
Condition66%2/3
$op eq "intersection" or $op eq "\x{22c2}"
l!l&&r!l&&!r
101676
MC/DC50%1/2
$op eq "intersection" or $op eq "\x{22c2}"
$op eq "intersection" $op eq "\x{22c2}"
Truth table66%2/3
A or B
A= $op eq "intersection"B= $op eq "\x{22c2}"
ABresult
1X1
011
000
4148 1 return $self->_set_intersection( $l, $r, $file, $line );
4149 }
4150 1676 ▶ if ($op eq '\\' || $op eq '∖') {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "\\" or $op eq "\x{2216}") 1 1675 1676
Condition66%2/3
$op eq "\\" or $op eq "\x{2216}"
l!l&&r!l&&!r
101675
MC/DC50%1/2
$op eq "\\" or $op eq "\x{2216}"
$op eq "\\" $op eq "\x{2216}"
Truth table66%2/3
A or B
A= $op eq "\\"B= $op eq "\x{2216}"
ABresult
1X1
011
000
4151 1 return $self->_set_difference( $l, $r, $file, $line );
4152 }
4153 1675 ▶ if ($op eq 'subsetof' || $op eq '⊂') {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "subsetof" or $op eq "\x{2282}") 1 1674 1675
Condition66%2/3
$op eq "subsetof" or $op eq "\x{2282}"
l!l&&r!l&&!r
101674
MC/DC50%1/2
$op eq "subsetof" or $op eq "\x{2282}"
$op eq "subsetof" $op eq "\x{2282}"
Truth table66%2/3
A or B
A= $op eq "subsetof"B= $op eq "\x{2282}"
ABresult
1X1
011
000
4154 1 my $diff = $self->_set_difference( $l, $r, $file, $line );
4155 1 ▶ return $diff->empty ? $TRUE : $FALSE;
Branch: 1 branch
BranchTrueFalseTotal
$diff->empty ? : 1 0 1
4156 }
4157 1674 ▶ if ($op eq 'supersetof' || $op eq '⊃') {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "supersetof" or $op eq "\x{2283}") 1 1673 1674
Condition66%2/3
$op eq "supersetof" or $op eq "\x{2283}"
l!l&&r!l&&!r
101673
MC/DC50%1/2
$op eq "supersetof" or $op eq "\x{2283}"
$op eq "supersetof" $op eq "\x{2283}"
Truth table66%2/3
A or B
A= $op eq "supersetof"B= $op eq "\x{2283}"
ABresult
1X1
011
000
4158 1 my $diff = $self->_set_difference( $r, $l, $file, $line );
4159 1 ▶ return $diff->empty ? $TRUE : $FALSE;
Branch: 1 branch
BranchTrueFalseTotal
$diff->empty ? : 1 0 1
4160 }
4161 1673 ▶ if ($op eq 'equivalentof' || $op eq '⊂⊃') {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "equivalentof" or $op eq "\x{2282}\x{2283}") 1 1672 1673
Condition66%2/3
$op eq "equivalentof" or $op eq "\x{2282}\x{2283}"
l!l&&r!l&&!r
101672
MC/DC50%1/2
$op eq "equivalentof" or $op eq "\x{2282}\x{2283}"
$op eq "equivalentof" $op eq "\x{2282}\x{2283}"
Truth table66%2/3
A or B
A= $op eq "equivalentof"B= $op eq "\x{2282}\x{2283}"
ABresult
1X1
011
000
4162 1 my $a = $self->_set_difference( $l, $r, $file, $line );
4163 1 my $b = $self->_set_difference( $r, $l, $file, $line );
4164 1 ▶ return ( $a->empty and $b->empty ) ? $TRUE : $FALSE;
Branch: 1 branch
BranchTrueFalseTotal
$a->empty && $b->empty ? : 1 0 1
Condition33%1/3
$a->empty and $b->empty
!ll&&!rl&&r
001
MC/DC0%0/2
$a->empty and $b->empty
$a->empty $b->empty
Truth table33%1/3
A and B
A= $a->emptyB= $b->empty
ABresult
0X0
100
111
4165 }
4166 1672 ▶ if ( $op eq 'instanceof' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "instanceof") 1638 34 1672
4167 1638 ▶ return 0 if !blessed($r) or !$r->isa('Zuzu::Value::Class');
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($r) and $r->isa("Zuzu::Value::Class") 0 1638 1638
Condition33%1/3
builtin::blessed($r) and $r->isa("Zuzu::Value::Class")
!ll&&!rl&&r
001638
MC/DC0%0/2
builtin::blessed($r) and $r->isa("Zuzu::Value::Class")
builtin::blessed($r) $r->isa("Zuzu::Value::Class")
Truth table33%1/3
A and B
A= builtin::blessed($r)B= $r->isa("Zuzu::Value::Class")
ABresult
0X0
100
111
4168 1638 return $self->_value_matches_class( $l, $r );
4169 }
4170 34 ▶ if ( $op eq 'does' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "does") 2 32 34
4171 2 ▶ return $FALSE if !ref($l);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $l 0 2 2
4172 2 my $target = $l;
4173 2 ▶ $target = $l->class if $l->isa('Zuzu::Value::Object');
Branch: 1 branch
BranchTrueFalseTotal
if $l->isa("Zuzu::Value::Object") 2 0 2
4174 2 ▶ return $FALSE if !$target->isa('Zuzu::Value::Class');
Branch: 1 branch
BranchTrueFalseTotal
unless $target->isa("Zuzu::Value::Class") 0 2 2
4175 2 ▶ return $FALSE if !blessed($r) or !$r->isa('Zuzu::Value::Trait');
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($r) and $r->isa("Zuzu::Value::Trait") 0 2 2
Condition33%1/3
builtin::blessed($r) and $r->isa("Zuzu::Value::Trait")
!ll&&!rl&&r
002
MC/DC0%0/2
builtin::blessed($r) and $r->isa("Zuzu::Value::Trait")
builtin::blessed($r) $r->isa("Zuzu::Value::Trait")
Truth table33%1/3
A and B
A= builtin::blessed($r)B= $r->isa("Zuzu::Value::Trait")
ABresult
0X0
100
111
4176 2 my $k = $target;
4177 2 ▶ while ($k) {
Branch: 1 branch
BranchTrueFalseTotal
if ($k) 3 0 3
4178 3 ▶ for my $tr ( @{ $k->traits // [] } ) {
Condition50%1/2
$k->traits // []
l!l
30
MC/DC0%0/1
$k->traits // []
$k->traits
Truth table50%1/2
A
A= $k->traits
Aresult
11
00
4179 3 ▶ return $TRUE if $tr == $r;
Branch: 1 branch
BranchTrueFalseTotal
if $tr == $r 2 1 3
4180 }
4181 1 $k = $k->parent;
4182 }
4183 0 return $FALSE;
4184 }
4185 32 ▶ if ( $op eq 'can' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "can") 32 0 32
4186 32 ▶ my $method = defined($r) ? "$r" : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $r ? : 32 0 32
4187 32 ▶ return $FALSE if $method eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $method eq "" 0 32 32
4188 32 ▶ if ( blessed($l) and $l->isa('Zuzu::Value::Object') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($l) and $l->isa("Zuzu::Value::Object")) 2 30 32
Condition66%2/3
builtin::blessed($l) and $l->isa("Zuzu::Value::Object")
!ll&&!rl&&r
0302
MC/DC50%1/2
builtin::blessed($l) and $l->isa("Zuzu::Value::Object")
builtin::blessed($l) $l->isa("Zuzu::Value::Object")
Truth table66%2/3
A and B
A= builtin::blessed($l)B= $l->isa("Zuzu::Value::Object")
ABresult
0X0
100
111
4189 2 ▶ return $self->_lookup_method( $l->class, $method, 0 ) ? $TRUE : $FALSE;
Branch: 1 branch
BranchTrueFalseTotal
$self->_lookup_method($l->class, $method, 0) ? : 2 0 2
4190 }
4191 30 ▶ if ( blessed($l) and $l->isa('Zuzu::Value::Class') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($l) and $l->isa("Zuzu::Value::Class")) 0 30 30
Condition33%1/3
builtin::blessed($l) and $l->isa("Zuzu::Value::Class")
!ll&&!rl&&r
0300
MC/DC0%0/2
builtin::blessed($l) and $l->isa("Zuzu::Value::Class")
builtin::blessed($l) $l->isa("Zuzu::Value::Class")
Truth table33%1/3
A and B
A= builtin::blessed($l)B= $l->isa("Zuzu::Value::Class")
ABresult
0X0
100
111
4192 0 ▶ return $self->_lookup_method( $l, $method, 1 ) ? $TRUE : $FALSE;
Branch: 1 branch
BranchTrueFalseTotal
$self->_lookup_method($l, $method, 1) ? : 0 0 0
4193 }
4194 30 ▶ return $FALSE if !ref($l);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $l 0 30 30
4195  
4196 30 ▶ return $l->can($method) ? $TRUE : $FALSE;
Branch: 1 branch
BranchTrueFalseTotal
$l->can($method) ? : 0 30 30
4197 }
4198  
4199 0 die Zuzu::Error->new_runtime(message => "Unsupported binary op '$op'", file => $file, line => $line);
4200 }
4201  
4202 11 ▶sub _default_collection_values {
Subroutine _default_collection_values: called CC=22 SCAR=31.7
4203 11 my ( $self, $left, $right, $file, $line ) = @_;
4204  
4205 11 my $right_dict = $self->_unwrap_builtin_collection( $right, 'Dict' );
4206 11 my $right_pairlist = $self->_unwrap_builtin_collection( $right, 'PairList' );
4207 11 ▶ if ( !$right_dict and !$right_pairlist ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($right_dict or $right_pairlist) 2 9 11
Condition100%3/3
$right_dict or $right_pairlist
l!l&&r!l&&!r
362
MC/DC100%2/2
$right_dict or $right_pairlist
$right_dict $right_pairlist
Truth table100%3/3
A or B
A= $right_dictB= $right_pairlist
ABresult
1X1
011
000
4208 2 my $type = $self->_type_name($right);
4209 2 die Zuzu::Error->new_runtime(
4210 message => "TypeException: default operator right operand expects Dict or PairList, got $type",
4211 file => $file,
4212 line => $line,
4213 );
4214 }
4215  
4216 9 my $left_dict;
4217 my $left_pairlist;
4218 9 ▶ if ( defined $left ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $left) 8 1 9
4219 8 $left_dict = $self->_unwrap_builtin_collection( $left, 'Dict' );
4220 8 $left_pairlist = $self->_unwrap_builtin_collection( $left, 'PairList' );
4221 8 ▶ if ( !$left_dict and !$left_pairlist ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($left_dict or $left_pairlist) 1 7 8
Condition100%3/3
$left_dict or $left_pairlist
l!l&&r!l&&!r
341
MC/DC100%2/2
$left_dict or $left_pairlist
$left_dict $left_pairlist
Truth table100%3/3
A or B
A= $left_dictB= $left_pairlist
ABresult
1X1
011
000
4222 1 my $type = $self->_type_name($left);
4223 1 die Zuzu::Error->new_runtime(
4224 message => "TypeException: default operator left operand expects Dict, PairList, or Null, got $type",
4225 file => $file,
4226 line => $line,
4227 );
4228 }
4229 }
4230  
4231 8 ▶ if ($left_dict) {
Branch: 1 branch
BranchTrueFalseTotal
if ($left_dict) 3 5 8
4232 3 my $result = $left_dict->copy;
4233 3 ▶ if ($right_dict) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_dict) { } 2 1 3
4234 2 for my $key ( sort CORE::keys %{ $right_dict->map } ) {
4235 3 ▶ next if $result->exists($key);
Branch: 1 branch
BranchTrueFalseTotal
if $result->exists($key) 1 2 3
4236 $result->_store_key(
4237 $key,
4238 $right_dict->_value_for_key($key),
4239 2 ▶ $right_dict->weak->{$key} ? 1 : 0,
Branch: 1 branch
BranchTrueFalseTotal
$right_dict->weak->{$key} ? : 0 2 2
4240 );
4241 }
4242 }
4243 else {
4244 1 ▶ for ( my $i = 0; $i < @{ $right_pairlist->list }; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @{$right_pairlist->list;}) 3 1 4
4245 3 my $key = $right_pairlist->list->[$i][0];
4246 3 ▶ next if $result->exists($key);
Branch: 1 branch
BranchTrueFalseTotal
if $result->exists($key) 2 1 3
4247 1 ▶ $result->_store_key(
Branch: 1 branch
BranchTrueFalseTotal
$right_pairlist->weak->[$i] ? : 0 1 1
4248 $key,
4249 $right_pairlist->_value_at($i),
4250 $right_pairlist->weak->[$i] ? 1 : 0,
4251 );
4252 }
4253 }
4254  
4255 3 return $result;
4256 }
4257  
4258 5 ▶ my $source = $left_pairlist // Zuzu::Value::PairList->new( list => [] );
Condition66%2/3
$left_pairlist // "Zuzu::Value::PairList"->new("list", [])
l!l&&r!l&&!r
410
MC/DC0%0/2
$left_pairlist // "Zuzu::Value::PairList"->new("list", [])
$left_pairlist "Zuzu::Value::PairList"->new("list", [])
Truth table66%2/3
A // B
A= $left_pairlistB= "Zuzu::Value::PairList"->new("list", [])
ABresult
1X1
011
000
4259 5 my $result = $source->copy;
4260 5 my %original_key = map { $_->[0] => 1 } @{ $source->list };
4261  
4262 5 ▶ if ($right_dict) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_dict) { } 0 5 5
4263 0 for my $key ( sort CORE::keys %{ $right_dict->map } ) {
4264 0 ▶ next if $original_key{$key};
Branch: 1 branch
BranchTrueFalseTotal
if $original_key{$key} 0 0 0
4265 $result->_append(
4266 $key,
4267 $right_dict->_value_for_key($key),
4268 0 ▶ $right_dict->weak->{$key} ? 1 : 0,
Branch: 1 branch
BranchTrueFalseTotal
$right_dict->weak->{$key} ? : 0 0 0
4269 );
4270 }
4271 }
4272 else {
4273 5 ▶ for ( my $i = 0; $i < @{ $right_pairlist->list }; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @{$right_pairlist->list;}) 11 5 16
4274 11 my $key = $right_pairlist->list->[$i][0];
4275 11 ▶ next if $original_key{$key};
Branch: 1 branch
BranchTrueFalseTotal
if $original_key{$key} 3 8 11
4276 8 ▶ $result->_append(
Branch: 1 branch
BranchTrueFalseTotal
$right_pairlist->weak->[$i] ? : 0 8 8
4277 $key,
4278 $right_pairlist->_value_at($i),
4279 $right_pairlist->weak->[$i] ? 1 : 0,
4280 );
4281 }
4282 }
4283  
4284 5 return $result;
4285 }
4286  
4287 17 ▶sub _eval_path_operator {
Subroutine _eval_path_operator: called CC=4 SCAR=13.9
4288 17 my ( $self, $op, $target, $path_value, $file, $line ) = @_;
4289  
4290 17 my $path_obj = $self->_coerce_path_operand( $path_value, $file, $line );
4291  
4292 14 ▶ if ( $op eq '@' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "\@") 5 9 14
4293 5 return $self->_call_path_method(
4294 $path_obj,
4295 'first',
4296 [ $target, undef ],
4297 $file,
4298 $line,
4299 );
4300 }
4301 9 ▶ if ( $op eq '@?' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "\@?") 3 6 9
4302 3 my $exists = $self->_call_path_method(
4303 $path_obj,
4304 'exists',
4305 [ $target ],
4306 $file,
4307 $line,
4308 );
4309 2 ▶ return $self->_to_Boolean( $exists ) ? $TRUE : $FALSE;
Branch: 1 branch
BranchTrueFalseTotal
$self->_to_Boolean($exists) ? : 1 1 2
4310 }
4311  
4312 6 return $self->_call_path_method(
4313 $path_obj,
4314 'get',
4315 [ $target ],
4316 $file,
4317 $line,
4318 );
4319 }
4320  
4321 35 ▶sub _coerce_path_operand {
Subroutine _coerce_path_operand: called CC=5 SCAR=17.1
4322 35 my ( $self, $path_value, $file, $line ) = @_;
4323  
4324 35 ▶ if ( blessed($path_value) and $path_value->isa('Zuzu::Value::Object') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($path_value) and $path_value->isa("Zuzu::Value::Object")) 0 35 35
Condition33%1/3
builtin::blessed($path_value) and $path_value->isa("Zuzu::Value::Object")
!ll&&!rl&&r
3500
MC/DC0%0/2
builtin::blessed($path_value) and $path_value->isa("Zuzu::Value::Object")
builtin::blessed($path_value) $path_value->isa("Zuzu::Value::Object")
Truth table33%1/3
A and B
A= builtin::blessed($path_value)B= $path_value->isa("Zuzu::Value::Object")
ABresult
0X0
100
111
4325 0 return $path_value;
4326 }
4327  
4328 35 ▶ if ( !ref($path_value) and $self->_type_name( $path_value ) eq 'String' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not ref $path_value and $self->_type_name($path_value) eq "String") 33 2 35
Condition66%2/3
not ref $path_value and $self->_type_name($path_value) eq "String"
!ll&&!rl&&r
0233
MC/DC50%1/2
not ref $path_value and $self->_type_name($path_value) eq "String"
not ref $path_value $self->_type_name($path_value) eq "String"
Truth table66%2/3
not(A) and B
A= not ref $path_valueB= $self->_type_name($path_value) eq "String"
ABresult
0X0
100
111
4329 33 my $path_class = $self->_resolve_path_class_from_props( $file, $line );
4330 32 return $self->_instantiate_path_object( $path_class, $path_value, $file, $line );
4331 }
4332  
4333 2 my $type = $self->_type_name( $path_value );
4334 2 die Zuzu::Error->new_runtime(
4335 message => "TypeException: path operand must be String or Object, got $type",
4336 file => $file,
4337 line => $line,
4338 );
4339 }
4340  
4341 33 ▶sub _resolve_path_class_from_props {
Subroutine _resolve_path_class_from_props: called CC=4 SCAR=13.9
4342 33 my ( $self, $file, $line ) = @_;
4343  
4344 33 my $prop = $self->_env->get_special_prop('paths');
4345 33 ▶ if ( defined $prop ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $prop) 4 29 33
4346 4 ▶ if ( blessed($prop) and $prop->isa('Zuzu::Value::Class') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($prop) and $prop->isa("Zuzu::Value::Class")) 3 1 4
Condition66%2/3
builtin::blessed($prop) and $prop->isa("Zuzu::Value::Class")
!ll&&!rl&&r
103
MC/DC50%1/2
builtin::blessed($prop) and $prop->isa("Zuzu::Value::Class")
builtin::blessed($prop) $prop->isa("Zuzu::Value::Class")
Truth table66%2/3
A and B
A= builtin::blessed($prop)B= $prop->isa("Zuzu::Value::Class")
ABresult
0X0
100
111
4347 3 return $prop;
4348 }
4349 1 my $type = $self->_type_name( $prop );
4350 1 die Zuzu::Error->new_runtime(
4351 message => "TypeException: paths special property must be Class or null, got $type",
4352 file => $file,
4353 line => $line,
4354 );
4355 }
4356  
4357 29 return $self->_default_path_class( $file, $line );
4358 }
4359  
4360 29 ▶sub _default_path_class {
Subroutine _default_path_class: called CC=6 SCAR=18.7
4361 29 my ( $self, $file, $line ) = @_;
4362  
4363 return $self->{_default_path_class}
4364 if blessed( $self->{_default_path_class} )
4365 29 ▶ and $self->{_default_path_class}->isa('Zuzu::Value::Class');
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($self->{"_default_path_class"}) and $self->{"_default_path_class"}->isa("Zuzu::Value::Class") 11 18 29
Condition66%2/3
builtin::blessed($self->{"_default_path_class"}) and $self->{"_default_path_class"}->isa("Zuzu::Value::Class")
!ll&&!rl&&r
18011
MC/DC50%1/2
builtin::blessed($self->{"_default_path_class"}) and $self->{"_default_path_class"}->isa("Zuzu::Value::Class")
builtin::blessed($self->{"_default_path_class"}) $self->{"_default_path_class"}->isa("Zuzu::Value::Class")
Truth table66%2/3
A and B
A= builtin::blessed($self->{"_default_path_class"})B= $self->{"_default_path_class"}->isa("Zuzu::Value::Class")
ABresult
0X0
100
111
4366  
4367 18 my $module_env = $self->_load_module( 'std/path/zz', $file, $line );
4368 18 my $class_ref = $module_env->find_ref('ZZPath');
4369 18 ▶ die Zuzu::Error->new_runtime(
Branch: 1 branch
BranchTrueFalseTotal
unless defined $class_ref 0 18 18
4370 message => "Cannot resolve default path class 'ZZPath' from std/path/zz",
4371 file => $file,
4372 line => $line,
4373 ) if !defined $class_ref;
4374  
4375 18 my $class_obj = $$class_ref;
4376 18 ▶ die Zuzu::Error->new_runtime(
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($class_obj) and $class_obj->isa("Zuzu::Value::Class") 0 18 18
Condition33%1/3
builtin::blessed($class_obj) and $class_obj->isa("Zuzu::Value::Class")
!ll&&!rl&&r
0018
MC/DC0%0/2
builtin::blessed($class_obj) and $class_obj->isa("Zuzu::Value::Class")
builtin::blessed($class_obj) $class_obj->isa("Zuzu::Value::Class")
Truth table33%1/3
A and B
A= builtin::blessed($class_obj)B= $class_obj->isa("Zuzu::Value::Class")
ABresult
0X0
100
111
4377 message => "Default path class 'ZZPath' from std/path/zz is not a Class",
4378 file => $file,
4379 line => $line,
4380 ) if !blessed($class_obj) or !$class_obj->isa('Zuzu::Value::Class');
4381  
4382 18 $self->{_default_path_class} = $class_obj;
4383 18 return $class_obj;
4384 }
4385  
4386 32 ▶sub _instantiate_path_object {
Subroutine _instantiate_path_object: called CC=5 SCAR=16.4
4387 32 my ( $self, $path_class, $path_text, $file, $line ) = @_;
4388  
4389 32 my %named = ( path => $path_text );
4390 32 my ($slots, $const, $types, $weak) = $self->_instantiate_slots($path_class);
4391 32 for my $k ( keys %named ) {
4392 32 $slots->{$k} = $named{$k};
4393 32 ▶ $const->{$k} = 0 if !exists $const->{$k};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $const->{$k} 0 32 32
4394 32 ▶ $types->{$k} = 'Any' if !exists $types->{$k};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $types->{$k} 0 32 32
4395 32 ▶ $weak->{$k} = 0 if !exists $weak->{$k};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $weak->{$k} 0 32 32
4396 }
4397 32 my $object = Zuzu::Value::Object->new(
4398 class => $path_class,
4399 slots => $slots,
4400 const => $const,
4401 types => $types,
4402 weak => $weak,
4403 );
4404 32 return $self->_apply_object_lifecycle_hooks( $object, $path_class, $file, $line );
4405 }
4406  
4407 32 ▶sub _call_path_method {
Subroutine _call_path_method: called CC=2 SCAR=7.0
4408 32 my ( $self, $path_obj, $method_name, $args, $file, $line ) = @_;
4409  
4410 32 my $method = $self->_lookup_method( $path_obj->class, $method_name, 0 );
4411 32 ▶ die Zuzu::Error->new_runtime(
Branch: 1 branch
BranchTrueFalseTotal
unless $method 0 32 32
4412 message => "Path object does not support method '$method_name'",
4413 file => $file,
4414 line => $line,
4415 ) if !$method;
4416  
4417 32 return $self->_call_method(
4418 $method,
4419 $path_obj,
4420 $args,
4421 $EMPTY_HASH,
4422 $EMPTY_ARRAY,
4423 $file,
4424 $line,
4425 );
4426 }
4427  
4428 226 ▶sub _bitwise_binary_op {
Subroutine _bitwise_binary_op: called CC=12 SCAR=25.3
4429 226 my ( $self, $op, $left, $right, $file, $line ) = @_;
4430  
4431 226 ▶ my $left_is_binary = blessed($left) && $left->isa('Zuzu::Value::BinaryString') ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($left) && $left->isa('Zuzu::Value::BinaryString') ? : 6 220 226
Condition66%2/3
builtin::blessed($left) and $left->isa("Zuzu::Value::BinaryString")
!ll&&!rl&&r
22006
MC/DC50%1/2
builtin::blessed($left) and $left->isa("Zuzu::Value::BinaryString")
builtin::blessed($left) $left->isa("Zuzu::Value::BinaryString")
Truth table66%2/3
A and B
A= builtin::blessed($left)B= $left->isa("Zuzu::Value::BinaryString")
ABresult
0X0
100
111
4432 226 ▶ my $right_is_binary = blessed($right) && $right->isa('Zuzu::Value::BinaryString') ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($right) && $right->isa('Zuzu::Value::BinaryString') ? : 5 221 226
Condition66%2/3
builtin::blessed($right) and $right->isa("Zuzu::Value::BinaryString")
!ll&&!rl&&r
22105
MC/DC50%1/2
builtin::blessed($right) and $right->isa("Zuzu::Value::BinaryString")
builtin::blessed($right) $right->isa("Zuzu::Value::BinaryString")
Truth table66%2/3
A and B
A= builtin::blessed($right)B= $right->isa("Zuzu::Value::BinaryString")
ABresult
0X0
100
111
4433 226 ▶ if ( $left_is_binary || $right_is_binary ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($left_is_binary or $right_is_binary) 6 220 226
Condition66%2/3
$left_is_binary or $right_is_binary
l!l&&r!l&&!r
60220
MC/DC50%1/2
$left_is_binary or $right_is_binary
$left_is_binary $right_is_binary
Truth table66%2/3
A or B
A= $left_is_binaryB= $right_is_binary
ABresult
1X1
011
000
4434 6 ▶ if ( !$left_is_binary or !$right_is_binary ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($left_is_binary and $right_is_binary) 1 5 6
Condition66%2/3
$left_is_binary and $right_is_binary
!ll&&!rl&&r
015
MC/DC50%1/2
$left_is_binary and $right_is_binary
$left_is_binary $right_is_binary
Truth table66%2/3
A and B
A= $left_is_binaryB= $right_is_binary
ABresult
0X0
100
111
4435 1 die Zuzu::Error->new_runtime(
4436 message => "TypeException: BinaryString bitwise '$op' expects BinaryString operands on both sides",
4437 file => $file,
4438 line => $line,
4439 );
4440 }
4441 5 return $self->_bitwise_binary_string_pair( $op, $left, $right, $file, $line );
4442 }
4443  
4444 220 my $ln = int( $self->_to_Number( $left ) );
4445 220 my $rn = int( $self->_to_Number( $right ) );
4446  
4447 220 ▶ return ( $ln & $rn ) if $op eq '&';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "&" 153 67 220
4448 67 ▶ return ( $ln | $rn ) if $op eq '|';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "|" 2 65 67
4449 65 ▶ return ( $ln ^ $rn ) if $op eq '^';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "^" 65 0 65
4450 0 die Zuzu::Error->new_runtime(message => "Unsupported bitwise op '$op'", file => $file, line => $line);
4451 }
4452  
4453 5 ▶sub _bitwise_binary_string_pair {
Subroutine _bitwise_binary_string_pair: called CC=7 SCAR=19.5
4454 5 my ( $self, $op, $left, $right, $file, $line ) = @_;
4455  
4456 5 ▶ my $lhs = $left->bytes // '';
Condition50%1/2
$left->bytes // ""
l!l
50
MC/DC0%0/1
$left->bytes // ""
$left->bytes
Truth table50%1/2
A
A= $left->bytes
Aresult
11
00
4457 5 ▶ my $rhs = $right->bytes // '';
Condition50%1/2
$right->bytes // ""
l!l
50
MC/DC0%0/1
$right->bytes // ""
$right->bytes
Truth table50%1/2
A
A= $right->bytes
Aresult
11
00
4458 5 my $llen = length( $lhs );
4459 5 my $rlen = length( $rhs );
4460 5 ▶ if ( $llen != $rlen ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($llen != $rlen) 1 4 5
4461 1 die Zuzu::Error->new_runtime(
4462 message => "Bitwise '$op' on BinaryString requires equal byte lengths",
4463 file => $file,
4464 line => $line,
4465 );
4466 }
4467 4 my $out = '';
4468 4 ▶ for ( my $i = 0; $i < $llen; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $llen) 8 4 12
4469 8 my $lb = ord( substr( $lhs, $i, 1 ) );
4470 8 my $rb = ord( substr( $rhs, $i, 1 ) );
4471 8 ▶ my $xb = $op eq '&'
Branch: 2 branches
BranchTrueFalseTotal
$op eq '&' ? : 4 4 8
$op eq '|' ? : 2 2 4
4472 ? ( $lb & $rb )
4473 : $op eq '|'
4474 ? ( $lb | $rb )
4475 : ( $lb ^ $rb );
4476 8 $out .= chr( $xb );
4477 }
4478  
4479 4 return Zuzu::Value::BinaryString->new( bytes => $out );
4480 }
4481  
4482 0 ▶sub _shift_binary_op {
Subroutine _shift_binary_op: not called CC=8 SCAR=42.8
4483 0 my ( $self, $op, $left, $right, $file, $line ) = @_;
4484  
4485 0 ▶ my $left_shift = ( $op eq '<<' || $op eq '«' ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$op eq '<<' || $op eq "\253" ? : 0 0 0
Condition0%0/3
$op eq "<<" or $op eq "\x{ab}"
l!l&&r!l&&!r
000
MC/DC0%0/2
$op eq "<<" or $op eq "\x{ab}"
$op eq "<<" $op eq "\x{ab}"
Truth table0%0/3
A or B
A= $op eq "<<"B= $op eq "\x{ab}"
ABresult
1X1
011
000
4486 0 my $count = $self->_to_Number( $right );
4487 0 $count = int( $count );
4488 0 ▶ if ( $count < 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count < 0) 0 0 0
4489 0 die Zuzu::Error->new_runtime(
4490 message => "shift count must be a non-negative integer",
4491 file => $file,
4492 line => $line,
4493 );
4494 }
4495  
4496 0 ▶ if ( blessed($left) and $left->isa('Zuzu::Value::BinaryString') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($left) and $left->isa("Zuzu::Value::BinaryString")) 0 0 0
Condition0%0/3
builtin::blessed($left) and $left->isa("Zuzu::Value::BinaryString")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($left) and $left->isa("Zuzu::Value::BinaryString")
builtin::blessed($left) $left->isa("Zuzu::Value::BinaryString")
Truth table0%0/3
A and B
A= builtin::blessed($left)B= $left->isa("Zuzu::Value::BinaryString")
ABresult
0X0
100
111
4497 0 ▶ return Zuzu::Value::BinaryString->new(
Condition0%0/2
$left->bytes // ""
l!l
00
MC/DC0%0/1
$left->bytes // ""
$left->bytes
Truth table0%0/2
A
A= $left->bytes
Aresult
11
00
4498 bytes => _shift_bitstream( $left->bytes // '', $count, $left_shift ),
4499 );
4500 }
4501  
4502 0 my $value = int( $self->_to_Number( $left ) );
4503 0 my $factor = 2 ** $count;
4504 0 ▶ return $left_shift
Branch: 1 branch
BranchTrueFalseTotal
$left_shift ? : 0 0 0
4505 ? $value * $factor
4506 : POSIX::floor( $value / $factor );
4507 }
4508  
4509 # Shift a byte string as one whole bit string: bits carry across byte
4510 # boundaries, length is preserved, vacated bits are 0.
4511 0 ▶sub _shift_bitstream {
Subroutine _shift_bitstream: not called CC=9 SCAR=45.0
4512 0 my ( $bytes, $count, $left ) = @_;
4513  
4514 0 my $len = length( $bytes );
4515 0 ▶ return $bytes if $len == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $len == 0 0 0 0
4516 0 ▶ return "\0" x $len if $count >= $len * 8;
Branch: 1 branch
BranchTrueFalseTotal
if $count >= $len * 8 0 0 0
4517  
4518 0 my $byte_shift = int( $count / 8 );
4519 0 my $bit_shift = $count % 8;
4520 0 my $out = '';
4521 0 ▶ for ( my $i = 0; $i < $len; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $len) 0 0 0
4522 0 my $value;
4523 0 ▶ if ( $left ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($left) { } 0 0 0
4524 0 my $src = $i + $byte_shift;
4525 0 ▶ my $hi = $src < $len ? ord( substr( $bytes, $src, 1 ) ) : 0;
Branch: 1 branch
BranchTrueFalseTotal
$src < $len ? : 0 0 0
4526 0 ▶ my $lo = $src + 1 < $len ? ord( substr( $bytes, $src + 1, 1 ) ) : 0;
Branch: 1 branch
BranchTrueFalseTotal
$src + 1 < $len ? : 0 0 0
4527 0 $value = ( ( ( $hi << 8 ) | $lo ) << $bit_shift ) >> 8;
4528 }
4529 else {
4530 0 ▶ if ( $i < $byte_shift ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $byte_shift) 0 0 0
4531 0 $out .= "\0";
4532 0 next;
4533 }
4534 0 my $lo = ord( substr( $bytes, $i - $byte_shift, 1 ) );
4535 0 ▶ my $hi = $i > $byte_shift
Branch: 1 branch
BranchTrueFalseTotal
$i > $byte_shift ? : 0 0 0
4536 ? ord( substr( $bytes, $i - $byte_shift - 1, 1 ) )
4537 : 0;
4538 0 $value = ( ( $hi << 8 ) | $lo ) >> $bit_shift;
4539 }
4540 0 $out .= chr( $value & 0xFF );
4541 }
4542  
4543 0 return $out;
4544 }
4545  
4546 9 ▶sub _bitwise_not_value {
Subroutine _bitwise_not_value: called CC=5 SCAR=16.2
4547 9 my ( $self, $value, $file, $line ) = @_;
4548  
4549 9 ▶ if ( blessed($value) and $value->isa('Zuzu::Value::BinaryString') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($value) and $value->isa("Zuzu::Value::BinaryString")) 4 5 9
Condition66%2/3
builtin::blessed($value) and $value->isa("Zuzu::Value::BinaryString")
!ll&&!rl&&r
504
MC/DC50%1/2
builtin::blessed($value) and $value->isa("Zuzu::Value::BinaryString")
builtin::blessed($value) $value->isa("Zuzu::Value::BinaryString")
Truth table66%2/3
A and B
A= builtin::blessed($value)B= $value->isa("Zuzu::Value::BinaryString")
ABresult
0X0
100
111
4550 4 ▶ my $bytes = $value->bytes // '';
Condition50%1/2
$value->bytes // ""
l!l
40
MC/DC0%0/1
$value->bytes // ""
$value->bytes
Truth table50%1/2
A
A= $value->bytes
Aresult
11
00
4551 4 my $out = '';
4552 4 ▶ for ( my $i = 0; $i < length( $bytes ); $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < length $bytes) 8 4 12
4553 8 my $byte = ord( substr( $bytes, $i, 1 ) );
4554 8 $out .= chr( ( ~$byte ) & 0xFF );
4555 }
4556  
4557 4 return Zuzu::Value::BinaryString->new( bytes => $out );
4558 }
4559  
4560 5 return ~int( $self->_to_Number( $value ) );
4561 }
4562  
4563 1133 ▶sub _coerce_regexp {
Subroutine _coerce_regexp: called CC=6 SCAR=24.1
4564 1133 my ( $self, $value, $file, $line ) = @_;
4565  
4566 1133 ▶ if ( blessed($value) and $value->isa('Zuzu::Value::Regexp') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($value) and $value->isa("Zuzu::Value::Regexp")) 1133 0 1133
Condition33%1/3
builtin::blessed($value) and $value->isa("Zuzu::Value::Regexp")
!ll&&!rl&&r
001133
MC/DC0%0/2
builtin::blessed($value) and $value->isa("Zuzu::Value::Regexp")
builtin::blessed($value) $value->isa("Zuzu::Value::Regexp")
Truth table33%1/3
A and B
A= builtin::blessed($value)B= $value->isa("Zuzu::Value::Regexp")
ABresult
0X0
100
111
4567 1133 ▶ my $pattern = $value->pattern // '';
Condition50%1/2
$value->pattern // ""
l!l
11330
MC/DC0%0/1
$value->pattern // ""
$value->pattern
Truth table50%1/2
A
A= $value->pattern
Aresult
11
00
4568 1133 ▶ my $flags = $value->flags // '';
Condition50%1/2
$value->flags // ""
l!l
11330
MC/DC0%0/1
$value->flags // ""
$value->flags
Truth table50%1/2
A
A= $value->flags
Aresult
11
00
4569 1133 my $mods = $self->_regexp_flags_to_modifiers($flags);
4570  
4571 1133 return $self->_compile_regexp_pattern(
4572 $pattern,
4573 $mods,
4574 'literal',
4575 'Invalid regexp literal',
4576 $file,
4577 $line,
4578 );
4579 }
4580 0 ▶ if ( ref($value) eq 'Regexp' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value eq "Regexp") 0 0 0
4581 0 return $value;
4582 }
4583 0 my $pattern = $self->_to_OperatorString( $value, $file, $line );
4584  
4585 0 return $self->_compile_regexp_pattern(
4586 $pattern,
4587 '',
4588 'plain',
4589 'Invalid regexp value',
4590 $file,
4591 $line,
4592 );
4593 }
4594  
4595 1133 ▶sub _regexp_flags_to_modifiers {
Subroutine _regexp_flags_to_modifiers: called CC=3 SCAR=11.1
4596 1133 my ( $self, $flags ) = @_;
4597  
4598 1133 ▶ return ( $flags // '' ) =~ /i/ ? '(?i)' : '';
Branch: 1 branch
BranchTrueFalseTotal
($flags // '') =~ /i/ ? : 2 1131 1133
Condition50%1/2
$flags // ""
l!l
11330
MC/DC0%0/1
$flags // ""
$flags
Truth table50%1/2
A
A= $flags
Aresult
11
00
4599 }
4600  
4601 1133 ▶sub _compile_regexp_pattern {
Subroutine _compile_regexp_pattern: called CC=6 SCAR=19.5
4602 1133 my ( $self, $pattern, $mods, $kind, $message, $file, $line ) = @_;
4603  
4604 1133 ▶ $pattern //= '';
Condition50%1/2
$pattern //= ""
l!l
11330
MC/DC0%0/1
$pattern //= ""
$pattern
Truth table50%1/2
A
A= $pattern
Aresult
11
00
4605 1133 ▶ $mods //= '';
Condition50%1/2
$mods //= ""
l!l
11330
MC/DC0%0/1
$mods //= ""
$mods
Truth table50%1/2
A
A= $mods
Aresult
11
00
4606 1133 my $cache_key = "$kind\x1f$mods\x1f$pattern";
4607 1133 my $regex = $self->{_regexp_cache}{$cache_key};
4608 1133 ▶ return $regex if defined $regex;
Branch: 1 branch
BranchTrueFalseTotal
if defined $regex 1057 76 1133
4609 76 $regex = eval { qr/$mods$pattern/ };
4610 76 ▶ if ( !defined $regex ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $regex) 0 76 76
4611 0 ▶ my $err = $@ || 'unknown regex compile error';
Condition0%0/2
$@ || 'unknown regex compile error'
l!l
00
MC/DC0%0/1
$@ || 'unknown regex compile error'
$@
Truth table0%0/2
A
A= $@
Aresult
11
00
4612 0 die Zuzu::Error->new_runtime(
4613 message => "$message: $err",
4614 file => $file,
4615 line => $line,
4616 );
4617 }
4618 76 $self->{_regexp_cache}{$cache_key} = $regex;
4619  
4620 76 return $regex;
4621 }
4622  
4623 0 ▶sub _to_RegexpValue {
Subroutine _to_RegexpValue: not called CC=4 SCAR=30.0
4624 0 my ( $self, $value, $file, $line ) = @_;
4625  
4626 0 ▶ if ( blessed($value) and $value->isa('Zuzu::Value::Regexp') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($value) and $value->isa("Zuzu::Value::Regexp")) 0 0 0
Condition0%0/3
builtin::blessed($value) and $value->isa("Zuzu::Value::Regexp")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($value) and $value->isa("Zuzu::Value::Regexp")
builtin::blessed($value) $value->isa("Zuzu::Value::Regexp")
Truth table0%0/3
A and B
A= builtin::blessed($value)B= $value->isa("Zuzu::Value::Regexp")
ABresult
0X0
100
111
4627 0 ▶ my $pattern = $value->pattern // '';
Condition0%0/2
$value->pattern // ""
l!l
00
MC/DC0%0/1
$value->pattern // ""
$value->pattern
Truth table0%0/2
A
A= $value->pattern
Aresult
11
00
4628 0 my $mods = $self->_regexp_flags_to_modifiers( $value->flags );
4629 0 $self->_compile_regexp_pattern(
4630 $pattern,
4631 $mods,
4632 'literal',
4633 'Invalid regexp literal',
4634 $file,
4635 $line,
4636 );
4637  
4638 0 return $value;
4639 }
4640  
4641 0 my $pattern = $self->_to_OperatorString( $value, $file, $line );
4642 0 $self->_compile_regexp_pattern(
4643 $pattern,
4644 '',
4645 'plain',
4646 'Invalid regexp value',
4647 $file,
4648 $line,
4649 );
4650  
4651 0 return Zuzu::Value::Regexp->new( pattern => $pattern, flags => '' );
4652 }
4653  
4654 0 ▶sub _to_RegexpValue_with_flags {
Subroutine _to_RegexpValue_with_flags: not called CC=1 SCAR=6.9
4655 0 my ( $self, $value, $flags, $file, $line ) = @_;
4656  
4657 0 my $pattern = $self->_to_OperatorString( $value, $file, $line );
4658 0 $flags = $self->_to_OperatorString( $flags, $file, $line );
4659 0 my $mods = $self->_regexp_flags_to_modifiers($flags);
4660 0 $self->_compile_regexp_pattern(
4661 $pattern,
4662 $mods,
4663 'plain',
4664 'Invalid regexp value',
4665 $file,
4666 $line,
4667 );
4668  
4669 0 return Zuzu::Value::Regexp->new( pattern => $pattern, flags => $flags );
4670 }
4671  
4672 1133 ▶sub _regexp_is_global {
Subroutine _regexp_is_global: called CC=5 SCAR=18.6
4673 1133 my ( $self, $value ) = @_;
4674  
4675 1133 ▶ return 0 if ! blessed($value) or ! $value->isa('Zuzu::Value::Regexp');
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($value) and $value->isa("Zuzu::Value::Regexp") 0 1133 1133
Condition33%1/3
builtin::blessed($value) and $value->isa("Zuzu::Value::Regexp")
!ll&&!rl&&r
001133
MC/DC0%0/2
builtin::blessed($value) and $value->isa("Zuzu::Value::Regexp")
builtin::blessed($value) $value->isa("Zuzu::Value::Regexp")
Truth table33%1/3
A and B
A= builtin::blessed($value)B= $value->isa("Zuzu::Value::Regexp")
ABresult
0X0
100
111
4676 1133 ▶ my $flags = $value->flags // '';
Condition50%1/2
$value->flags // ""
l!l
11330
MC/DC0%0/1
$value->flags // ""
$value->flags
Truth table50%1/2
A
A= $value->flags
Aresult
11
00
4677  
4678 1133 ▶ return $flags =~ /g/ ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$flags =~ /g/ ? : 0 1133 1133
4679 }
4680  
4681 1 ▶sub _current_match_values {
Subroutine _current_match_values: called CC=6 SCAR=21.2
4682 1 my ( $self, $target ) = @_;
4683  
4684 1 my @captures = ();
4685 1 ▶ for ( my $i = 0; $i < scalar @-; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @-) 1 1 2
4686 1 ▶ if ( defined $-[$i] and defined $+[$i] and $-[$i] >= 0 and $+[$i] >= 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $-[$i] and defined $+[$i] and $-[$i] >= 0 and $+[$i] >= 0) { } 1 0 1
Condition33%3/9
defined $-[$i] and defined $+[$i] and $-[$i] >= 0 and $+[$i] >= 0
!ll&&!rl&&r
001
defined $-[$i] and defined $+[$i] and $-[$i] >= 0
!ll&&!rl&&r
001
defined $-[$i] and defined $+[$i]
!ll&&!rl&&r
001
MC/DC0%0/4
defined $-[$i] and defined $+[$i] and $-[$i] >= 0 and $+[$i] >= 0
defined $-[$i] defined $+[$i] $-[$i] >= 0 $+[$i] >= 0
Truth table20%1/5
A and B and C and D
A= defined $-[$i]B= defined $+[$i]C= $-[$i] >= 0D= $+[$i] >= 0
ABCDresult
0XXX0
10XX0
110X0
11100
11111
4687 1 push @captures, substr( $target, $-[$i], $+[$i] - $-[$i] );
4688 }
4689 else {
4690 0 push @captures, undef;
4691 }
4692 }
4693  
4694 1 return @captures;
4695 }
4696  
4697 1 ▶sub _evaluate_regexp_replace_expr {
Subroutine _evaluate_regexp_replace_expr: called CC=2 SCAR=6.9
4698 1 my ( $self, $replace_expr, $captures ) = @_;
4699  
4700 1 my $env = Zuzu::Env->_new_fast( $self->_env );
4701 1 $self->_push_env($env);
4702 1 $env->declare( 'm', Zuzu::Value::Array->new( items => $captures ), 1 );
4703 1 my $value;
4704 1 my $ok = eval {
4705 1 $value = $replace_expr->evaluate($self);
4706 1 1;
4707 };
4708 1 my $err = $@;
4709 1 $self->_pop_env;
4710 1 ▶ die $err if !$ok;
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 0 1 1
4711  
4712 1 return $self->_to_String($value);
4713 }
4714  
4715 1 ▶sub _regexp_replace_value {
Subroutine _regexp_replace_value: called CC=5 SCAR=16.8
4716 1 my ( $self, $target, $regex, $global, $replace_expr ) = @_;
4717  
4718 1 my $out = '';
4719 1 my $cursor = 0;
4720 1 ▶ while ( $target =~ /$regex/g ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target =~ /$regex/g) 1 0 1
4721 1 my $start = $-[0];
4722 1 my $end = $+[0];
4723 1 $out .= substr( $target, $cursor, $start - $cursor );
4724 1 my @captures = $self->_current_match_values($target);
4725 1 $out .= $self->_evaluate_regexp_replace_expr( $replace_expr, \@captures );
4726 1 $cursor = $end;
4727 1 ▶ last if !$global;
Branch: 1 branch
BranchTrueFalseTotal
unless $global 1 0 1
4728 }
4729 1 ▶ if ( $cursor == 0 and $target !~ /$regex/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cursor == 0 and not $target =~ /$regex/) 0 1 1
Condition33%1/3
$cursor == 0 and not $target =~ /$regex/
!ll&&!rl&&r
100
MC/DC0%0/2
$cursor == 0 and not $target =~ /$regex/
$cursor == 0 not $target =~ /$regex/
Truth table33%1/3
A and not(B)
A= $cursor == 0B= not $target =~ /$regex/
ABresult
0X0
100
111
4730 0 return $target;
4731 }
4732 1 $out .= substr( $target, $cursor );
4733  
4734 1 return $out;
4735 }
4736  
4737 1511 ▶sub eval_type_ref {
Subroutine eval_type_ref: called CC=5 SCAR=21.6
Pod undocumented
4738 1511 my ( $self, $node ) = @_;
4739  
4740 1511 my $ref = $self->_env->find_ref($node->root);
4741 1511 ▶ die Zuzu::Error->new_runtime(
Branch: 1 branch
BranchTrueFalseTotal
unless $ref 0 1511 1511
4742 message => "Unknown type root '".$node->root."'",
4743 file => $node->file,
4744 line => $node->line,
4745 ) if !$ref;
4746  
4747 1511 my $value = $$ref;
4748 1511 ▶ if ( defined $node->member ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $node->member) 0 1511 1511
4749 0 ▶ die Zuzu::Error->new_runtime(
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($value) and $value->isa("Zuzu::Value::Dict") 0 0 0
Condition0%0/3
builtin::blessed($value) and $value->isa("Zuzu::Value::Dict")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($value) and $value->isa("Zuzu::Value::Dict")
builtin::blessed($value) $value->isa("Zuzu::Value::Dict")
Truth table0%0/3
A and B
A= builtin::blessed($value)B= $value->isa("Zuzu::Value::Dict")
ABresult
0X0
100
111
4750 message => "Type root '".$node->root."' does not support member type access",
4751 file => $node->file,
4752 line => $node->line,
4753 ) if !blessed($value) or !$value->isa('Zuzu::Value::Dict');
4754 0 $value = $value->map->{ $node->member };
4755 }
4756  
4757 1511 return $value;
4758 }
4759  
4760 2458 ▶sub eval_call {
Subroutine eval_call: called CC=5 SCAR=16.8
Pod documented
4761 2458 my ($self, $node) = @_;
4762  
4763 2458 my $callee = $node->callee->evaluate($self);
4764 2458 ▶ my ( $positional, $named, $named_pairs ) = $self->_evaluate_invocation_args( $node->args // [] );
Condition50%1/2
$node->args // []
l!l
24580
MC/DC0%0/1
$node->args // []
$node->args
Truth table50%1/2
A
A= $node->args
Aresult
11
00
4765  
4766 2457 ▶ die Zuzu::Error->new_runtime(message => "Call target is not a function", file => $node->file, line => $node->line)
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($callee) and $callee->isa("Zuzu::Value::Function") 3 2454 2457
Condition66%2/3
builtin::blessed($callee) and $callee->isa("Zuzu::Value::Function")
!ll&&!rl&&r
302454
MC/DC50%1/2
builtin::blessed($callee) and $callee->isa("Zuzu::Value::Function")
builtin::blessed($callee) $callee->isa("Zuzu::Value::Function")
Truth table66%2/3
A and B
A= builtin::blessed($callee)B= $callee->isa("Zuzu::Value::Function")
ABresult
0X0
100
111
4767 if !blessed($callee) or !$callee->isa('Zuzu::Value::Function');
4768  
4769 2454 ▶ if ($callee->{_bound_self}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($callee->{"_bound_self"}) 0 2454 2454
4770 return $self->_call_method(
4771 $callee,
4772 $callee->{_bound_self},
4773 $positional,
4774 $named,
4775 $named_pairs,
4776 $node->file,
4777 $node->line,
4778 $node->{_arg_static_types},
4779 0 );
4780 }
4781  
4782 return $self->_call_function(
4783 $callee,
4784 $positional,
4785 $named,
4786 $named_pairs,
4787 $node->file,
4788 $node->line,
4789 $node->{_arg_static_types},
4790 2454 );
4791 }
4792  
4793 72088 ▶sub eval_member_call {
Subroutine eval_member_call: called CC=32 SCAR=43.6
Pod documented
4794 72088 my ($self, $node) = @_;
4795  
4796 72088 my $obj = $node->object->evaluate($self);
4797 72088 ▶ my ( $positional, $named, $named_pairs ) = $self->_evaluate_invocation_args( $node->args // [] );
Condition50%1/2
$node->args // []
l!l
720880
MC/DC0%0/1
$node->args // []
$node->args
Truth table50%1/2
A
A= $node->args
Aresult
11
00
4798 72087 my ( $array_like, $dict_like, $pairlist_like, $set_like, $bag_like )
4799 = $self->_builtin_collection_views($obj);
4800  
4801 72087 ▶ if (blessed($obj) and $obj->isa('Zuzu::Value::Object')) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($obj) and $obj->isa("Zuzu::Value::Object")) 54928 17159 72087
Condition66%2/3
builtin::blessed($obj) and $obj->isa("Zuzu::Value::Object")
!ll&&!rl&&r
01715954928
MC/DC50%1/2
builtin::blessed($obj) and $obj->isa("Zuzu::Value::Object")
builtin::blessed($obj) $obj->isa("Zuzu::Value::Object")
Truth table66%2/3
A and B
A= builtin::blessed($obj)B= $obj->isa("Zuzu::Value::Object")
ABresult
0X0
100
111
4802 54928 my $m = $self->_lookup_method($obj->class, $node->method, 0);
4803 54928 ▶ if ( $m ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($m) 54927 1 54928
4804 return $self->_call_method(
4805 $m,
4806 $obj,
4807 $positional,
4808 $named,
4809 $named_pairs,
4810 $node->file,
4811 $node->line,
4812 $node->{_arg_static_types},
4813 54927 );
4814 }
4815 1 ▶ if ( $array_like ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($array_like) 0 1 1
4816 0 ▶ die Zuzu::Error->new_runtime(message => "Named arguments are not supported for Array methods", file => $node->file, line => $node->line)
Branch: 1 branch
BranchTrueFalseTotal
if _named_pairs_count($named_pairs) 0 0 0
4817 if _named_pairs_count( $named_pairs );
4818 0 return $self->_array_method($array_like, $node->method, $positional, $node->file, $node->line);
4819 }
4820 1 ▶ if ( $dict_like ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dict_like) 0 1 1
4821 0 ▶ die Zuzu::Error->new_runtime(message => "Named arguments are not supported for Dict methods", file => $node->file, line => $node->line)
Branch: 1 branch
BranchTrueFalseTotal
if _named_pairs_count($named_pairs) 0 0 0
4822 if _named_pairs_count( $named_pairs );
4823 0 return $self->_dict_method($dict_like, $node->method, $positional, $node->file, $node->line);
4824 }
4825 1 ▶ if ( $pairlist_like ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pairlist_like) 0 1 1
4826 0 ▶ die Zuzu::Error->new_runtime(message => "Named arguments are not supported for PairList methods", file => $node->file, line => $node->line)
Branch: 1 branch
BranchTrueFalseTotal
if _named_pairs_count($named_pairs) 0 0 0
4827 if _named_pairs_count( $named_pairs );
4828 0 return $self->_pairlist_method( $pairlist_like, $node->method, $positional, $node->file, $node->line );
4829 }
4830 1 ▶ if ( $set_like ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($set_like) 0 1 1
4831 0 ▶ die Zuzu::Error->new_runtime(message => "Named arguments are not supported for Set methods", file => $node->file, line => $node->line)
Branch: 1 branch
BranchTrueFalseTotal
if _named_pairs_count($named_pairs) 0 0 0
4832 if _named_pairs_count( $named_pairs );
4833 0 return $self->_set_method($set_like, $node->method, $positional, $node->file, $node->line);
4834 }
4835 1 ▶ if ( $bag_like ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bag_like) 0 1 1
4836 0 ▶ die Zuzu::Error->new_runtime(message => "Named arguments are not supported for Bag methods", file => $node->file, line => $node->line)
Branch: 1 branch
BranchTrueFalseTotal
if _named_pairs_count($named_pairs) 0 0 0
4837 if _named_pairs_count( $named_pairs );
4838 0 return $self->_bag_method($bag_like, $node->method, $positional, $node->file, $node->line);
4839 }
4840 1 ▶ if ( my $fallback = $self->_call_missing_method_fallback(
Branch: 1 branch
BranchTrueFalseTotal
if (my $fallback = $self->_call_missing_method_fallback($obj, $node->method, $positional, $named_pairs, $node->file, $node->line, $node->{"_arg_static_types"})) 0 1 1
4841 $obj,
4842 $node->method,
4843 $positional,
4844 $named_pairs,
4845 $node->file,
4846 $node->line,
4847 $node->{_arg_static_types},
4848 ) ) {
4849 0 return $fallback->[0];
4850 }
4851 1 die Zuzu::Error->new_runtime(message => "Unknown method '".$node->method."'", file => $node->file, line => $node->line);
4852 }
4853  
4854 # Minimal method support for Array/Dict: expose a few methods like length/empty/clear/append
4855 17159 ▶ if ( $array_like ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($array_like) 9077 8082 17159
4856  
4857 9077 ▶ die Zuzu::Error->new_runtime(message => "Named arguments are not supported for Array methods", file => $node->file, line => $node->line)
Branch: 1 branch
BranchTrueFalseTotal
if _named_pairs_count($named_pairs) 0 9077 9077
4858 if _named_pairs_count( $named_pairs );
4859 9077 return $self->_array_method($array_like, $node->method, $positional, $node->file, $node->line);
4860 }
4861 8082 ▶ if ( $dict_like ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dict_like) 7694 388 8082
4862  
4863 7694 ▶ die Zuzu::Error->new_runtime(message => "Named arguments are not supported for Dict methods", file => $node->file, line => $node->line)
Branch: 1 branch
BranchTrueFalseTotal
if _named_pairs_count($named_pairs) 0 7694 7694
4864 if _named_pairs_count( $named_pairs );
4865 7694 return $self->_dict_method($dict_like, $node->method, $positional, $node->file, $node->line);
4866 }
4867 388 ▶ if ( $pairlist_like ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pairlist_like) 79 309 388
4868  
4869 79 ▶ die Zuzu::Error->new_runtime(message => "Named arguments are not supported for PairList methods", file => $node->file, line => $node->line)
Branch: 1 branch
BranchTrueFalseTotal
if _named_pairs_count($named_pairs) 0 79 79
4870 if _named_pairs_count( $named_pairs );
4871 79 return $self->_pairlist_method( $pairlist_like, $node->method, $positional, $node->file, $node->line );
4872 }
4873 309 ▶ if ( $set_like ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($set_like) 59 250 309
4874  
4875 59 ▶ die Zuzu::Error->new_runtime(message => "Named arguments are not supported for Set methods", file => $node->file, line => $node->line)
Branch: 1 branch
BranchTrueFalseTotal
if _named_pairs_count($named_pairs) 0 59 59
4876 if _named_pairs_count( $named_pairs );
4877 59 return $self->_set_method($set_like, $node->method, $positional, $node->file, $node->line);
4878 }
4879 250 ▶ if ( $bag_like ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bag_like) 43 207 250
4880  
4881 43 ▶ die Zuzu::Error->new_runtime(message => "Named arguments are not supported for Bag methods", file => $node->file, line => $node->line)
Branch: 1 branch
BranchTrueFalseTotal
if _named_pairs_count($named_pairs) 0 43 43
4882 if _named_pairs_count( $named_pairs );
4883 43 return $self->_bag_method($bag_like, $node->method, $positional, $node->file, $node->line);
4884 }
4885 207 ▶ if ( blessed($obj) and $obj->isa('Zuzu::Value::Task') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($obj) and $obj->isa("Zuzu::Value::Task")) 7 200 207
Condition66%2/3
builtin::blessed($obj) and $obj->isa("Zuzu::Value::Task")
!ll&&!rl&&r
02007
MC/DC50%1/2
builtin::blessed($obj) and $obj->isa("Zuzu::Value::Task")
builtin::blessed($obj) $obj->isa("Zuzu::Value::Task")
Truth table66%2/3
A and B
A= builtin::blessed($obj)B= $obj->isa("Zuzu::Value::Task")
ABresult
0X0
100
111
4886 my $m = $self->_lookup_method(
4887 $self->{_builtin_classes}{Task},
4888 7 $node->method,
4889 0,
4890 );
4891 7 ▶ die Zuzu::Error->new_runtime(message => "Unknown Task method '".$node->method."'", file => $node->file, line => $node->line) if !$m;
Branch: 1 branch
BranchTrueFalseTotal
unless $m 0 7 7
4892  
4893 return $self->_call_method(
4894 $m,
4895 $obj,
4896 $positional,
4897 $named,
4898 $named_pairs,
4899 $node->file,
4900 $node->line,
4901 $node->{_arg_static_types},
4902 7 );
4903 }
4904 200 ▶ if ( blessed($obj) and $obj->isa('Zuzu::Value::Class') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($obj) and $obj->isa("Zuzu::Value::Class")) 200 0 200
Condition33%1/3
builtin::blessed($obj) and $obj->isa("Zuzu::Value::Class")
!ll&&!rl&&r
00200
MC/DC0%0/2
builtin::blessed($obj) and $obj->isa("Zuzu::Value::Class")
builtin::blessed($obj) $obj->isa("Zuzu::Value::Class")
Truth table33%1/3
A and B
A= builtin::blessed($obj)B= $obj->isa("Zuzu::Value::Class")
ABresult
0X0
100
111
4905 200 my $m = $self->_lookup_method($obj, $node->method, 1);
4906 200 ▶ die Zuzu::Error->new_runtime(message => "Unknown static method '".$node->method."'", file => $node->file, line => $node->line) if !$m;
Branch: 1 branch
BranchTrueFalseTotal
unless $m 0 200 200
4907  
4908 return $self->_call_method(
4909 $m,
4910 $obj,
4911 $positional,
4912 $named,
4913 $named_pairs,
4914 $node->file,
4915 $node->line,
4916 $node->{_arg_static_types},
4917 200 );
4918 }
4919  
4920 0 die Zuzu::Error->new_runtime(message => "Unknown object type for member call", file => $node->file, line => $node->line);
4921 }
4922  
4923 0 ▶sub eval_dynamic_member_call {
Subroutine eval_dynamic_member_call: not called CC=7 SCAR=40.3
Pod undocumented
4924 0 my ( $self, $node ) = @_;
4925  
4926 0 my $method = $node->method_expr->evaluate($self);
4927 0 ▶ if ( blessed($method) and $method->isa('Zuzu::Value::Function') and $method->{_is_method} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($method) and $method->isa("Zuzu::Value::Function") and $method->{"_is_method"}) 0 0 0
Condition0%0/6
builtin::blessed($method) and $method->isa("Zuzu::Value::Function") and $method->{"_is_method"}
!ll&&!rl&&r
000
builtin::blessed($method) and $method->isa("Zuzu::Value::Function")
!ll&&!rl&&r
000
MC/DC0%0/3
builtin::blessed($method) and $method->isa("Zuzu::Value::Function") and $method->{"_is_method"}
builtin::blessed($method) $method->isa("Zuzu::Value::Function") $method->{"_is_method"}
Truth table0%0/4
A and B and C
A= builtin::blessed($method)B= $method->isa("Zuzu::Value::Function")C= $method->{"_is_method"}
ABCresult
0XX0
10X0
1100
1111
4928 0 my $obj = $node->object->evaluate($self);
4929 0 ▶ my ( $positional, $named, $named_pairs ) = $self->_evaluate_invocation_args( $node->args // [] );
Condition0%0/2
$node->args // []
l!l
00
MC/DC0%0/1
$node->args // []
$node->args
Truth table0%0/2
A
A= $node->args
Aresult
11
00
4930 0 ▶ die Zuzu::Error->new_runtime(message => "Dynamic Method call expects Object receiver", file => $node->file, line => $node->line)
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($obj) and $obj->isa("Zuzu::Value::Object") 0 0 0
Condition0%0/3
builtin::blessed($obj) and $obj->isa("Zuzu::Value::Object")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($obj) and $obj->isa("Zuzu::Value::Object")
builtin::blessed($obj) $obj->isa("Zuzu::Value::Object")
Truth table0%0/3
A and B
A= builtin::blessed($obj)B= $obj->isa("Zuzu::Value::Object")
ABresult
0X0
100
111
4931 if !blessed($obj) or !$obj->isa('Zuzu::Value::Object');
4932  
4933 return $self->_call_method(
4934 $method,
4935 $obj,
4936 $positional,
4937 $named,
4938 $named_pairs,
4939 $node->file,
4940 $node->line,
4941 $node->{_arg_static_types},
4942 0 );
4943 }
4944 0 $method = $self->_to_String($method);
4945 0 my $resolved = Zuzu::AST::Expr::MemberCall->new(
4946 file => $node->file,
4947 line => $node->line,
4948 object => $node->object,
4949 method => $method,
4950 args => $node->args,
4951 );
4952  
4953 0 return $self->eval_member_call($resolved);
4954 }
4955  
4956 5319 ▶sub eval_new {
Subroutine eval_new: called CC=11 SCAR=25.2
Pod documented
4957 5319 my ($self, $node) = @_;
4958  
4959 5319 my $class_val = $node->class_expr->evaluate($self);
4960 5319 ▶ die Zuzu::Error->new_runtime(message => "new expects a Class", file => $node->file, line => $node->line)
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($class_val) and $class_val->isa("Zuzu::Value::Class") 0 5319 5319
Condition33%1/3
builtin::blessed($class_val) and $class_val->isa("Zuzu::Value::Class")
!ll&&!rl&&r
005319
MC/DC0%0/2
builtin::blessed($class_val) and $class_val->isa("Zuzu::Value::Class")
builtin::blessed($class_val) $class_val->isa("Zuzu::Value::Class")
Truth table33%1/3
A and B
A= builtin::blessed($class_val)B= $class_val->isa("Zuzu::Value::Class")
ABresult
0X0
100
111
4961 if !blessed($class_val) or !$class_val->isa('Zuzu::Value::Class');
4962  
4963 5319 ▶ if ( @{ $node->traits // [] } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$node->traits // [];}) 1 5318 5319
Condition50%1/2
$node->traits // []
l!l
53190
MC/DC0%0/1
$node->traits // []
$node->traits
Truth table50%1/2
A
A= $node->traits
Aresult
11
00
4964 1 my @traits;
4965 1 ▶ for my $tref ( @{ $node->traits // [] } ) {
Condition50%1/2
$node->traits // []
l!l
10
MC/DC0%0/1
$node->traits // []
$node->traits
Truth table50%1/2
A
A= $node->traits
Aresult
11
00
4966 1 my $trait = $tref->evaluate($self);
4967 1 ▶ die Zuzu::Error->new_runtime(
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($trait) and $trait->isa("Zuzu::Value::Trait") 0 1 1
Condition33%1/3
builtin::blessed($trait) and $trait->isa("Zuzu::Value::Trait")
!ll&&!rl&&r
001
MC/DC0%0/2
builtin::blessed($trait) and $trait->isa("Zuzu::Value::Trait")
builtin::blessed($trait) $trait->isa("Zuzu::Value::Trait")
Truth table33%1/3
A and B
A= builtin::blessed($trait)B= $trait->isa("Zuzu::Value::Trait")
ABresult
0X0
100
111
4968 message => "Composed type is not a Trait",
4969 file => $node->file,
4970 line => $node->line,
4971 ) if !blessed($trait) or !$trait->isa('Zuzu::Value::Trait');
4972 1 push @traits, $trait;
4973 }
4974 1 $class_val = $self->_per_object_trait_class(
4975 $class_val,
4976 \@traits,
4977 $node->file,
4978 $node->line,
4979 );
4980 }
4981  
4982 5319 ▶ my ( $positional, $named ) = $self->_evaluate_invocation_args( $node->args // [] );
Condition50%1/2
$node->args // []
l!l
53190
MC/DC0%0/1
$node->args // []
$node->args
Truth table50%1/2
A
A= $node->args
Aresult
11
00
4983  
4984 5319 my $native_constructor = $self->_native_constructor_for( $class_val );
4985 5319 ▶ if ( $native_constructor ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($native_constructor) 61 5258 5319
4986 61 my $object = $native_constructor->(
4987 $self,
4988 $class_val,
4989 $positional,
4990 $named,
4991 $node->file,
4992 $node->line,
4993 );
4994 61 $self->_apply_declared_fields_to_native_object(
4995 $object,
4996 $class_val,
4997 $named,
4998 $node->file,
4999 $node->line,
5000 );
5001  
5002 61 return $self->_apply_object_lifecycle_hooks(
5003 $object,
5004 $class_val,
5005 $node->file,
5006 $node->line,
5007 );
5008 }
5009  
5010 5258 return $self->_make_instance(
5011 $class_val,
5012 $named,
5013 $node->file,
5014 $node->line,
5015 1,
5016 );
5017 }
5018  
5019 1 ▶sub _per_object_trait_class {
Subroutine _per_object_trait_class: called CC=7 SCAR=19.8
5020 1 my ( $self, $base_class, $traits, $file, $line ) = @_;
5021  
5022 1 ▶ my @ids = map { refaddr($_) // 0 } ( $base_class, @{ $traits // [] } );
Condition50%2/4
builtin::refaddr($_) // 0
l!l
20
$traits // []
l!l
10
MC/DC0%0/1
builtin::refaddr($_) // 0
builtin::refaddr($_)
MC/DC0%0/1
$traits // []
$traits
Truth table50%1/2
A
A= builtin::refaddr($_)
Aresult
11
00
Truth table50%1/2
A
A= $traits
Aresult
11
00
5023 1 my $cache_key = join "\x1f", @ids;
5024 return $self->{_per_object_trait_class_cache}{$cache_key}
5025 1 ▶ if exists $self->{_per_object_trait_class_cache}{$cache_key};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"_per_object_trait_class_cache"}{$cache_key} 0 1 1
5026  
5027 1 my $capture_env = Zuzu::Env->_new_fast( $self->_env );
5028 1 $capture_env->declare(
5029 '__zuzu_per_object_base',
5030 $base_class,
5031 1,
5032 'Class',
5033 );
5034 1 my @trait_refs;
5035 1 ▶ for my $i ( 0 .. $#{ $traits // [] } ) {
Condition50%1/2
$traits // []
l!l
10
MC/DC0%0/1
$traits // []
$traits
Truth table50%1/2
A
A= $traits
Aresult
11
00
5036 1 my $name = "__zuzu_per_object_trait_$i";
5037 1 $capture_env->declare( $name, $traits->[$i], 1, 'Trait' );
5038 1 push @trait_refs, Zuzu::AST::Expr::TypeRef->new(
5039 file => $file,
5040 line => $line,
5041 root => $name,
5042 member => undef,
5043 );
5044 }
5045  
5046 1 my $source_node = Zuzu::AST::Stmt::Class->new(
5047 file => $file,
5048 line => $line,
5049 name => $base_class->name,
5050 parent => Zuzu::AST::Expr::TypeRef->new(
5051 file => $file,
5052 line => $line,
5053 root => '__zuzu_per_object_base',
5054 member => undef,
5055 ),
5056 traits => \@trait_refs,
5057 fields => [],
5058 methods => [],
5059 static_methods => [],
5060 classes => [],
5061 );
5062  
5063 my $klass = Zuzu::Value::Class->new(
5064 name => $base_class->name,
5065 parent => $base_class,
5066 1 ▶ traits => [ @{ $traits // [] } ],
Condition50%1/2
$traits // []
l!l
10
MC/DC0%0/1
$traits // []
$traits
Truth table50%1/2
A
A= $traits
Aresult
11
00
5067 field_specs => [],
5068 methods => {},
5069 trait_methods => {},
5070 static_methods => {},
5071 nested_classes => {},
5072 closure_env => $capture_env,
5073 source_node => $source_node,
5074 );
5075 1 $self->_install_trait_methods_for_class( $klass, $traits );
5076  
5077 1 $self->{_per_object_trait_class_cache}{$cache_key} = $klass;
5078  
5079 1 return $klass;
5080 }
5081  
5082 5258 ▶sub _make_instance {
Subroutine _make_instance: called CC=9 SCAR=23.1
5083 5258 my ( $self, $class_val, $named, $file, $line, $call_build ) = @_;
5084  
5085 5258 my $native_constructor = $self->_native_constructor_for( $class_val );
5086 5258 ▶ die Zuzu::Error->new_runtime(
Branch: 1 branch
BranchTrueFalseTotal
if $native_constructor 0 5258 5258
5087 message => "make_instance cannot instantiate native class '" . $class_val->name . "'",
5088 file => $file,
5089 line => $line,
5090 ) if $native_constructor;
5091  
5092 5258 my ( $slots, $const, $types, $weak ) = $self->_instantiate_slots($class_val);
5093 5258 ▶ for my $k ( keys %{ $named // {} } ) {
Condition50%1/2
$named // {}
l!l
52580
MC/DC0%0/1
$named // {}
$named
Truth table50%1/2
A
A= $named
Aresult
11
00
5094 17572 ▶ my $declared_type = exists $types->{$k} ? $types->{$k} : 'Any';
Branch: 1 branch
BranchTrueFalseTotal
exists $types->{$k} ? : 17572 0 17572
5095 $self->_assert_declared_type(
5096 $declared_type,
5097 17572 $named->{$k},
5098 $file,
5099 $line,
5100 $k,
5101 );
5102 17572 ▶ $const->{$k} = 0 if !exists $const->{$k};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $const->{$k} 0 17572 17572
5103 17572 ▶ $types->{$k} = 'Any' if !exists $types->{$k};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $types->{$k} 0 17572 17572
5104 17572 ▶ $weak->{$k} = 0 if !exists $weak->{$k};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $weak->{$k} 0 17572 17572
5105 17572 store_value( \$slots->{$k}, $named->{$k}, $weak->{$k} );
5106 }
5107  
5108 5258 my $object = Zuzu::Value::Object->new(
5109 class => $class_val,
5110 slots => $slots,
5111 const => $const,
5112 types => $types,
5113 weak => $weak,
5114 );
5115  
5116 5258 $self->_install_object_demolish_hook( $object, $class_val, $file, $line );
5117 5258 ▶ $self->_call_object_build_hook( $object, $class_val, $file, $line )
Branch: 1 branch
BranchTrueFalseTotal
if $call_build 5258 0 5258
5118 if $call_build;
5119  
5120 5258 return $object;
5121 }
5122  
5123 0 ▶sub _make_instance_without_build {
Subroutine _make_instance_without_build: not called CC=3 SCAR=24.8
5124 0 my ( $self, $class_val, $named, $file, $line ) = @_;
5125  
5126 0 ▶ die Zuzu::Error->new_runtime(
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($class_val) and $class_val->isa("Zuzu::Value::Class") 0 0 0
Condition0%0/3
builtin::blessed($class_val) and $class_val->isa("Zuzu::Value::Class")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($class_val) and $class_val->isa("Zuzu::Value::Class")
builtin::blessed($class_val) $class_val->isa("Zuzu::Value::Class")
Truth table0%0/3
A and B
A= builtin::blessed($class_val)B= $class_val->isa("Zuzu::Value::Class")
ABresult
0X0
100
111
5127 message => "make_instance expects a Class",
5128 file => $file,
5129 line => $line,
5130 ) if !blessed($class_val) or !$class_val->isa('Zuzu::Value::Class');
5131  
5132 0 return $self->_make_instance(
5133 $class_val,
5134 $named,
5135 $file,
5136 $line,
5137 0,
5138 );
5139 }
5140  
5141 61 ▶sub _apply_declared_fields_to_native_object {
Subroutine _apply_declared_fields_to_native_object: called CC=10 SCAR=23.1
5142 61 my ( $self, $object, $class_val, $named, $file, $line ) = @_;
5143  
5144 61 ▶ return $object
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($object) and $object->isa("Zuzu::Value::Object") 11 50 61
Condition66%2/3
builtin::blessed($object) and $object->isa("Zuzu::Value::Object")
!ll&&!rl&&r
01150
MC/DC50%1/2
builtin::blessed($object) and $object->isa("Zuzu::Value::Object")
builtin::blessed($object) $object->isa("Zuzu::Value::Object")
Truth table66%2/3
A and B
A= builtin::blessed($object)B= $object->isa("Zuzu::Value::Object")
ABresult
0X0
100
111
5145 if !blessed($object) or !$object->isa('Zuzu::Value::Object');
5146  
5147 50 my ( $slots, $const, $types, $weak ) = $self->_instantiate_slots($class_val);
5148 50 ▶ return $object if !keys %{$slots};
Branch: 1 branch
BranchTrueFalseTotal
unless keys %{$slots;} 48 2 50
5149  
5150 2 for my $key ( keys %{$slots} ) {
5151 2 ▶ next if exists $object->slots->{$key};
Branch: 1 branch
BranchTrueFalseTotal
if exists $object->slots->{$key} 1 1 2
5152 1 $object->slots->{$key} = $slots->{$key};
5153 1 $object->const->{$key} = $const->{$key};
5154 1 $object->types->{$key} = $types->{$key};
5155 1 $object->weak->{$key} = $weak->{$key};
5156 }
5157  
5158 2 ▶ for my $key ( keys %{ $named // {} } ) {
Condition50%1/2
$named // {}
l!l
20
MC/DC0%0/1
$named // {}
$named
Truth table50%1/2
A
A= $named
Aresult
11
00
5159 4 ▶ next if !exists $slots->{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $slots->{$key} 2 2 4
5160 2 ▶ my $declared_type = exists $types->{$key} ? $types->{$key} : 'Any';
Branch: 1 branch
BranchTrueFalseTotal
exists $types->{$key} ? : 2 0 2
5161 $self->_assert_declared_type(
5162 $declared_type,
5163 2 $named->{$key},
5164 $file,
5165 $line,
5166 $key,
5167 );
5168 2 store_value( \$object->slots->{$key}, $named->{$key}, $object->weak->{$key} );
5169 }
5170  
5171 2 return $object;
5172 }
5173  
5174 5351 ▶sub _install_object_demolish_hook {
Subroutine _install_object_demolish_hook: called CC=4 SCAR=13.9
5175 5351 my ( $self, $object, $class_val, $file, $line ) = @_;
5176  
5177 5351 ▶ return $object
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($object) and $object->isa("Zuzu::Value::Object") 11 5340 5351
Condition66%2/3
builtin::blessed($object) and $object->isa("Zuzu::Value::Object")
!ll&&!rl&&r
0115340
MC/DC50%1/2
builtin::blessed($object) and $object->isa("Zuzu::Value::Object")
builtin::blessed($object) $object->isa("Zuzu::Value::Object")
Truth table66%2/3
A and B
A= builtin::blessed($object)B= $object->isa("Zuzu::Value::Object")
ABresult
0X0
100
111
5178 if !blessed($object) or !$object->isa('Zuzu::Value::Object');
5179  
5180 5340 my $demolish = $self->_lookup_method( $class_val, '__demolish__', 0 );
5181 5340 ▶ if ( $demolish ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($demolish) 4 5336 5340
5182 4 my $runtime = $self;
5183 4 weaken($runtime);
5184 $object->demolish_hook(
5185 4 ▶ sub {
Subroutine __ANON__: called CC=3 SCAR=11.2
5186 4 my ( $target ) = @_;
5187 4 ▶ return if !$runtime;
Branch: 1 branch
BranchTrueFalseTotal
unless $runtime 0 4 4
5188 4 local $@;
5189 4 ▶ eval {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $runtime->_call_method($demolish, $target, $Zuzu::Runtime::EMPTY_ARRAY, $Zuzu::Runtime::EMPTY_HASH, $Zuzu::Runtime::EMPTY_ARRAY, $file, $line); 1 } } or return 4 0 4
5190 4 $runtime->_call_method(
5191 $demolish,
5192 $target,
5193 $EMPTY_ARRAY,
5194 $EMPTY_HASH,
5195 $EMPTY_ARRAY,
5196 $file,
5197 $line,
5198 );
5199 4 1;
5200 } or return;
5201 4 return;
5202 }
5203 4 );
5204 4 push @{ $self->{_demolish_objects} }, $object;
5205 4 weaken( $self->{_demolish_objects}[-1] );
5206 }
5207  
5208 5340 return $object;
5209 }
5210  
5211 5351 ▶sub _call_object_build_hook {
Subroutine _call_object_build_hook: called CC=4 SCAR=13.9
5212 5351 my ( $self, $object, $class_val, $file, $line ) = @_;
5213  
5214 5351 ▶ return $object
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($object) and $object->isa("Zuzu::Value::Object") 11 5340 5351
Condition66%2/3
builtin::blessed($object) and $object->isa("Zuzu::Value::Object")
!ll&&!rl&&r
0115340
MC/DC50%1/2
builtin::blessed($object) and $object->isa("Zuzu::Value::Object")
builtin::blessed($object) $object->isa("Zuzu::Value::Object")
Truth table66%2/3
A and B
A= builtin::blessed($object)B= $object->isa("Zuzu::Value::Object")
ABresult
0X0
100
111
5215 if !blessed($object) or !$object->isa('Zuzu::Value::Object');
5216  
5217 5340 my $build = $self->_lookup_method( $class_val, '__build__', 0 );
5218 5340 ▶ if ( $build ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($build) 170 5170 5340
5219 170 $self->_call_method(
5220 $build,
5221 $object,
5222 $EMPTY_ARRAY,
5223 $EMPTY_HASH,
5224 $EMPTY_ARRAY,
5225 $file,
5226 $line,
5227 );
5228 }
5229  
5230 5340 return $object;
5231 }
5232  
5233 93 ▶sub _apply_object_lifecycle_hooks {
Subroutine _apply_object_lifecycle_hooks: called CC=1 SCAR=0.0
5234 93 my ( $self, $object, $class_val, $file, $line ) = @_;
5235  
5236 93 $self->_install_object_demolish_hook( $object, $class_val, $file, $line );
5237 93 $self->_call_object_build_hook( $object, $class_val, $file, $line );
5238  
5239 93 return $object;
5240 }
5241  
5242 79865 ▶sub _evaluate_invocation_args {
Subroutine _evaluate_invocation_args: called CC=39 SCAR=39.8
5243 79865 my ( $self, $entries ) = @_;
5244  
5245 79865 ▶ my $list = $entries // $EMPTY_ARRAY;
Condition33%1/3
$entries // $Zuzu::Runtime::EMPTY_ARRAY
l!l&&r!l&&!r
7986500
MC/DC0%0/2
$entries // $Zuzu::Runtime::EMPTY_ARRAY
$entries $Zuzu::Runtime::EMPTY_ARRAY
Truth table33%1/3
A // B
A= $entriesB= $Zuzu::Runtime::EMPTY_ARRAY
ABresult
1X1
011
000
5246 return ( $EMPTY_ARRAY, $EMPTY_HASH, $EMPTY_ARRAY )
5247 79865 ▶ if scalar @{ $list } == 0;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @{$list;} == 0 60202 19663 79865
5248  
5249 19663 my $simple_exprs;
5250 19663 ▶ my $simple_addr = refaddr($list) // 0;
Condition50%1/2
builtin::refaddr($list) // 0
l!l
196630
MC/DC0%0/1
builtin::refaddr($list) // 0
builtin::refaddr($list)
Truth table50%1/2
A
A= builtin::refaddr($list)
Aresult
11
00
5251 19663 ▶ my $simple_cache = $self->{_simple_invocation_arg_cache} //= {};
Condition100%2/2
$self->{"_simple_invocation_arg_cache"} //= {}
l!l
19434229
MC/DC100%1/1
$self->{"_simple_invocation_arg_cache"} //= {}
$self->{"_simple_invocation_arg_cache"}
Truth table100%2/2
A
A= $self->{"_simple_invocation_arg_cache"}
Aresult
11
00
5252 19663 my $simple_cached = $simple_cache->{$simple_addr};
5253 19663 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (defined $simple_cached and defined $simple_cached->[0] and builtin::refaddr($simple_cached->[0]) == $simple_addr) { } 11331 8332 19663
Condition66%4/6
defined $simple_cached and defined $simple_cached->[0] and builtin::refaddr($simple_cached->[0]) == $simple_addr
!ll&&!rl&&r
8332011331
defined $simple_cached and defined $simple_cached->[0]
!ll&&!rl&&r
8332011331
MC/DC33%1/3
defined $simple_cached and defined $simple_cached->[0] and builtin::refaddr($simple_cached->[0]) == $simple_addr
defined $simple_cached defined $simple_cached->[0] builtin::refaddr($simple_cached->[0]) == $simple_addr
Truth table50%2/4
A and B and C
A= defined $simple_cachedB= defined $simple_cached->[0]C= builtin::refaddr($simple_cached->[0]) == $simple_addr
ABCresult
0XX0
10X0
1100
1111
5254 defined $simple_cached
5255 and defined $simple_cached->[0]
5256 and refaddr( $simple_cached->[0] ) == $simple_addr
5257 ) {
5258 11331 $simple_exprs = $simple_cached->[1];
5259 }
5260 else {
5261 8332 my @exprs;
5262 8332 $simple_exprs = \@exprs;
5263 8332 for my $entry ( @{ $list } ) {
5264 10047 ▶ if ( ref($entry) ne 'ARRAY' or defined $entry->[0] or $entry->[2] ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $entry ne "ARRAY" or defined $entry->[0] or $entry->[2]) 5181 4866 10047
Condition83%5/6
ref $entry ne "ARRAY" or defined $entry->[0] or $entry->[2]
l!l&&r!l&&!r
518104866
ref $entry ne "ARRAY" or defined $entry->[0]
l!l&&r!l&&!r
13050514866
MC/DC66%2/3
ref $entry ne "ARRAY" or defined $entry->[0] or $entry->[2]
ref $entry ne "ARRAY" defined $entry->[0] $entry->[2]
Truth table75%3/4
A or B or C
A= ref $entry ne "ARRAY"B= defined $entry->[0]C= $entry->[2]
ABCresult
1XX1
01X1
0011
0000
5265 5181 $simple_exprs = 0;
5266 5181 last;
5267 }
5268 4866 my $expr = $entry->[1];
5269 4866 ▶ if ( blessed($expr) and $expr->isa('Zuzu::AST::Expr::Spread') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Spread")) 5 4861 4866
Condition66%2/3
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Spread")
!ll&&!rl&&r
048615
MC/DC50%1/2
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Spread")
builtin::blessed($expr) $expr->isa("Zuzu::AST::Expr::Spread")
Truth table66%2/3
A and B
A= builtin::blessed($expr)B= $expr->isa("Zuzu::AST::Expr::Spread")
ABresult
0X0
100
111
5270 5 $simple_exprs = 0;
5271 5 last;
5272 }
5273 4861 push @exprs, $expr;
5274 }
5275 8332 $simple_cache->{$simple_addr} = [ $list, $simple_exprs ];
5276 8332 weaken( $simple_cache->{$simple_addr}[0] );
5277 }
5278 19663 ▶ if ($simple_exprs) {
Branch: 1 branch
BranchTrueFalseTotal
if ($simple_exprs) 14272 5391 19663
5279 14272 my @positional;
5280 14272 push @positional, $_->evaluate($self) for @{ $simple_exprs };
5281 14271 return ( \@positional, $EMPTY_HASH, $EMPTY_ARRAY );
5282 }
5283  
5284 5391 my @positional;
5285 my $named;
5286 5391 my $named_pairs;
5287 5391 for my $entry ( @{ $list } ) {
5288 17831 my ( $name, $expr );
5289 17831 my $name_expr;
5290 17831 my $name_is_expr = 0;
5291 17831 ▶ if ( ref($entry) eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $entry eq 'ARRAY') { } 17660 171 17831
5292 17660 ( $name, $expr, $name_is_expr ) = @{ $entry };
5293 17660 ▶ $name_expr = $name if $name_is_expr;
Branch: 1 branch
BranchTrueFalseTotal
if $name_is_expr 0 17660 17660
5294 }
5295 else {
5296 171 $name = undef;
5297 171 $expr = $entry;
5298 }
5299 17831 ▶ if ( blessed($expr) and $expr->isa('Zuzu::AST::Expr::Spread') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Spread")) 6 17825 17831
Condition66%2/3
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Spread")
!ll&&!rl&&r
0178256
MC/DC50%1/2
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Spread")
builtin::blessed($expr) $expr->isa("Zuzu::AST::Expr::Spread")
Truth table66%2/3
A and B
A= builtin::blessed($expr)B= $expr->isa("Zuzu::AST::Expr::Spread")
ABresult
0X0
100
111
5300 6 my $value = $expr->expr->evaluate($self);
5301 6 my ( $array, $dict, $pairlist ) =
5302 $self->_builtin_collection_views($value);
5303 6 ▶ if ( $array ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($array) 2 4 6
5304 2 push @positional, $array->resolved_items;
5305 2 next;
5306 }
5307 4 ▶ if ( $dict ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dict) 0 4 4
5308 0 ▶ $named //= {};
Condition0%0/2
$named //= {}
l!l
00
MC/DC0%0/1
$named //= {}
$named
Truth table0%0/2
A
A= $named
Aresult
11
00
5309 0 ▶ $named_pairs //= [];
Condition0%0/2
$named_pairs //= []
l!l
00
MC/DC0%0/1
$named_pairs //= []
$named_pairs
Truth table0%0/2
A
A= $named_pairs
Aresult
11
00
5310 0 for my $key ( sort CORE::keys %{ $dict->map } ) {
5311 0 my $item = $dict->_value_for_key($key);
5312 0 $named->{$key} = $item;
5313 0 push @{ $named_pairs }, [ $key, $item ];
5314 }
5315 0 next;
5316 }
5317 4 ▶ if ( $pairlist ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pairlist) 3 1 4
5318 3 ▶ $named //= {};
Condition50%1/2
$named //= {}
l!l
03
MC/DC0%0/1
$named //= {}
$named
Truth table50%1/2
A
A= $named
Aresult
11
00
5319 3 ▶ $named_pairs //= [];
Condition50%1/2
$named_pairs //= []
l!l
03
MC/DC0%0/1
$named_pairs //= []
$named_pairs
Truth table50%1/2
A
A= $named_pairs
Aresult
11
00
5320 3 ▶ for ( my $i = 0; $i < @{ $pairlist->list }; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @{$pairlist->list;}) 7 3 10
5321 7 my $key = $pairlist->list->[$i][0];
5322 7 my $item = $pairlist->_value_at($i);
5323 7 $named->{$key} = $item;
5324 7 push @{ $named_pairs }, [ $key, $item ];
5325 }
5326 3 next;
5327 }
5328 1 my $type = $self->_type_name($value);
5329 1 die Zuzu::Error->new_runtime(
5330 message => "Spread argument expects Array, Dict, or PairList, got $type",
5331 file => $expr->file,
5332 line => $expr->line,
5333 );
5334 }
5335 17825 my $value = $expr->evaluate($self);
5336 17825 ▶ if ( $name_is_expr ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name_is_expr) 0 17825 17825
5337 0 ▶ $named //= {};
Condition0%0/2
$named //= {}
l!l
00
MC/DC0%0/1
$named //= {}
$named
Truth table0%0/2
A
A= $named
Aresult
11
00
5338 0 ▶ $named_pairs //= [];
Condition0%0/2
$named_pairs //= []
l!l
00
MC/DC0%0/1
$named_pairs //= []
$named_pairs
Truth table0%0/2
A
A= $named_pairs
Aresult
11
00
5339 0 my $key_value = $name_expr->evaluate($self);
5340 0 $name = $self->_to_String($key_value);
5341 }
5342 17825 ▶ if ( defined $name ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $name) { } 17643 182 17825
5343 17643 ▶ $named //= {};
Condition100%2/2
$named //= {}
l!l
124285215
MC/DC100%1/1
$named //= {}
$named
Truth table100%2/2
A
A= $named
Aresult
11
00
5344 17643 ▶ $named_pairs //= [];
Condition100%2/2
$named_pairs //= []
l!l
124285215
MC/DC100%1/1
$named_pairs //= []
$named_pairs
Truth table100%2/2
A
A= $named_pairs
Aresult
11
00
5345 17643 $named->{$name} = $value;
5346 17643 push @{ $named_pairs }, [ $name, $value ];
5347 }
5348 else {
5349 182 push @positional, $value;
5350 }
5351 }
5352  
5353 return (
5354 5390 ▶ ( scalar @positional ? \@positional : $EMPTY_ARRAY ),
Branch: 3 branches
BranchTrueFalseTotal
scalar @positional ? : 182 5208 5390
defined $named ? : 5218 172 5390
defined $named_pairs ? : 5218 172 5390
5355 ( defined $named ? $named : $EMPTY_HASH ),
5356 ( defined $named_pairs ? $named_pairs : $EMPTY_ARRAY ),
5357 );
5358 }
5359  
5360 10580 ▶sub _native_constructor_for {
Subroutine _native_constructor_for: called CC=3 SCAR=11.0
5361 10580 my ( $self, $klass ) = @_;
5362  
5363 10580 my $cur = $klass;
5364 10580 ▶ while ( $cur ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cur) 36230 10519 46749
5365 36230 ▶ return $cur->native_constructor if $cur->native_constructor;
Branch: 1 branch
BranchTrueFalseTotal
if $cur->native_constructor 61 36169 36230
5366 36169 $cur = $cur->parent;
5367 }
5368  
5369 10519 return undef;
5370 }
5371  
5372 83 ▶sub _instantiate_builtin_object {
Subroutine _instantiate_builtin_object: called CC=3 SCAR=11.0
5373 83 my ( $self, $klass, $slots ) = @_;
5374  
5375 83 my $base = Zuzu::Value::Object->new(
5376 class => $klass,
5377 slots => {},
5378 const => {},
5379 types => {},
5380 weak => {},
5381 );
5382 83 ▶ for my $key ( sort CORE::keys %{ $slots // {} } ) {
Condition50%1/2
$slots // {}
l!l
830
MC/DC0%0/1
$slots // {}
$slots
Truth table50%1/2
A
A= $slots
Aresult
11
00
5383 297 $base->slots->{$key} = $slots->{$key};
5384 297 $base->const->{$key} = 0;
5385 297 $base->types->{$key} = 'Any';
5386 297 $base->weak->{$key} = 0;
5387 }
5388  
5389 83 return $base;
5390 }
5391  
5392 14517 ▶sub _class_is_or_descends {
Subroutine _class_is_or_descends: called CC=5 SCAR=16.2
5393 14517 my ( $self, $klass, $target_name ) = @_;
5394  
5395 14517 ▶ return $FALSE if !defined $klass;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $klass 0 14517 14517
5396 14517 my $target = $self->{_builtin_classes}{$target_name};
5397 14517 ▶ return $FALSE if !defined $target;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $target 0 14517 14517
5398 14517 my $cur = $klass;
5399 14517 ▶ while ( $cur ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cur) 57871 14514 72385
5400 57871 ▶ return $TRUE if $cur == $target;
Branch: 1 branch
BranchTrueFalseTotal
if $cur == $target 3 57868 57871
5401 57868 $cur = $cur->parent;
5402 }
5403  
5404 14514 return $FALSE;
5405 }
5406  
5407 54949 ▶sub _collection_builtin_kind {
Subroutine _collection_builtin_kind: called CC=5 SCAR=16.1
5408 54949 my ( $self, $klass ) = @_;
5409  
5410 54949 ▶ while ($klass) {
Branch: 1 branch
BranchTrueFalseTotal
if ($klass) 216044 54948 270992
5411 216044 my $kind = $klass->{builtin_kind};
5412 216044 ▶ if ( defined $kind ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $kind) 23 216021 216044
5413 23 for my $collection_kind ( @BUILTIN_COLLECTION_KINDS ) {
5414 115 ▶ return $kind if $kind eq $collection_kind;
Branch: 1 branch
BranchTrueFalseTotal
if $kind eq $collection_kind 1 114 115
5415 }
5416 }
5417 216043 $klass = $klass->{parent};
5418 }
5419  
5420 54948 return undef;
5421 }
5422  
5423 118865 ▶sub _builtin_collection_views {
Subroutine _builtin_collection_views: called CC=15 SCAR=27.4
5424 118865 my ( $self, $value ) = @_;
5425  
5426 118865 my $class = ref($value);
5427 118865 ▶ if ($class) {
Branch: 1 branch
BranchTrueFalseTotal
if ($class) 94702 24163 118865
5428 94702 ▶ return ( $value, undef, undef, undef, undef )
Branch: 1 branch
BranchTrueFalseTotal
if $class eq "Zuzu::Value::Array" 9444 85258 94702
5429 if $class eq 'Zuzu::Value::Array';
5430 85258 ▶ return ( undef, $value, undef, undef, undef )
Branch: 1 branch
BranchTrueFalseTotal
if $class eq "Zuzu::Value::Dict" 8726 76532 85258
5431 if $class eq 'Zuzu::Value::Dict';
5432 76532 ▶ return ( undef, undef, $value, undef, undef )
Branch: 1 branch
BranchTrueFalseTotal
if $class eq "Zuzu::Value::PairList" 136 76396 76532
5433 if $class eq 'Zuzu::Value::PairList';
5434 76396 ▶ return ( undef, undef, undef, $value, undef )
Branch: 1 branch
BranchTrueFalseTotal
if $class eq "Zuzu::Value::Set" 106 76290 76396
5435 if $class eq 'Zuzu::Value::Set';
5436 76290 ▶ return ( undef, undef, undef, undef, $value )
Branch: 1 branch
BranchTrueFalseTotal
if $class eq "Zuzu::Value::Bag" 76 76214 76290
5437 if $class eq 'Zuzu::Value::Bag';
5438  
5439 76214 ▶ if ( $class eq 'Zuzu::Value::Object' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($class eq "Zuzu::Value::Object") 54949 21265 76214
5440 54949 my $kind = $self->_collection_builtin_kind( $value->{class} );
5441 54949 ▶ if ( defined $kind ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $kind) 1 54948 54949
5442 1 my $wrapped = $value->{slots}{__value};
5443 1 ▶ if ( ref($wrapped) eq "Zuzu::Value::$kind" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $wrapped eq "Zuzu::Value::$kind") 1 0 1
5444 1 ▶ return ( $wrapped, undef, undef, undef, undef ) if $kind eq 'Array';
Branch: 1 branch
BranchTrueFalseTotal
if $kind eq "Array" 0 1 1
5445 1 ▶ return ( undef, $wrapped, undef, undef, undef ) if $kind eq 'Dict';
Branch: 1 branch
BranchTrueFalseTotal
if $kind eq "Dict" 0 1 1
5446 1 ▶ return ( undef, undef, $wrapped, undef, undef ) if $kind eq 'PairList';
Branch: 1 branch
BranchTrueFalseTotal
if $kind eq "PairList" 0 1 1
5447 1 ▶ return ( undef, undef, undef, $wrapped, undef ) if $kind eq 'Set';
Branch: 1 branch
BranchTrueFalseTotal
if $kind eq "Set" 0 1 1
5448 1 ▶ return ( undef, undef, undef, undef, $wrapped ) if $kind eq 'Bag';
Branch: 1 branch
BranchTrueFalseTotal
if $kind eq "Bag" 1 0 1
5449 }
5450 }
5451 }
5452 }
5453  
5454 100376 return ( undef, undef, undef, undef, undef );
5455 }
5456  
5457 40837 ▶sub _unwrap_builtin_collection {
Subroutine _unwrap_builtin_collection: called CC=8 SCAR=23.4
5458 40837 my ( $self, $value, $kind ) = @_;
5459  
5460 40837 ▶ return $value if blessed($value) and $value->isa("Zuzu::Value::$kind");
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($value) and $value->isa("Zuzu::Value::$kind") 26050 14787 40837
Condition100%3/3
builtin::blessed($value) and $value->isa("Zuzu::Value::$kind")
!ll&&!rl&&r
341475326050
MC/DC100%2/2
builtin::blessed($value) and $value->isa("Zuzu::Value::$kind")
builtin::blessed($value) $value->isa("Zuzu::Value::$kind")
Truth table100%3/3
A and B
A= builtin::blessed($value)B= $value->isa("Zuzu::Value::$kind")
ABresult
0X0
100
111
5461 14787 ▶ if ( blessed($value) and $value->isa('Zuzu::Value::Object') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($value) and $value->isa("Zuzu::Value::Object")) 14504 283 14787
Condition100%3/3
builtin::blessed($value) and $value->isa("Zuzu::Value::Object")
!ll&&!rl&&r
3424914504
MC/DC100%2/2
builtin::blessed($value) and $value->isa("Zuzu::Value::Object")
builtin::blessed($value) $value->isa("Zuzu::Value::Object")
Truth table100%3/3
A and B
A= builtin::blessed($value)B= $value->isa("Zuzu::Value::Object")
ABresult
0X0
100
111
5462 14504 ▶ return undef if !$self->_class_is_or_descends( $value->class, $kind );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_class_is_or_descends($value->class, $kind) 14504 0 14504
5463 0 my $wrapped = $value->slots->{__value};
5464 0 ▶ return $wrapped if blessed($wrapped) and $wrapped->isa("Zuzu::Value::$kind");
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($wrapped) and $wrapped->isa("Zuzu::Value::$kind") 0 0 0
Condition0%0/3
builtin::blessed($wrapped) and $wrapped->isa("Zuzu::Value::$kind")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($wrapped) and $wrapped->isa("Zuzu::Value::$kind")
builtin::blessed($wrapped) $wrapped->isa("Zuzu::Value::$kind")
Truth table0%0/3
A and B
A= builtin::blessed($wrapped)B= $wrapped->isa("Zuzu::Value::$kind")
ABresult
0X0
100
111
5465 }
5466  
5467 283 return undef;
5468 }
5469  
5470 12 ▶sub _wrap_builtin_if_needed {
Subroutine _wrap_builtin_if_needed: called CC=3 SCAR=11.0
5471 12 my ( $self, $klass, $value, $kind ) = @_;
5472  
5473 12 my $base = $self->{_builtin_classes}{$kind};
5474 12 ▶ return $value if defined $base and $klass == $base;
Branch: 1 branch
BranchTrueFalseTotal
if defined $base and $klass == $base 11 1 12
Condition66%2/3
defined $base and $klass == $base
!ll&&!rl&&r
0111
MC/DC50%1/2
defined $base and $klass == $base
defined $base $klass == $base
Truth table66%2/3
A and B
A= defined $baseB= $klass == $base
ABresult
0X0
100
111
5475  
5476 1 return $self->_instantiate_builtin_object(
5477 $klass,
5478 {
5479 __value => $value,
5480 },
5481 );
5482 }
5483  
5484 3 ▶sub _normalize_pair_argument {
Subroutine _normalize_pair_argument: called CC=10 SCAR=29.6
5485 3 my ( $self, $pair, $file, $line, $kind ) = @_;
5486  
5487 3 ▶ if ( blessed($pair) and $pair->isa('Zuzu::Value::Object') and $self->_class_is_or_descends( $pair->class, 'Pair' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($pair) and $pair->isa("Zuzu::Value::Object") and $self->_class_is_or_descends($pair->class, "Pair")) 3 0 3
Condition33%2/6
builtin::blessed($pair) and $pair->isa("Zuzu::Value::Object") and $self->_class_is_or_descends($pair->class, "Pair")
!ll&&!rl&&r
030
builtin::blessed($pair) and $pair->isa("Zuzu::Value::Object")
!ll&&!rl&&r
003
MC/DC0%0/3
builtin::blessed($pair) and $pair->isa("Zuzu::Value::Object") and $self->_class_is_or_descends($pair->class, "Pair")
builtin::blessed($pair) $pair->isa("Zuzu::Value::Object") $self->_class_is_or_descends($pair->class, "Pair")
Truth table0%0/4
A and B and C
A= builtin::blessed($pair)B= $pair->isa("Zuzu::Value::Object")C= $self->_class_is_or_descends($pair->class, "Pair")
ABCresult
0XX0
10X0
1100
1111
5488 3 $pair = $pair->slots->{pair};
5489 }
5490 3 ▶ if ( blessed($pair) and $pair->isa('Zuzu::Value::Array') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($pair) and $pair->isa("Zuzu::Value::Array")) 3 0 3
Condition33%1/3
builtin::blessed($pair) and $pair->isa("Zuzu::Value::Array")
!ll&&!rl&&r
003
MC/DC0%0/2
builtin::blessed($pair) and $pair->isa("Zuzu::Value::Array")
builtin::blessed($pair) $pair->isa("Zuzu::Value::Array")
Truth table33%1/3
A and B
A= builtin::blessed($pair)B= $pair->isa("Zuzu::Value::Array")
ABresult
0X0
100
111
5491 3 $pair = [ @{ $pair->items } ];
5492 }
5493 die Zuzu::Error->new_runtime(
5494 message => ( $kind // 'Dict' ) . " constructor expects Pair values",
5495 file => $file,
5496 line => $line,
5497 3 ▶ ) if ref($pair) ne 'ARRAY' or @{ $pair } < 2;
Branch: 1 branch
BranchTrueFalseTotal
if ref $pair ne "ARRAY" or @{$pair;} < 2 0 3 3
Condition20%1/5
ref $pair ne "ARRAY" or @{$pair;} < 2
l!l&&r!l&&!r
003
$kind // "Dict"
l!l
00
MC/DC0%0/2
ref $pair ne "ARRAY" or @{$pair;} < 2
ref $pair ne "ARRAY" @{$pair;} < 2
MC/DC0%0/1
$kind // "Dict"
$kind
Truth table33%1/3
A or B
A= ref $pair ne "ARRAY"B= @{$pair;} < 2
ABresult
1X1
011
000
Truth table0%0/2
A
A= $kind
Aresult
11
00
5498  
5499 3 ▶ return [ ( defined $pair->[0] ? "$pair->[0]" : '' ), $pair->[1] ];
Branch: 1 branch
BranchTrueFalseTotal
defined $pair->[0] ? : 3 0 3
5500 }
5501  
5502 9077 ▶sub _array_method {
Subroutine _array_method: called CC=60 SCAR=45.4
5503 9077 my ($self, $arr, $m, $args, $file, $line) = @_;
5504 $self->_assert_mutable_collection( $arr, $file, $line )
5505 9077 ▶ if $ARRAY_MUTATING_METHOD{$m};
Branch: 1 branch
BranchTrueFalseTotal
if $ARRAY_MUTATING_METHOD{$m} 1161 7916 9077
5506  
5507 9076 ▶ if ($m eq 'append' || $m eq 'push' || $m eq 'add') { return $arr->push( @$args ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "append" or $m eq "push" or $m eq "add") 1143 7933 9076
Condition66%4/6
$m eq "append" or $m eq "push" or $m eq "add"
l!l&&r!l&&!r
114307933
$m eq "append" or $m eq "push"
l!l&&r!l&&!r
011437933
MC/DC33%1/3
$m eq "append" or $m eq "push" or $m eq "add"
$m eq "append" $m eq "push" $m eq "add"
Truth table50%2/4
A or B or C
A= $m eq "append"B= $m eq "push"C= $m eq "add"
ABCresult
1XX1
01X1
0011
0000
5508 7933 ▶ if ($m eq 'push_weak') { return $arr->push_weak( @$args ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "push_weak") 9 7924 7933
5509 0 ▶ if ($m eq 'pop') { return $arr->pop; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "pop") 0 7924 7924
5510 0 ▶ if ($m eq 'prepend' || $m eq 'unshift') { return $arr->unshift( @$args ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "prepend" or $m eq "unshift") 0 7924 7924
Condition33%1/3
$m eq "prepend" or $m eq "unshift"
l!l&&r!l&&!r
007924
MC/DC0%0/2
$m eq "prepend" or $m eq "unshift"
$m eq "prepend" $m eq "unshift"
Truth table33%1/3
A or B
A= $m eq "prepend"B= $m eq "unshift"
ABresult
1X1
011
000
5511 7924 ▶ if ($m eq 'unshift_weak') { return $arr->unshift_weak( @$args ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "unshift_weak") 1 7923 7924
5512 0 ▶ if ($m eq 'shift') { return $arr->shift; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "shift") 0 7923 7923
5513 7923 ▶ if ($m eq 'length') { return $arr->length; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "length") 7630 293 7923
5514 0 ▶ if ($m eq 'count') { return $arr->count; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "count") 0 293 293
5515 293 ▶ if ($m eq 'empty') { return $arr->empty; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "empty") 22 271 293
5516 0 ▶ if ($m eq 'is_empty') { return $arr->is_empty; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "is_empty") 0 271 271
5517 271 ▶ if ($m eq 'copy') { return $arr->copy; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "copy") 5 266 271
5518 0 ▶ if ($m eq 'to_Array') { return $arr->to_Array; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "to_Array") 0 266 266
5519 266 ▶ if ($m eq 'get') { return $self->_array_get( $arr, $args, $file, $line ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "get") 1 265 266
5520 265 ▶ if ($m eq 'set') { return $self->_array_set( $arr, $args, $file, $line, 0 ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "set") 2 263 265
5521 263 ▶ if ($m eq 'set_weak') { return $self->_array_set( $arr, $args, $file, $line, 1 ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "set_weak") 1 262 263
5522 0 ▶ if ($m eq 'clear') { return $arr->clear; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "clear") 0 262 262
5523 0 ▶ if ($m eq 'join') { return $self->_array_join( $arr, $args, $file, $line ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "join") 0 262 262
5524 0 ▶ if ($m eq 'slice') { return $self->_array_slice( $arr, $args, $file, $line ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "slice") 0 262 262
5525 0 ▶ if ($m eq 'to_Set') { return $arr->to_Set; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "to_Set") 0 262 262
5526 262 ▶ if ($m eq 'to_Bag') { return $arr->to_Bag; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "to_Bag") 3 259 262
5527 259 ▶ if ($m eq 'to_Iterator') {
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "to_Iterator") 0 259 259
5528 0 return $self->_iterator_function_from_items(
5529 [ $arr->resolved_items ],
5530 $file,
5531 $line,
5532 );
5533 }
5534 259 ▶ if ($m eq 'sort') { return $arr->sort( $self->_as_compare_callback( $args->[0], $file, $line ) ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "sort") 27 232 259
5535 232 ▶ if ($m eq 'sortstr') { return $arr->sortstr; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "sortstr") 1 231 232
5536 231 ▶ if ($m eq 'sortnum') { return $arr->sortnum; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "sortnum") 1 230 231
5537 230 ▶ if ($m eq 'reverse') { return $arr->reverse; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "reverse") 1 229 230
5538 229 ▶ if ($m eq 'head') {
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "head") 0 229 229
5539 0 $self->_require_method_arity_range( 'Array.head', $args, 0, 1, $file, $line );
5540 0 return $arr->head( $args->[0] );
5541 }
5542 229 ▶ if ($m eq 'tail') {
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "tail") 0 229 229
5543 0 $self->_require_method_arity_range( 'Array.tail', $args, 0, 1, $file, $line );
5544 0 return $arr->tail( $args->[0] );
5545 }
5546 0 ▶ if ($m eq 'sum') { return $arr->sum; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "sum") 0 229 229
5547 0 ▶ if ($m eq 'product') { return $arr->product; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "product") 0 229 229
5548 0 ▶ if ($m eq 'shuffle') { return $arr->shuffle; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "shuffle") 0 229 229
5549 229 ▶ if ($m eq 'sample') {
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "sample") 0 229 229
5550 0 $self->_require_method_arity_range( 'Array.sample', $args, 0, 1, $file, $line );
5551 0 return $arr->sample( $args->[0] );
5552 }
5553 229 ▶ if ($m eq 'contains') { return $arr->contains( $args->[0] ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "contains") 2 227 229
5554 227 ▶ if ($m eq 'map' || $m eq 'grep' || $m eq 'any' || $m eq 'all' || $m eq 'first' || $m eq 'remove' || $m eq 'first_index' || $m eq 'for_each_value') {
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "map" or $m eq "grep" or $m eq "any" or $m eq "all" or $m eq "first" or $m eq "remove" or $m eq "first_index" or $m eq "for_each_value") 224 3 227
Condition95%20/21
$m eq "map" or $m eq "grep" or $m eq "any" or $m eq "all" or $m eq "first" or $m eq "remove" or $m eq "first_index" or $m eq "for_each_value"
l!l&&r!l&&!r
22313
$m eq "map" or $m eq "grep" or $m eq "any" or $m eq "all" or $m eq "first" or $m eq "remove" or $m eq "first_index"
l!l&&r!l&&!r
22304
$m eq "map" or $m eq "grep" or $m eq "any" or $m eq "all" or $m eq "first" or $m eq "remove"
l!l&&r!l&&!r
21944
$m eq "map" or $m eq "grep" or $m eq "any" or $m eq "all" or $m eq "first"
l!l&&r!l&&!r
421778
$m eq "map" or $m eq "grep" or $m eq "any" or $m eq "all"
l!l&&r!l&&!r
411185
$m eq "map" or $m eq "grep" or $m eq "any"
l!l&&r!l&&!r
401186
$m eq "map" or $m eq "grep"
l!l&&r!l&&!r
1228187
MC/DC87%7/8
$m eq "map" or $m eq "grep" or $m eq "any" or $m eq "all" or $m eq "first" or $m eq "remove" or $m eq "first_index" or $m eq "for_each_value"
$m eq "map" $m eq "grep" $m eq "any" $m eq "all" $m eq "first" $m eq "remove" $m eq "first_index" $m eq "for_each_value"
Truth table88%8/9
A or B or C or D or E or F or G or H
A= $m eq "map"B= $m eq "grep"C= $m eq "any"D= $m eq "all"E= $m eq "first"F= $m eq "remove"G= $m eq "first_index"H= $m eq "for_each_value"
ABCDEFGHresult
1XXXXXXX1
01XXXXXX1
001XXXXX1
0001XXXX1
00001XXX1
000001XX1
0000001X1
000000011
000000000
5555 224 ▶ $self->_require_method_arity( "Array.$m", $args, 1, $file, $line )
Branch: 1 branch
BranchTrueFalseTotal
if $m eq "map" or $m eq "grep" or $m eq "any" or $m eq "all" or $m eq "first" 219 5 224
Condition100%12/12
$m eq "map" or $m eq "grep" or $m eq "any" or $m eq "all" or $m eq "first"
l!l&&r!l&&!r
421775
$m eq "map" or $m eq "grep" or $m eq "any" or $m eq "all"
l!l&&r!l&&!r
411182
$m eq "map" or $m eq "grep" or $m eq "any"
l!l&&r!l&&!r
401183
$m eq "map" or $m eq "grep"
l!l&&r!l&&!r
1228184
MC/DC100%5/5
$m eq "map" or $m eq "grep" or $m eq "any" or $m eq "all" or $m eq "first"
$m eq "map" $m eq "grep" $m eq "any" $m eq "all" $m eq "first"
Truth table100%6/6
A or B or C or D or E
A= $m eq "map"B= $m eq "grep"C= $m eq "any"D= $m eq "all"E= $m eq "first"
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
5556 if $m eq 'map' || $m eq 'grep' || $m eq 'any' || $m eq 'all' || $m eq 'first';
5557 224 ▶ return $arr->map( $self->_as_mapper_callback( $args->[0], $file, $line ) ) if $m eq 'map';
Branch: 1 branch
BranchTrueFalseTotal
if $m eq "map" 12 212 224
5558 212 my $cb = $self->_as_predicate_callback( $args->[0], $file, $line );
5559 212 ▶ return $arr->grep($cb) if $m eq 'grep';
Branch: 1 branch
BranchTrueFalseTotal
if $m eq "grep" 28 184 212
5560 184 ▶ return $arr->any($cb) if $m eq 'any';
Branch: 1 branch
BranchTrueFalseTotal
if $m eq "any" 1 183 184
5561 183 ▶ return $arr->all($cb) if $m eq 'all';
Branch: 1 branch
BranchTrueFalseTotal
if $m eq "all" 1 182 183
5562 182 ▶ return $arr->first($cb) if $m eq 'first';
Branch: 1 branch
BranchTrueFalseTotal
if $m eq "first" 177 5 182
5563 5 ▶ return $arr->first_index($cb) if $m eq 'first_index';
Branch: 1 branch
BranchTrueFalseTotal
if $m eq "first_index" 0 5 5
5564 5 ▶ return $arr->for_each_value($cb) if $m eq 'for_each_value';
Branch: 1 branch
BranchTrueFalseTotal
if $m eq "for_each_value" 1 4 5
5565 4 return $arr->remove($cb);
5566 }
5567 3 ▶ if ($m eq 'reduce' || $m eq 'reductions') {
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "reduce" or $m eq "reductions") 3 0 3
Condition66%2/3
$m eq "reduce" or $m eq "reductions"
l!l&&r!l&&!r
210
MC/DC0%0/2
$m eq "reduce" or $m eq "reductions"
$m eq "reduce" $m eq "reductions"
Truth table66%2/3
A or B
A= $m eq "reduce"B= $m eq "reductions"
ABresult
1X1
011
000
5568 3 my $cb = $self->_as_reducer_callback( $args->[0], $file, $line );
5569 3 ▶ return $arr->reduce($cb) if $m eq 'reduce';
Branch: 1 branch
BranchTrueFalseTotal
if $m eq "reduce" 2 1 3
5570 1 return $arr->reductions($cb);
5571 }
5572 0 die Zuzu::Error->new_runtime(message => "Unsupported Array method '$m' (skeleton)", file => $file, line => $line);
5573 }
5574  
5575 7694 ▶sub _dict_method {
Subroutine _dict_method: called CC=32 SCAR=35.8
5576 7694 my ($self, $d, $m, $args, $file, $line) = @_;
5577 $self->_assert_mutable_collection( $d, $file, $line )
5578 7694 ▶ if $DICT_MUTATING_METHOD{$m};
Branch: 1 branch
BranchTrueFalseTotal
if $DICT_MUTATING_METHOD{$m} 6624 1070 7694
5579  
5580 7693 ▶ if ($m eq 'keys') {
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "keys") 66 7627 7693
5581 66 return $d->keys;
5582 }
5583 7627 ▶ if ($m eq 'values') { return $d->values; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "values") 1 7626 7627
5584 0 ▶ if ($m eq 'enumerate') { return $self->_dict_enumerate($d); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "enumerate") 0 7626 7626
5585 7626 ▶ if ($m eq 'has') { return $d->contains_key( $args->[0] ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "has") 1 7625 7626
5586 0 ▶ if ($m eq 'contains') { return $d->contains( $args->[0] ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "contains") 0 7625 7625
5587 7625 ▶ if ($m eq 'exists') { return $d->exists( $args->[0] ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "exists") 657 6968 7625
5588 6968 ▶ if ($m eq 'defined') { return $d->defined( $args->[0] ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "defined") 33 6935 6968
5589 6935 ▶ if ($m eq 'copy') { return $d->copy; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "copy") 5 6930 6935
5590 6930 ▶ if ($m eq 'get') { return $d->get( @$args ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "get") 261 6669 6930
5591 6669 ▶ if ($m eq 'add') { return $d->add( @$args ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "add") 1 6668 6669
5592 6668 ▶ if ($m eq 'add_weak') { return $d->add_weak( @$args ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "add_weak") 1 6667 6668
5593 6667 ▶ if ($m eq 'set') { return $d->set( @$args ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "set") 6614 53 6667
5594 53 ▶ if ($m eq 'set_weak') { return $d->set_weak( @$args ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "set_weak") 5 48 53
5595 48 ▶ if ($m eq 'kv') { return $d->kv; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "kv") 1 47 48
5596 47 ▶ if ($m eq 'sorted_keys') { return $d->sorted_keys; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "sorted_keys") 4 43 47
5597 43 ▶ if ($m eq 'remove') {
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "remove") 1 42 43
5598 1 ▶ if ( blessed($args->[0]) and $args->[0]->isa('Zuzu::Value::Function') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($args->[0]) and $args->[0]->isa("Zuzu::Value::Function")) 0 1 1
Condition33%1/3
builtin::blessed($args->[0]) and $args->[0]->isa("Zuzu::Value::Function")
!ll&&!rl&&r
100
MC/DC0%0/2
builtin::blessed($args->[0]) and $args->[0]->isa("Zuzu::Value::Function")
builtin::blessed($args->[0]) $args->[0]->isa("Zuzu::Value::Function")
Truth table33%1/3
A and B
A= builtin::blessed($args->[0])B= $args->[0]->isa("Zuzu::Value::Function")
ABresult
0X0
100
111
5599 0 my $cb = $self->_as_predicate_callback( $args->[0], $file, $line );
5600 0 ▶ return $d->remove( sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
5601 0 my ( $pair ) = @_;
5602 0 return $cb->( $self->_make_pair_object( $pair->[0], $pair->[1] ) );
5603 0 } );
5604 }
5605 1 return $d->remove( $args->[0] );
5606 }
5607 42 ▶ if ($m eq 'length') { return $d->length; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "length") 7 35 42
5608 0 ▶ if ($m eq 'count') { return $d->count; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "count") 0 35 35
5609 0 ▶ if ($m eq 'empty') { return $d->empty; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "empty") 0 35 35
5610 0 ▶ if ($m eq 'is_empty') { return $d->is_empty; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "is_empty") 0 35 35
5611 35 ▶ if ($m eq 'clear') { return $d->clear; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "clear") 1 34 35
5612 34 ▶ if ($m eq 'to_Array') { return $self->_dict_to_array($d); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "to_Array") 1 33 34
5613 33 ▶ if ($m eq 'to_Iterator') {
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "to_Iterator") 0 33 33
5614 return $self->_iterator_function_from_items(
5615 0 [ sort CORE::keys %{ $d->map } ],
5616 $file,
5617 $line,
5618 );
5619 }
5620 33 ▶ if ($m eq 'for_each_pair' || $m eq 'for_each_key' || $m eq 'for_each_value') {
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "for_each_pair" or $m eq "for_each_key" or $m eq "for_each_value") 3 30 33
Condition100%6/6
$m eq "for_each_pair" or $m eq "for_each_key" or $m eq "for_each_value"
l!l&&r!l&&!r
2130
$m eq "for_each_pair" or $m eq "for_each_key"
l!l&&r!l&&!r
1131
MC/DC100%3/3
$m eq "for_each_pair" or $m eq "for_each_key" or $m eq "for_each_value"
$m eq "for_each_pair" $m eq "for_each_key" $m eq "for_each_value"
Truth table100%4/4
A or B or C
A= $m eq "for_each_pair"B= $m eq "for_each_key"C= $m eq "for_each_value"
ABCresult
1XX1
01X1
0011
0000
5621 3 my $cb = $self->_as_mapper_callback( $args->[0], $file, $line );
5622 4 ▶ return $d->for_each_pair( sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
5623 4 my ( $pair ) = @_;
5624 4 return $cb->( $self->_make_pair_object( $pair->[0], $pair->[1] ) );
5625 3 ▶ } ) if $m eq 'for_each_pair';
Branch: 1 branch
BranchTrueFalseTotal
if $m eq "for_each_pair" 1 2 3
5626 2 ▶ return $d->for_each_key($cb) if $m eq 'for_each_key';
Branch: 1 branch
BranchTrueFalseTotal
if $m eq "for_each_key" 1 1 2
5627 1 return $d->for_each_value($cb);
5628 }
5629 30 die Zuzu::Error->new_runtime(message => "Unsupported Dict method '$m' (skeleton)", file => $file, line => $line);
5630 }
5631  
5632 79 ▶sub _pairlist_method {
Subroutine _pairlist_method: called CC=33 SCAR=41.8
5633 79 my ( $self, $pairlist, $m, $args, $file, $line ) = @_;
5634 $self->_assert_mutable_collection( $pairlist, $file, $line )
5635 79 ▶ if $DICT_MUTATING_METHOD{$m};
Branch: 1 branch
BranchTrueFalseTotal
if $DICT_MUTATING_METHOD{$m} 16 63 79
5636  
5637 79 ▶ if ( $m eq 'keys' ) { return $pairlist->keys; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "keys") 4 75 79
5638 75 ▶ if ( $m eq 'values' ) { return $pairlist->values; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "values") 1 74 75
5639 0 ▶ if ( $m eq 'enumerate' ) { return $self->_pairlist_enumerate($pairlist); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "enumerate") 0 74 74
5640 0 ▶ if ( $m eq 'has' ) { return $pairlist->contains_key( $args->[0] ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "has") 0 74 74
5641 74 ▶ if ( $m eq 'exists' ) { return $pairlist->exists( $args->[0] ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "exists") 3 71 74
5642 71 ▶ if ( $m eq 'defined' ) { return $pairlist->defined( $args->[0] ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "defined") 1 70 71
5643 70 ▶ if ( $m eq 'copy' ) { return $pairlist->copy; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "copy") 6 64 70
5644 64 ▶ if ( $m eq 'get' ) { return $pairlist->get( @{ $args } ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "get") 31 33 64
5645 33 ▶ if ( $m eq 'get_all' or $m eq 'all' ) { return $pairlist->get_all( $args->[0] ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "get_all" or $m eq "all") 9 24 33
Condition66%2/3
$m eq "get_all" or $m eq "all"
l!l&&r!l&&!r
9024
MC/DC50%1/2
$m eq "get_all" or $m eq "all"
$m eq "get_all" $m eq "all"
Truth table66%2/3
A or B
A= $m eq "get_all"B= $m eq "all"
ABresult
1X1
011
000
5646 24 ▶ if ( $m eq 'add' ) { return $pairlist->add( @{ $args } ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "add") 8 16 24
5647 16 ▶ if ( $m eq 'add_weak' ) { return $pairlist->add_weak( @{ $args } ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "add_weak") 5 11 16
5648 0 ▶ if ( $m eq 'set' ) { return $pairlist->set( @{ $args } ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "set") 0 11 11
5649 11 ▶ if ( $m eq 'set_weak' ) { return $pairlist->set_weak( @{ $args } ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "set_weak") 1 10 11
5650 0 ▶ if ( $m eq 'kv' ) { return $pairlist->kv; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "kv") 0 10 10
5651 0 ▶ if ( $m eq 'sorted_keys' ) { return $pairlist->sorted_keys; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "sorted_keys") 0 10 10
5652 10 ▶ if ( $m eq 'remove' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "remove") 2 8 10
5653 2 ▶ if ( blessed( $args->[0] ) and $args->[0]->isa('Zuzu::Value::Function') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($args->[0]) and $args->[0]->isa("Zuzu::Value::Function")) 0 2 2
Condition33%1/3
builtin::blessed($args->[0]) and $args->[0]->isa("Zuzu::Value::Function")
!ll&&!rl&&r
200
MC/DC0%0/2
builtin::blessed($args->[0]) and $args->[0]->isa("Zuzu::Value::Function")
builtin::blessed($args->[0]) $args->[0]->isa("Zuzu::Value::Function")
Truth table33%1/3
A and B
A= builtin::blessed($args->[0])B= $args->[0]->isa("Zuzu::Value::Function")
ABresult
0X0
100
111
5654 0 my $cb = $self->_as_predicate_callback( $args->[0], $file, $line );
5655 0 ▶ return $pairlist->remove( sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
5656 0 my ( $pair ) = @_;
5657 0 return $cb->( $self->_make_pair_object( $pair->[0], $pair->[1] ) );
5658 0 } );
5659 }
5660 2 return $pairlist->remove( $args->[0] );
5661 }
5662 8 ▶ if ( $m eq 'length' ) { return $pairlist->length; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "length") 6 2 8
5663 0 ▶ if ( $m eq 'count' ) { return $pairlist->count; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "count") 0 2 2
5664 0 ▶ if ( $m eq 'empty' ) { return $pairlist->empty; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "empty") 0 2 2
5665 0 ▶ if ( $m eq 'is_empty' ) { return $pairlist->is_empty; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "is_empty") 0 2 2
5666 0 ▶ if ( $m eq 'clear' ) { return $pairlist->clear; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "clear") 0 2 2
5667 2 ▶ if ( $m eq 'to_Array' ) { return $self->_pairlist_to_array($pairlist); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "to_Array") 1 1 2
5668 1 ▶ if ( $m eq 'to_Iterator' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "to_Iterator") 0 1 1
5669 return $self->_iterator_function_from_items(
5670 0 [ map { $_->[0] } @{ $pairlist->list } ],
5671 $file,
5672 $line,
5673 );
5674 }
5675 1 ▶ if ( $m eq 'for_each_pair' or $m eq 'for_each_key' or $m eq 'for_each_value' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "for_each_pair" or $m eq "for_each_key" or $m eq "for_each_value") 1 0 1
Condition33%2/6
$m eq "for_each_pair" or $m eq "for_each_key" or $m eq "for_each_value"
l!l&&r!l&&!r
100
$m eq "for_each_pair" or $m eq "for_each_key"
l!l&&r!l&&!r
100
MC/DC0%0/3
$m eq "for_each_pair" or $m eq "for_each_key" or $m eq "for_each_value"
$m eq "for_each_pair" $m eq "for_each_key" $m eq "for_each_value"
Truth table25%1/4
A or B or C
A= $m eq "for_each_pair"B= $m eq "for_each_key"C= $m eq "for_each_value"
ABCresult
1XX1
01X1
0011
0000
5676 1 my $cb = $self->_as_mapper_callback( $args->[0], $file, $line );
5677 2 ▶ return $pairlist->for_each_pair( sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
5678 2 my ( $pair ) = @_;
5679 2 return $cb->( $self->_make_pair_object( $pair->[0], $pair->[1] ) );
5680 1 ▶ } ) if $m eq 'for_each_pair';
Branch: 1 branch
BranchTrueFalseTotal
if $m eq "for_each_pair" 1 0 1
5681 0 ▶ return $pairlist->for_each_key($cb) if $m eq 'for_each_key';
Branch: 1 branch
BranchTrueFalseTotal
if $m eq "for_each_key" 0 0 0
5682 0 return $pairlist->for_each_value($cb);
5683 }
5684 0 die Zuzu::Error->new_runtime(message => "Unsupported PairList method '$m'", file => $file, line => $line);
5685 }
5686  
5687 0 ▶sub _dict_enumerate {
Subroutine _dict_enumerate: not called CC=2 SCAR=17.9
5688 0 my ( $self, $dict ) = @_;
5689  
5690 0 my @pair_objects;
5691 0 for my $key ( sort CORE::keys %{ $dict->map } ) {
5692 0 my $value = $dict->get($key);
5693 0 push @pair_objects, $self->_make_pair_object( $key, $value );
5694 }
5695  
5696 0 return Zuzu::Value::Bag->new( items => \@pair_objects );
5697 }
5698  
5699 222 ▶sub _require_method_arity {
Subroutine _require_method_arity: called CC=3 SCAR=13.1
5700 222 my ( $self, $method, $args, $expected, $file, $line ) = @_;
5701  
5702 die Zuzu::Error->new_runtime(
5703 message => "$method expects $expected argument"
5704 . ( $expected == 1 ? '' : 's' ),
5705 file => $file,
5706 line => $line,
5707 222 ▶ ) if @{ $args } != $expected;
Branch: 2 branches
BranchTrueFalseTotal
if @{$args;} != $expected 0 222 222
$expected == 1 ? : 0 0 0
5708 }
5709  
5710 1 ▶sub _require_method_arity_range {
Subroutine _require_method_arity_range: called CC=3 SCAR=12.0
5711 1 my ( $self, $method, $args, $min, $max, $file, $line ) = @_;
5712  
5713 die Zuzu::Error->new_runtime(
5714 message => "$method expects between $min and $max arguments",
5715 file => $file,
5716 line => $line,
5717 1 ▶ ) if @{ $args } < $min or @{ $args } > $max;
Branch: 1 branch
BranchTrueFalseTotal
if @{$args;} < $min or @{$args;} > $max 0 1 1
Condition33%1/3
@{$args;} < $min or @{$args;} > $max
l!l&&r!l&&!r
001
MC/DC0%0/2
@{$args;} < $min or @{$args;} > $max
@{$args;} < $min @{$args;} > $max
Truth table33%1/3
A or B
A= @{$args;} < $minB= @{$args;} > $max
ABresult
1X1
011
000
5718 }
5719  
5720 4 ▶sub _array_index {
Subroutine _array_index: called CC=3 SCAR=11.4
5721 4 my ( $self, $arr, $index ) = @_;
5722  
5723 4 ▶ my $idx = 0 + ( $index // 0 );
Condition50%1/2
$index // 0
l!l
40
MC/DC0%0/1
$index // 0
$index
Truth table50%1/2
A
A= $index
Aresult
11
00
5724 4 ▶ $idx += $arr->length if $idx < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $idx < 0 0 4 4
5725  
5726 4 return $idx;
5727 }
5728  
5729 1 ▶sub _array_get {
Subroutine _array_get: called CC=1 SCAR=0.0
5730 1 my ( $self, $arr, $args, $file, $line ) = @_;
5731  
5732 1 $self->_require_method_arity_range( 'Array.get', $args, 1, 2, $file, $line );
5733 1 my $idx = $self->_array_index( $arr, $args->[0] );
5734  
5735 1 return $arr->get( $idx, $args->[1] );
5736 }
5737  
5738 3 ▶sub _array_set {
Subroutine _array_set: called CC=4 SCAR=13.9
5739 3 my ( $self, $arr, $args, $file, $line, $weak ) = @_;
5740  
5741 3 ▶ $self->_require_method_arity( $weak ? 'Array.set_weak' : 'Array.set', $args, 2, $file, $line );
Branch: 1 branch
BranchTrueFalseTotal
$weak ? : 1 2 3
5742 3 my $idx = $self->_array_index( $arr, $args->[0] );
5743 3 ▶ die Zuzu::Error->new_runtime(
Branch: 1 branch
BranchTrueFalseTotal
if $idx < 0 0 3 3
5744 message => 'Array index is out of range',
5745 file => $file,
5746 line => $line,
5747 ) if $idx < 0;
5748  
5749 3 ▶ return $weak ? $arr->set_weak( $idx, $args->[1] ) : $arr->set( $idx, $args->[1] );
Branch: 1 branch
BranchTrueFalseTotal
$weak ? : 1 2 3
5750 }
5751  
5752 0 ▶sub _pairlist_enumerate {
Subroutine _pairlist_enumerate: not called CC=2 SCAR=17.9
5753 0 my ( $self, $pairlist ) = @_;
5754  
5755 0 my @pair_objects;
5756 0 ▶ for ( my $i = 0; $i < @{ $pairlist->list }; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @{$pairlist->list;}) 0 0 0
5757 0 my $pair = $pairlist->list->[$i];
5758 0 push @pair_objects, $self->_make_pair_object(
5759 $pair->[0],
5760 $pairlist->_value_at($i),
5761 );
5762 }
5763  
5764 0 return Zuzu::Value::Array->new( items => \@pair_objects );
5765 }
5766  
5767 0 ▶sub _array_join {
Subroutine _array_join: not called CC=10 SCAR=47.0
5768 0 my ( $self, $arr, $args, $file, $line ) = @_;
5769  
5770 die Zuzu::Error->new_runtime(
5771 message => 'Array.join expects one or two arguments',
5772 file => $file,
5773 line => $line,
5774 0 ▶ ) if @{ $args } < 1 or @{ $args } > 2;
Branch: 1 branch
BranchTrueFalseTotal
if @{$args;} < 1 or @{$args;} > 2 0 0 0
Condition0%0/3
@{$args;} < 1 or @{$args;} > 2
l!l&&r!l&&!r
000
MC/DC0%0/2
@{$args;} < 1 or @{$args;} > 2
@{$args;} < 1 @{$args;} > 2
Truth table0%0/3
A or B
A= @{$args;} < 1B= @{$args;} > 2
ABresult
1X1
011
000
5775  
5776 0 my $separator = $self->_to_OperatorString( $args->[0], $file, $line );
5777 0 my $fallback = $args->[1];
5778 0 my $has_fallback = @{ $args } == 2;
5779 0 my $fallback_string;
5780 my @parts;
5781 0 for my $value ( $arr->resolved_items ) {
5782 0 my $part = eval { $self->_to_OperatorString( $value, $file, $line ) };
5783 0 ▶ if ( !defined $part and $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $part and $@) 0 0 0
Condition0%0/3
not defined $part and $@
!ll&&!rl&&r
000
MC/DC0%0/2
not defined $part and $@
not defined $part $@
Truth table0%0/3
not(A) and B
A= not defined $partB= $@
ABresult
0X0
100
111
5784 0 ▶ die $@ if !$has_fallback;
Branch: 1 branch
BranchTrueFalseTotal
unless $has_fallback 0 0 0
5785 0 ▶ if ( blessed($fallback) and $fallback->isa('Zuzu::Value::Function') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($fallback) and $fallback->isa('Zuzu::Value::Function')) { } 0 0 0
Condition0%0/3
builtin::blessed($fallback) and $fallback->isa("Zuzu::Value::Function")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($fallback) and $fallback->isa("Zuzu::Value::Function")
builtin::blessed($fallback) $fallback->isa("Zuzu::Value::Function")
Truth table0%0/3
A and B
A= builtin::blessed($fallback)B= $fallback->isa("Zuzu::Value::Function")
ABresult
0X0
100
111
5786 0 my $replacement = $self->_await_callback_value(
5787 $self->_call_function(
5788 $fallback,
5789 [ $value ],
5790 $EMPTY_HASH,
5791 $EMPTY_ARRAY,
5792 $file,
5793 $line,
5794 ),
5795 );
5796 0 $part = $self->_to_OperatorString(
5797 $replacement,
5798 $file,
5799 $line,
5800 );
5801 }
5802 else {
5803 0 ▶ $fallback_string //=
Condition0%0/3
$fallback_string //= $self->_to_OperatorString($fallback, $file, $line)
l!l&&r!l&&!r
000
MC/DC0%0/2
$fallback_string //= $self->_to_OperatorString($fallback, $file, $line)
$fallback_string $self->_to_OperatorString($fallback, $file, $line)
Truth table0%0/3
A //= B
A= $fallback_stringB= $self->_to_OperatorString($fallback, $file, $line)
ABresult
1X1
011
000
5804 $self->_to_OperatorString( $fallback, $file, $line );
5805 0 $part = $fallback_string;
5806 }
5807 }
5808 0 push @parts, $part;
5809 }
5810  
5811 0 return join $separator, @parts;
5812 }
5813  
5814 0 ▶sub _array_slice {
Subroutine _array_slice: not called CC=3 SCAR=24.8
5815 0 my ( $self, $arr, $args, $file, $line ) = @_;
5816  
5817 die Zuzu::Error->new_runtime(
5818 message => 'Array.slice expects one or two arguments',
5819 file => $file,
5820 line => $line,
5821 0 ▶ ) if @{ $args } < 1 or @{ $args } > 2;
Branch: 1 branch
BranchTrueFalseTotal
if @{$args;} < 1 or @{$args;} > 2 0 0 0
Condition0%0/3
@{$args;} < 1 or @{$args;} > 2
l!l&&r!l&&!r
000
MC/DC0%0/2
@{$args;} < 1 or @{$args;} > 2
@{$args;} < 1 @{$args;} > 2
Truth table0%0/3
A or B
A= @{$args;} < 1B= @{$args;} > 2
ABresult
1X1
011
000
5822  
5823 0 return $arr->slice( @{ $args } );
5824 }
5825  
5826 9 ▶sub _make_pair_object {
Subroutine _make_pair_object: called CC=1 SCAR=0.0
5827 9 my ( $self, $key, $value ) = @_;
5828  
5829 9 my $pair_class = $self->{_builtin_classes}{Pair};
5830  
5831 9 return $self->_instantiate_builtin_object(
5832 $pair_class,
5833 {
5834 pair => Zuzu::Value::Array->new(
5835 items => [ $key, $value ],
5836 ),
5837 },
5838 );
5839 }
5840  
5841 1 ▶sub _dict_to_array {
Subroutine _dict_to_array: called CC=2 SCAR=6.9
5842 1 my ( $self, $dict ) = @_;
5843  
5844 1 my @pairs;
5845 1 for my $key ( sort CORE::keys %{ $dict->map } ) {
5846 1 push @pairs, $self->_make_pair_object( $key, $dict->get($key) );
5847 }
5848  
5849 1 return Zuzu::Value::Array->new( items => \@pairs );
5850 }
5851  
5852 1 ▶sub _pairlist_to_array {
Subroutine _pairlist_to_array: called CC=2 SCAR=6.9
5853 1 my ( $self, $pairlist ) = @_;
5854  
5855 1 my @pairs;
5856 1 ▶ for ( my $i = 0; $i < @{ $pairlist->list }; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @{$pairlist->list;}) 2 1 3
5857 2 my $pair = $pairlist->list->[$i];
5858 2 push @pairs, $self->_make_pair_object(
5859 $pair->[0],
5860 $pairlist->_value_at($i),
5861 );
5862 }
5863  
5864 1 return Zuzu::Value::Array->new( items => \@pairs );
5865 }
5866  
5867 59 ▶sub _set_method {
Subroutine _set_method: called CC=48 SCAR=41.1
5868 59 my ($self, $set, $m, $args, $file, $line) = @_;
5869 $self->_assert_mutable_collection( $set, $file, $line )
5870 59 ▶ if $SET_MUTATING_METHOD{$m};
Branch: 1 branch
BranchTrueFalseTotal
if $SET_MUTATING_METHOD{$m} 9 50 59
5871  
5872 59 ▶ if ($m eq 'add' || $m eq 'push') { return $set->add( @$args ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "add" or $m eq "push") 3 56 59
Condition100%3/3
$m eq "add" or $m eq "push"
l!l&&r!l&&!r
2156
MC/DC100%2/2
$m eq "add" or $m eq "push"
$m eq "add" $m eq "push"
Truth table100%3/3
A or B
A= $m eq "add"B= $m eq "push"
ABresult
1X1
011
000
5873 56 ▶ if ($m eq 'add_weak' || $m eq 'push_weak') { return $set->add_weak( @$args ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "add_weak" or $m eq "push_weak") 4 52 56
Condition66%2/3
$m eq "add_weak" or $m eq "push_weak"
l!l&&r!l&&!r
4052
MC/DC50%1/2
$m eq "add_weak" or $m eq "push_weak"
$m eq "add_weak" $m eq "push_weak"
Truth table66%2/3
A or B
A= $m eq "add_weak"B= $m eq "push_weak"
ABresult
1X1
011
000
5874 52 ▶ if ($m eq 'remove') { return $set->remove( $args->[0] ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "remove") 2 50 52
5875 50 ▶ if ($m eq 'length') { return $set->length; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "length") 19 31 50
5876 0 ▶ if ($m eq 'count') { return $set->count; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "count") 0 31 31
5877 31 ▶ if ($m eq 'empty') { return $set->empty; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "empty") 1 30 31
5878 0 ▶ if ($m eq 'is_empty') { return $set->is_empty; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "is_empty") 0 30 30
5879 30 ▶ if ($m eq 'copy') { return $set->copy; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "copy") 5 25 30
5880 0 ▶ if ($m eq 'clear') { return $set->clear; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "clear") 0 25 25
5881 25 ▶ if ($m eq 'contains') { return $set->contains( $args->[0] ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "contains") 12 13 25
5882 13 ▶ if ($m eq 'to_Array') { return $set->to_Array; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "to_Array") 2 11 13
5883 0 ▶ if ($m eq 'to_Bag') { return $set->to_Bag; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "to_Bag") 0 11 11
5884 11 ▶ if ($m eq 'to_Iterator') {
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "to_Iterator") 0 11 11
5885 0 return $self->_iterator_function_from_items(
5886 [ $set->resolved_items ],
5887 $file,
5888 $line,
5889 );
5890 }
5891 11 ▶ if ($m eq 'union' || $m eq 'intersection' || $m eq 'difference' || $m eq 'symmetric_difference' || $m eq 'is_subset' || $m eq 'is_superset' || $m eq 'is_disjoint' || $m eq 'equals') {
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "union" or $m eq "intersection" or $m eq "difference" or $m eq "symmetric_difference" or $m eq "is_subset" or $m eq "is_superset" or $m eq "is_disjoint" or $m eq "equals") 8 3 11
Condition100%21/21
$m eq "union" or $m eq "intersection" or $m eq "difference" or $m eq "symmetric_difference" or $m eq "is_subset" or $m eq "is_superset" or $m eq "is_disjoint" or $m eq "equals"
l!l&&r!l&&!r
713
$m eq "union" or $m eq "intersection" or $m eq "difference" or $m eq "symmetric_difference" or $m eq "is_subset" or $m eq "is_superset" or $m eq "is_disjoint"
l!l&&r!l&&!r
614
$m eq "union" or $m eq "intersection" or $m eq "difference" or $m eq "symmetric_difference" or $m eq "is_subset" or $m eq "is_superset"
l!l&&r!l&&!r
515
$m eq "union" or $m eq "intersection" or $m eq "difference" or $m eq "symmetric_difference" or $m eq "is_subset"
l!l&&r!l&&!r
416
$m eq "union" or $m eq "intersection" or $m eq "difference" or $m eq "symmetric_difference"
l!l&&r!l&&!r
317
$m eq "union" or $m eq "intersection" or $m eq "difference"
l!l&&r!l&&!r
218
$m eq "union" or $m eq "intersection"
l!l&&r!l&&!r
119
MC/DC100%8/8
$m eq "union" or $m eq "intersection" or $m eq "difference" or $m eq "symmetric_difference" or $m eq "is_subset" or $m eq "is_superset" or $m eq "is_disjoint" or $m eq "equals"
$m eq "union" $m eq "intersection" $m eq "difference" $m eq "symmetric_difference" $m eq "is_subset" $m eq "is_superset" $m eq "is_disjoint" $m eq "equals"
Truth table100%9/9
A or B or C or D or E or F or G or H
A= $m eq "union"B= $m eq "intersection"C= $m eq "difference"D= $m eq "symmetric_difference"E= $m eq "is_subset"F= $m eq "is_superset"G= $m eq "is_disjoint"H= $m eq "equals"
ABCDEFGHresult
1XXXXXXX1
01XXXXXX1
001XXXXX1
0001XXXX1
00001XXX1
000001XX1
0000001X1
000000011
000000000
5892 8 my $other = $self->_as_set_argument( $args->[0], $file, $line );
5893 8 ▶ return $set->union($other) if $m eq 'union';
Branch: 1 branch
BranchTrueFalseTotal
if $m eq "union" 1 7 8
5894 7 ▶ return $set->intersection($other) if $m eq 'intersection';
Branch: 1 branch
BranchTrueFalseTotal
if $m eq "intersection" 1 6 7
5895 6 ▶ return $set->difference($other) if $m eq 'difference';
Branch: 1 branch
BranchTrueFalseTotal
if $m eq "difference" 1 5 6
5896 5 ▶ return $set->symmetric_difference($other) if $m eq 'symmetric_difference';
Branch: 1 branch
BranchTrueFalseTotal
if $m eq "symmetric_difference" 1 4 5
5897 4 ▶ return $set->is_subset($other) if $m eq 'is_subset';
Branch: 1 branch
BranchTrueFalseTotal
if $m eq "is_subset" 1 3 4
5898 3 ▶ return $set->is_superset($other) if $m eq 'is_superset';
Branch: 1 branch
BranchTrueFalseTotal
if $m eq "is_superset" 1 2 3
5899 2 ▶ return $set->is_disjoint($other) if $m eq 'is_disjoint';
Branch: 1 branch
BranchTrueFalseTotal
if $m eq "is_disjoint" 1 1 2
5900 1 return $set->equals($other);
5901 }
5902 3 ▶ if ($m eq 'sort') { return $set->sort( $self->_as_compare_callback( $args->[0], $file, $line ) ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "sort") 1 2 3
5903 0 ▶ if ($m eq 'sortstr') { return $set->sortstr; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "sortstr") 0 2 2
5904 0 ▶ if ($m eq 'sortnum') { return $set->sortnum; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "sortnum") 0 2 2
5905 2 ▶ if ($m eq 'map' || $m eq 'grep' || $m eq 'any' || $m eq 'all' || $m eq 'first' || $m eq 'remove_if' || $m eq 'for_each_value') {
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "map" or $m eq "grep" or $m eq "any" or $m eq "all" or $m eq "first" or $m eq "remove_if" or $m eq "for_each_value") 2 0 2
Condition66%12/18
$m eq "map" or $m eq "grep" or $m eq "any" or $m eq "all" or $m eq "first" or $m eq "remove_if" or $m eq "for_each_value"
l!l&&r!l&&!r
110
$m eq "map" or $m eq "grep" or $m eq "any" or $m eq "all" or $m eq "first" or $m eq "remove_if"
l!l&&r!l&&!r
101
$m eq "map" or $m eq "grep" or $m eq "any" or $m eq "all" or $m eq "first"
l!l&&r!l&&!r
101
$m eq "map" or $m eq "grep" or $m eq "any" or $m eq "all"
l!l&&r!l&&!r
101
$m eq "map" or $m eq "grep" or $m eq "any"
l!l&&r!l&&!r
101
$m eq "map" or $m eq "grep"
l!l&&r!l&&!r
101
MC/DC0%0/7
$m eq "map" or $m eq "grep" or $m eq "any" or $m eq "all" or $m eq "first" or $m eq "remove_if" or $m eq "for_each_value"
$m eq "map" $m eq "grep" $m eq "any" $m eq "all" $m eq "first" $m eq "remove_if" $m eq "for_each_value"
Truth table25%2/8
A or B or C or D or E or F or G
A= $m eq "map"B= $m eq "grep"C= $m eq "any"D= $m eq "all"E= $m eq "first"F= $m eq "remove_if"G= $m eq "for_each_value"
ABCDEFGresult
1XXXXXX1
01XXXXX1
001XXXX1
0001XXX1
00001XX1
000001X1
00000011
00000000
5906 2 ▶ return $set->map( $self->_as_mapper_callback( $args->[0], $file, $line ) ) if $m eq 'map';
Branch: 1 branch
BranchTrueFalseTotal
if $m eq "map" 1 1 2
5907 1 my $cb = $self->_as_predicate_callback( $args->[0], $file, $line );
5908 1 ▶ return $set->grep($cb) if $m eq 'grep';
Branch: 1 branch
BranchTrueFalseTotal
if $m eq "grep" 0 1 1
5909 1 ▶ return $set->any($cb) if $m eq 'any';
Branch: 1 branch
BranchTrueFalseTotal
if $m eq "any" 0 1 1
5910 1 ▶ return $set->all($cb) if $m eq 'all';
Branch: 1 branch
BranchTrueFalseTotal
if $m eq "all" 0 1 1
5911 1 ▶ return $set->first($cb) if $m eq 'first';
Branch: 1 branch
BranchTrueFalseTotal
if $m eq "first" 0 1 1
5912 1 ▶ return $set->for_each_value($cb) if $m eq 'for_each_value';
Branch: 1 branch
BranchTrueFalseTotal
if $m eq "for_each_value" 1 0 1
5913 0 return $set->remove_if($cb);
5914 }
5915 0 die Zuzu::Error->new_runtime(message => "Unsupported Set method '$m'", file => $file, line => $line);
5916 }
5917  
5918 43 ▶sub _bag_method {
Subroutine _bag_method: called CC=37 SCAR=42.8
5919 43 my ($self, $bag, $m, $args, $file, $line) = @_;
5920 $self->_assert_mutable_collection( $bag, $file, $line )
5921 43 ▶ if $BAG_MUTATING_METHOD{$m};
Branch: 1 branch
BranchTrueFalseTotal
if $BAG_MUTATING_METHOD{$m} 10 33 43
5922  
5923 43 ▶ if ($m eq 'add' || $m eq 'push') { return $bag->add( @$args ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "add" or $m eq "push") 2 41 43
Condition66%2/3
$m eq "add" or $m eq "push"
l!l&&r!l&&!r
2041
MC/DC50%1/2
$m eq "add" or $m eq "push"
$m eq "add" $m eq "push"
Truth table66%2/3
A or B
A= $m eq "add"B= $m eq "push"
ABresult
1X1
011
000
5924 41 ▶ if ($m eq 'add_weak' || $m eq 'push_weak') { return $bag->add_weak( @$args ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "add_weak" or $m eq "push_weak") 4 37 41
Condition66%2/3
$m eq "add_weak" or $m eq "push_weak"
l!l&&r!l&&!r
4037
MC/DC50%1/2
$m eq "add_weak" or $m eq "push_weak"
$m eq "add_weak" $m eq "push_weak"
Truth table66%2/3
A or B
A= $m eq "add_weak"B= $m eq "push_weak"
ABresult
1X1
011
000
5925 37 ▶ if ($m eq 'remove') { return $bag->remove( $args->[0] ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "remove") 3 34 37
5926 34 ▶ if ($m eq 'remove_first') { return $bag->remove_first( $args->[0] ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "remove_first") 1 33 34
5927 33 ▶ if ($m eq 'length') { return $bag->length; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "length") 9 24 33
5928 24 ▶ if ($m eq 'count') { return $bag->count( @$args ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "count") 2 22 24
5929 0 ▶ if ($m eq 'empty') { return $bag->empty; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "empty") 0 22 22
5930 0 ▶ if ($m eq 'is_empty') { return $bag->is_empty; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "is_empty") 0 22 22
5931 22 ▶ if ($m eq 'copy') { return $bag->copy; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "copy") 5 17 22
5932 0 ▶ if ($m eq 'clear') { return $bag->clear; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "clear") 0 17 17
5933 17 ▶ if ($m eq 'contains') { return $bag->contains( $args->[0] ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "contains") 12 5 17
5934 5 ▶ if ($m eq 'to_Array') { return $bag->to_Array; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "to_Array") 1 4 5
5935 4 ▶ if ($m eq 'to_Set') { return $bag->to_Set; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "to_Set") 1 3 4
5936 3 ▶ if ($m eq 'to_Iterator') {
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "to_Iterator") 0 3 3
5937 0 return $self->_iterator_function_from_items(
5938 [ $bag->resolved_items ],
5939 $file,
5940 $line,
5941 );
5942 }
5943 3 ▶ if ($m eq 'uniq') { return $bag->uniq; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "uniq") 1 2 3
5944 0 ▶ if ($m eq 'sum') { return $bag->sum; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "sum") 0 2 2
5945 0 ▶ if ($m eq 'product') { return $bag->product; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "product") 0 2 2
5946 2 ▶ if ($m eq 'sort') { return $bag->sort( $self->_as_compare_callback( $args->[0], $file, $line ) ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "sort") 1 1 2
5947 0 ▶ if ($m eq 'sortstr') { return $bag->sortstr; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "sortstr") 0 1 1
5948 0 ▶ if ($m eq 'sortnum') { return $bag->sortnum; }
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "sortnum") 0 1 1
5949 1 ▶ if ($m eq 'map' || $m eq 'grep' || $m eq 'any' || $m eq 'all' || $m eq 'first' || $m eq 'remove_if' || $m eq 'for_each_value') {
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq "map" or $m eq "grep" or $m eq "any" or $m eq "all" or $m eq "first" or $m eq "remove_if" or $m eq "for_each_value") 1 0 1
Condition33%6/18
$m eq "map" or $m eq "grep" or $m eq "any" or $m eq "all" or $m eq "first" or $m eq "remove_if" or $m eq "for_each_value"
l!l&&r!l&&!r
010
$m eq "map" or $m eq "grep" or $m eq "any" or $m eq "all" or $m eq "first" or $m eq "remove_if"
l!l&&r!l&&!r
001
$m eq "map" or $m eq "grep" or $m eq "any" or $m eq "all" or $m eq "first"
l!l&&r!l&&!r
001
$m eq "map" or $m eq "grep" or $m eq "any" or $m eq "all"
l!l&&r!l&&!r
001
$m eq "map" or $m eq "grep" or $m eq "any"
l!l&&r!l&&!r
001
$m eq "map" or $m eq "grep"
l!l&&r!l&&!r
001
MC/DC0%0/7
$m eq "map" or $m eq "grep" or $m eq "any" or $m eq "all" or $m eq "first" or $m eq "remove_if" or $m eq "for_each_value"
$m eq "map" $m eq "grep" $m eq "any" $m eq "all" $m eq "first" $m eq "remove_if" $m eq "for_each_value"
Truth table12%1/8
A or B or C or D or E or F or G
A= $m eq "map"B= $m eq "grep"C= $m eq "any"D= $m eq "all"E= $m eq "first"F= $m eq "remove_if"G= $m eq "for_each_value"
ABCDEFGresult
1XXXXXX1
01XXXXX1
001XXXX1
0001XXX1
00001XX1
000001X1
00000011
00000000
5950 1 ▶ return $bag->map( $self->_as_mapper_callback( $args->[0], $file, $line ) ) if $m eq 'map';
Branch: 1 branch
BranchTrueFalseTotal
if $m eq "map" 0 1 1
5951 1 my $cb = $self->_as_predicate_callback( $args->[0], $file, $line );
5952 1 ▶ return $bag->grep($cb) if $m eq 'grep';
Branch: 1 branch
BranchTrueFalseTotal
if $m eq "grep" 0 1 1
5953 1 ▶ return $bag->any($cb) if $m eq 'any';
Branch: 1 branch
BranchTrueFalseTotal
if $m eq "any" 0 1 1
5954 1 ▶ return $bag->all($cb) if $m eq 'all';
Branch: 1 branch
BranchTrueFalseTotal
if $m eq "all" 0 1 1
5955 1 ▶ return $bag->first($cb) if $m eq 'first';
Branch: 1 branch
BranchTrueFalseTotal
if $m eq "first" 0 1 1
5956 1 ▶ return $bag->for_each_value($cb) if $m eq 'for_each_value';
Branch: 1 branch
BranchTrueFalseTotal
if $m eq "for_each_value" 1 0 1
5957 0 return $bag->remove_if($cb);
5958 }
5959 0 die Zuzu::Error->new_runtime(message => "Unsupported Bag method '$m'", file => $file, line => $line);
5960 }
5961  
5962 0 ▶sub _iterator_function_from_items {
Subroutine _iterator_function_from_items: not called CC=2 SCAR=17.9
5963 0 my ( $self, $items, $file, $line ) = @_;
5964  
5965 0 ▶ my @values = @{ $items // [] };
Condition0%0/2
$items // []
l!l
00
MC/DC0%0/1
$items // []
$items
Truth table0%0/2
A
A= $items
Aresult
11
00
5966 0 my $idx = 0;
5967 0 my $fn = Zuzu::Value::Function->new(
5968 name => 'iterator',
5969 params => [],
5970 vararg => undef,
5971 body => undef,
5972 closure_env => undef,
5973 );
5974 0 ▶ $fn->{_native} = sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
5975 0 ▶ if ( $idx >= @values ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($idx >= @values) 0 0 0
5976 my $exhausted = $self->_instantiate_builtin_object(
5977 $self->{_builtin_classes}{ExhaustedException},
5978 {
5979 0 message => 'iterator exhausted',
5980 file => $file,
5981 line => $line,
5982 },
5983 );
5984 0 die {
5985 _zuzu_throw => 1,
5986 value => $exhausted,
5987 };
5988 }
5989 0 my $value = $values[$idx];
5990 0 $idx++;
5991 0 return $value;
5992 0 };
5993  
5994 0 return $fn;
5995 }
5996  
5997 231 ▶sub _as_mapper_callback {
Subroutine _as_mapper_callback: called CC=3 SCAR=11.8
5998 231 my ( $self, $fn, $file, $line ) = @_;
5999  
6000 231 ▶ die Zuzu::Error->new_runtime(
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($fn) and $fn->isa("Zuzu::Value::Function") 0 231 231
Condition33%1/3
builtin::blessed($fn) and $fn->isa("Zuzu::Value::Function")
!ll&&!rl&&r
00231
MC/DC0%0/2
builtin::blessed($fn) and $fn->isa("Zuzu::Value::Function")
builtin::blessed($fn) $fn->isa("Zuzu::Value::Function")
Truth table33%1/3
A and B
A= builtin::blessed($fn)B= $fn->isa("Zuzu::Value::Function")
ABresult
0X0
100
111
6001 message => "Collection method expects a function callback",
6002 file => $file,
6003 line => $line,
6004 ) if !blessed($fn) or !$fn->isa('Zuzu::Value::Function');
6005  
6006 3333 ▶ return sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
6007 3333 my ( $item ) = @_;
6008 3333 return $self->_await_callback_value(
6009 $self->_call_function(
6010 $fn,
6011 [ $item ],
6012 $EMPTY_HASH,
6013 $EMPTY_ARRAY,
6014 $file,
6015 $line,
6016 ),
6017 );
6018 231 };
6019 }
6020  
6021 15127 ▶sub _await_callback_value {
Subroutine _await_callback_value: called CC=3 SCAR=11.0
6022 15127 my ( $self, $value ) = @_;
6023  
6024 15127 ▶ return $value->await
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($value) and $value->isa("Zuzu::Value::Task") 9 15118 15127
Condition100%3/3
builtin::blessed($value) and $value->isa("Zuzu::Value::Task")
!ll&&!rl&&r
1183232869
MC/DC100%2/2
builtin::blessed($value) and $value->isa("Zuzu::Value::Task")
builtin::blessed($value) $value->isa("Zuzu::Value::Task")
Truth table100%3/3
A and B
A= builtin::blessed($value)B= $value->isa("Zuzu::Value::Task")
ABresult
0X0
100
111
6025 if blessed($value) and $value->isa('Zuzu::Value::Task');
6026 15118 return $value;
6027 }
6028  
6029 29 ▶sub _as_compare_callback {
Subroutine _as_compare_callback: called CC=3 SCAR=11.8
6030 29 my ( $self, $fn, $file, $line ) = @_;
6031  
6032 29 ▶ die Zuzu::Error->new_runtime(
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($fn) and $fn->isa("Zuzu::Value::Function") 0 29 29
Condition33%1/3
builtin::blessed($fn) and $fn->isa("Zuzu::Value::Function")
!ll&&!rl&&r
0029
MC/DC0%0/2
builtin::blessed($fn) and $fn->isa("Zuzu::Value::Function")
builtin::blessed($fn) $fn->isa("Zuzu::Value::Function")
Truth table33%1/3
A and B
A= builtin::blessed($fn)B= $fn->isa("Zuzu::Value::Function")
ABresult
0X0
100
111
6033 message => "Collection sort expects a function callback",
6034 file => $file,
6035 line => $line,
6036 ) if !blessed($fn) or !$fn->isa('Zuzu::Value::Function');
6037  
6038 11788 ▶ return sub {
Subroutine __ANON__: called CC=2 SCAR=7.1
6039 11788 my ( $left, $right ) = @_;
6040 11788 my $result = $self->_await_callback_value(
6041 $self->_call_function(
6042 $fn,
6043 [ $left, $right ],
6044 $EMPTY_HASH,
6045 $EMPTY_ARRAY,
6046 $file,
6047 $line,
6048 ),
6049 );
6050 11788 ▶ return 0 + ( $result // 0 );
Condition50%1/2
$result // 0
l!l
117880
MC/DC0%0/1
$result // 0
$result
Truth table50%1/2
A
A= $result
Aresult
11
00
6051 29 };
6052 }
6053  
6054 3 ▶sub _as_reducer_callback {
Subroutine _as_reducer_callback: called CC=3 SCAR=11.8
6055 3 my ( $self, $fn, $file, $line ) = @_;
6056  
6057 3 ▶ die Zuzu::Error->new_runtime(
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($fn) and $fn->isa("Zuzu::Value::Function") 0 3 3
Condition33%1/3
builtin::blessed($fn) and $fn->isa("Zuzu::Value::Function")
!ll&&!rl&&r
003
MC/DC0%0/2
builtin::blessed($fn) and $fn->isa("Zuzu::Value::Function")
builtin::blessed($fn) $fn->isa("Zuzu::Value::Function")
Truth table33%1/3
A and B
A= builtin::blessed($fn)B= $fn->isa("Zuzu::Value::Function")
ABresult
0X0
100
111
6058 message => "Collection reduce expects a function callback",
6059 file => $file,
6060 line => $line,
6061 ) if !blessed($fn) or !$fn->isa('Zuzu::Value::Function');
6062  
6063 6 ▶ return sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
6064 6 my ( $left, $right ) = @_;
6065 6 return $self->_await_callback_value(
6066 $self->_call_function(
6067 $fn,
6068 [ $left, $right ],
6069 $EMPTY_HASH,
6070 $EMPTY_ARRAY,
6071 $file,
6072 $line,
6073 ),
6074 );
6075 3 };
6076 }
6077  
6078 8 ▶sub _as_set_argument {
Subroutine _as_set_argument: called CC=2 SCAR=7.0
6079 8 my ( $self, $value, $file, $line ) = @_;
6080 8 my $set = $self->_unwrap_builtin_collection( $value, 'Set' );
6081  
6082 8 ▶ die Zuzu::Error->new_runtime(
Branch: 1 branch
BranchTrueFalseTotal
unless $set 0 8 8
6083 message => "Set method expects a Set argument",
6084 file => $file,
6085 line => $line,
6086 ) if ! $set;
6087  
6088 8 return $set;
6089 }
6090  
6091 58 ▶sub _throw_matches_type {
Subroutine _throw_matches_type: called CC=13 SCAR=48.4
6092 58 my ( $self, $value, $type ) = @_;
6093  
6094 58 ▶ if ( blessed($type) and $type->isa('Zuzu::Value::Class') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($type) and $type->isa("Zuzu::Value::Class")) 58 0 58
Condition33%1/3
builtin::blessed($type) and $type->isa("Zuzu::Value::Class")
!ll&&!rl&&r
0058
MC/DC0%0/2
builtin::blessed($type) and $type->isa("Zuzu::Value::Class")
builtin::blessed($type) $type->isa("Zuzu::Value::Class")
Truth table33%1/3
A and B
A= builtin::blessed($type)B= $type->isa("Zuzu::Value::Class")
ABresult
0X0
100
111
6095 58 return $self->_value_matches_class( $value, $type );
6096 }
6097 0 ▶ if ( blessed($type) and $type->isa('Zuzu::Value::Trait') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($type) and $type->isa("Zuzu::Value::Trait")) 0 0 0
Condition0%0/3
builtin::blessed($type) and $type->isa("Zuzu::Value::Trait")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($type) and $type->isa("Zuzu::Value::Trait")
builtin::blessed($type) $type->isa("Zuzu::Value::Trait")
Truth table0%0/3
A and B
A= builtin::blessed($type)B= $type->isa("Zuzu::Value::Trait")
ABresult
0X0
100
111
6098 0 ▶ return $FALSE if !blessed($value) or !$value->isa('Zuzu::Value::Object');
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($value) and $value->isa("Zuzu::Value::Object") 0 0 0
Condition0%0/3
builtin::blessed($value) and $value->isa("Zuzu::Value::Object")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($value) and $value->isa("Zuzu::Value::Object")
builtin::blessed($value) $value->isa("Zuzu::Value::Object")
Truth table0%0/3
A and B
A= builtin::blessed($value)B= $value->isa("Zuzu::Value::Object")
ABresult
0X0
100
111
6099 0 my $klass = $value->class;
6100 0 ▶ while ($klass) {
Branch: 1 branch
BranchTrueFalseTotal
if ($klass) 0 0 0
6101 0 ▶ for my $trait ( @{ $klass->traits // [] } ) {
Condition0%0/2
$klass->traits // []
l!l
00
MC/DC0%0/1
$klass->traits // []
$klass->traits
Truth table0%0/2
A
A= $klass->traits
Aresult
11
00
6102 0 ▶ return $TRUE if $trait == $type;
Branch: 1 branch
BranchTrueFalseTotal
if $trait == $type 0 0 0
6103 }
6104 0 $klass = $klass->parent;
6105 }
6106 0 return $FALSE;
6107 }
6108 0 my $type_name = $self->_type_name($value);
6109 0 ▶ my $target_name = ref($type) ? '' : "$type";
Branch: 1 branch
BranchTrueFalseTotal
ref $type ? : 0 0 0
6110  
6111 0 ▶ return $type_name eq $target_name ? $TRUE : $FALSE;
Branch: 1 branch
BranchTrueFalseTotal
$type_name eq $target_name ? : 0 0 0
6112 }
6113  
6114 46644 ▶sub _class_matches_or_descends {
Subroutine _class_matches_or_descends: called CC=5 SCAR=16.2
6115 46644 my ( $self, $klass, $target ) = @_;
6116  
6117 46644 ▶ return $FALSE if !defined $klass;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $klass 0 46644 46644
6118 46644 ▶ return $FALSE if !defined $target;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $target 0 46644 46644
6119 46644 my $cur = $klass;
6120 46644 ▶ while ( $cur ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cur) 50515 1434 51949
6121 50515 ▶ return $TRUE if $cur == $target;
Branch: 1 branch
BranchTrueFalseTotal
if $cur == $target 45210 5305 50515
6122 5305 $cur = $cur->parent;
6123 }
6124  
6125 1434 return $FALSE;
6126 }
6127  
6128 46644 ▶sub _value_matches_class {
Subroutine _value_matches_class: called CC=10 SCAR=29.2
6129 46644 my ( $self, $value, $target ) = @_;
6130  
6131 46644 ▶ return $FALSE if !defined $target;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $target 0 46644 46644
6132 46644 ▶ if ( blessed($value) and $value->isa('Zuzu::Error') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($value) and $value->isa("Zuzu::Error")) 0 46644 46644
Condition66%2/3
builtin::blessed($value) and $value->isa("Zuzu::Error")
!ll&&!rl&&r
24037226070
MC/DC0%0/2
builtin::blessed($value) and $value->isa("Zuzu::Error")
builtin::blessed($value) $value->isa("Zuzu::Error")
Truth table66%2/3
A and B
A= builtin::blessed($value)B= $value->isa("Zuzu::Error")
ABresult
0X0
100
111
6133 0 my $name = 'Exception';
6134 0 ▶ $name = 'TypeException' if ( $value->message // '' ) =~ /\ATypeException:/;
Branch: 1 branch
BranchTrueFalseTotal
if ($value->message // "") =~ /\ATypeException:/ 0 0 0
Condition0%0/2
$value->message // ""
l!l
00
MC/DC0%0/1
$value->message // ""
$value->message
Truth table0%0/2
A
A= $value->message
Aresult
11
00
6135 0 my $error_class = $self->{_builtin_classes}{$name};
6136 0 ▶ return $FALSE if !defined $error_class;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $error_class 0 0 0
6137 0 return $self->_class_matches_or_descends( $error_class, $target );
6138 }
6139 46644 ▶ if ( blessed($value) and $value->isa('Zuzu::Value::Object') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($value) and $value->isa("Zuzu::Value::Object")) 77 46567 46644
Condition100%3/3
builtin::blessed($value) and $value->isa("Zuzu::Value::Object")
!ll&&!rl&&r
240372253077
MC/DC100%2/2
builtin::blessed($value) and $value->isa("Zuzu::Value::Object")
builtin::blessed($value) $value->isa("Zuzu::Value::Object")
Truth table100%3/3
A and B
A= builtin::blessed($value)B= $value->isa("Zuzu::Value::Object")
ABresult
0X0
100
111
6140 77 return $self->_class_matches_or_descends( $value->class, $target );
6141 }
6142  
6143 46567 my $type_name = $self->_type_name($value);
6144 46567 my $value_class = $self->{_builtin_classes}{$type_name};
6145 46567 ▶ return $FALSE if !defined $value_class;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value_class 0 46567 46567
6146  
6147 46567 return $self->_class_matches_or_descends( $value_class, $target );
6148 }
6149  
6150 214 ▶sub _as_predicate_callback {
Subroutine _as_predicate_callback: called CC=1 SCAR=0.0
6151 214 my ( $self, $fn, $file, $line ) = @_;
6152 214 my $map = $self->_as_mapper_callback( $fn, $file, $line );
6153  
6154 3266 ▶ return sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
6155 3266 my ( $item ) = @_;
6156 3266 my $result = $map->( $item );
6157 3266 ▶ return $self->_to_Boolean( $result ) ? $TRUE : $FALSE;
Branch: 1 branch
BranchTrueFalseTotal
$self->_to_Boolean($result) ? : 2731 535 3266
6158 214 };
6159 }
6160  
6161 184 ▶sub _to_String {
Subroutine _to_String: called CC=25 SCAR=56.9
6162 184 my ( $self, $value ) = @_;
6163  
6164 184 ▶ return '' if !defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 184 184
6165 184 ▶ if ( blessed($value) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($value)) 5 179 184
6166 5 ▶ if ( $value->isa('Zuzu::Value::BinaryString') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value->isa("Zuzu::Value::BinaryString")) 0 5 5
6167 0 die Zuzu::Error->new_runtime(
6168 message => 'TypeException: Cannot implicitly convert BinaryString to String; use to_string(...)',
6169 file => '<runtime>',
6170 line => 0,
6171 );
6172 }
6173 5 ▶ if ( $value->isa('Zuzu::Value::Boolean') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value->isa("Zuzu::Value::Boolean")) 2 3 5
6174 2 ▶ return $value->value ? 'true' : 'false';
Branch: 1 branch
BranchTrueFalseTotal
$value->value ? : 2 0 2
6175 }
6176 3 ▶ if ( $value->isa('Zuzu::Value::Regexp') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value->isa("Zuzu::Value::Regexp")) 0 3 3
6177 0 return $value->to_String;
6178 }
6179 3 ▶ if ( $value->isa('Zuzu::Value::Object') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value->isa("Zuzu::Value::Object")) 3 0 3
6180 3 my $method = $self->_lookup_method( $value->class, 'to_String', 0 );
6181 3 ▶ if ( $method ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($method) 3 0 3
6182 3 my $result = $self->_call_method(
6183 $method,
6184 $value,
6185 [],
6186 {},
6187 [],
6188 '<runtime>',
6189 0,
6190 );
6191 3 return $self->_to_String($result);
6192 }
6193 }
6194 0 ▶ if ( my $array = $self->_unwrap_builtin_collection( $value, 'Array' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $array = $self->_unwrap_builtin_collection($value, "Array")) 0 0 0
6195 return '['
6196 0 . join( ', ', map { $self->_to_String($_) } $array->resolved_items )
6197 . ']';
6198 }
6199 0 ▶ if ( my $set = $self->_unwrap_builtin_collection( $value, 'Set' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $set = $self->_unwrap_builtin_collection($value, "Set")) 0 0 0
6200 return '<< '
6201 0 . join( ', ', map { $self->_to_String($_) } $set->resolved_items )
6202 . ' >>';
6203 }
6204 0 ▶ if ( my $bag = $self->_unwrap_builtin_collection( $value, 'Bag' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $bag = $self->_unwrap_builtin_collection($value, "Bag")) 0 0 0
6205 return '<<< '
6206 0 . join( ', ', map { $self->_to_String($_) } $bag->resolved_items )
6207 . ' >>>';
6208 }
6209 0 ▶ if ( my $dict = $self->_unwrap_builtin_collection( $value, 'Dict' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $dict = $self->_unwrap_builtin_collection($value, "Dict")) 0 0 0
6210 my @parts = map {
6211 0 $_ . ': ' . $self->_to_String( $dict->_value_for_key($_) )
6212 0 } sort CORE::keys %{ $dict->map };
6213 0 return '{' . join( ', ', @parts ) . '}';
6214 }
6215 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (my $pairlist = $self->_unwrap_builtin_collection($value, "PairList")) 0 0 0
6216 my $pairlist =
6217 $self->_unwrap_builtin_collection( $value, 'PairList' )
6218 ) {
6219 0 my @parts;
6220 0 ▶ for ( my $i = 0; $i < @{ $pairlist->list }; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @{$pairlist->list;}) 0 0 0
6221 0 push @parts,
6222 $pairlist->list->[$i][0] . ': '
6223 . $self->_to_String( $pairlist->_value_at($i) );
6224 }
6225 0 return '{{' . join( ', ', @parts ) . '}}';
6226 }
6227 0 ▶ if ( $value->isa('Zuzu::Value::Function') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value->isa("Zuzu::Value::Function")) 0 0 0
6228 return $value->{_is_method}
6229 0 ▶ ? ( $value->name // '<Method>' )
Branch: 1 branch
BranchTrueFalseTotal
$value->{'_is_method'} ? : 0 0 0
Condition0%0/2
$value->name // "<Method>"
l!l
00
MC/DC0%0/1
$value->name // "<Method>"
$value->name
Truth table0%0/2
A
A= $value->name
Aresult
11
00
6230 : '<Function>';
6231 }
6232 0 ▶ if ( $value->isa('Zuzu::Value::Class') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value->isa("Zuzu::Value::Class")) 0 0 0
6233 0 ▶ return '<Class ' . ( $value->name // 'Object' ) . '>';
Condition0%0/2
$value->name // "Object"
l!l
00
MC/DC0%0/1
$value->name // "Object"
$value->name
Truth table0%0/2
A
A= $value->name
Aresult
11
00
6234 }
6235 0 ▶ if ( $value->isa('Zuzu::Value::Trait') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value->isa("Zuzu::Value::Trait")) 0 0 0
6236 0 ▶ return '<Trait ' . ( $value->name // 'Trait' ) . '>';
Condition0%0/2
$value->name // "Trait"
l!l
00
MC/DC0%0/1
$value->name // "Trait"
$value->name
Truth table0%0/2
A
A= $value->name
Aresult
11
00
6237 }
6238 0 ▶ if ( $value->isa('Zuzu::Value::Object') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value->isa("Zuzu::Value::Object")) 0 0 0
6239 0 ▶ my $class_name = $value->class ? $value->class->name : 'Object';
Branch: 1 branch
BranchTrueFalseTotal
$value->class ? : 0 0 0
6240 0 return "[$class_name]";
6241 }
6242 0 ▶ if ( $value->can('to_String') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value->can("to_String")) 0 0 0
6243 0 my $result = $value->to_String;
6244 0 return $self->_to_String($result);
6245 }
6246 }
6247  
6248 179 return "$value";
6249 }
6250  
6251 63152 ▶sub _to_OperatorString {
Subroutine _to_OperatorString: called CC=13 SCAR=29.4
6252 63152 my ( $self, $value, $file, $line ) = @_;
6253  
6254 63152 ▶ $file //= '<runtime>';
Condition100%2/2
$file //= "<runtime>"
l!l
6312230
MC/DC100%1/1
$file //= "<runtime>"
$file
Truth table100%2/2
A
A= $file
Aresult
11
00
6255 63152 ▶ $line //= 0;
Condition100%2/2
$line //= 0
l!l
6312230
MC/DC100%1/1
$line //= 0
$line
Truth table100%2/2
A
A= $line
Aresult
11
00
6256 63152 ▶ return '' if !defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 1 63151 63152
6257 63151 ▶ if ( blessed($value) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($value)) 4 63147 63151
6258 4 ▶ if ( $value->isa('Zuzu::Value::Boolean') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value->isa("Zuzu::Value::Boolean")) 2 2 4
6259 2 ▶ return $value->value ? 'true' : 'false';
Branch: 1 branch
BranchTrueFalseTotal
$value->value ? : 1 1 2
6260 }
6261 2 ▶ if ( $value->isa('Zuzu::Value::Regexp') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value->isa("Zuzu::Value::Regexp")) 0 2 2
6262 0 return $value->to_String;
6263 }
6264 2 ▶ if ( $value->isa('Zuzu::Value::Object') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value->isa("Zuzu::Value::Object")) 2 0 2
6265 2 my $method = $self->_lookup_method( $value->class, 'to_String', 0 );
6266 2 ▶ if ( $method ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($method) 2 0 2
6267 2 my $result = $self->_call_method(
6268 $method,
6269 $value,
6270 [],
6271 {},
6272 [],
6273 $file,
6274 $line,
6275 );
6276 2 return $self->_to_OperatorString( $result, $file, $line );
6277 }
6278 }
6279 0 ▶ if ( $value->can('to_String') and !$self->_is_zuzu_runtime_value($value) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value->can("to_String") and not $self->_is_zuzu_runtime_value($value)) 0 0 0
Condition0%0/3
$value->can("to_String") and not $self->_is_zuzu_runtime_value($value)
!ll&&!rl&&r
000
MC/DC0%0/2
$value->can("to_String") and not $self->_is_zuzu_runtime_value($value)
$value->can("to_String") not $self->_is_zuzu_runtime_value($value)
Truth table0%0/3
A and not(B)
A= $value->can("to_String")B= not $self->_is_zuzu_runtime_value($value)
ABresult
0X0
100
111
6280 0 my $result = $value->to_String;
6281  
6282 0 return $self->_to_OperatorString( $result, $file, $line );
6283 }
6284  
6285 0 $self->_throw_operator_coercion_error( 'String', $value, $file, $line );
6286 }
6287 63147 ▶ if ( ref($value) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value) 0 63147 63147
6288 0 $self->_throw_operator_coercion_error( 'String', $value, $file, $line );
6289 }
6290  
6291 63147 return "$value";
6292 }
6293  
6294 199217 ▶sub _to_Number {
Subroutine _to_Number: called CC=16 SCAR=40.5
6295 199217 my ( $self, $value, $file, $line ) = @_;
6296  
6297 199217 ▶ $file //= '<runtime>';
Condition50%1/2
$file //= "<runtime>"
l!l
0199217
MC/DC0%0/1
$file //= "<runtime>"
$file
Truth table50%1/2
A
A= $file
Aresult
11
00
6298 199217 ▶ $line //= 0;
Condition50%1/2
$line //= 0
l!l
0199217
MC/DC0%0/1
$line //= 0
$line
Truth table50%1/2
A
A= $line
Aresult
11
00
6299 199217 ▶ return 0 if !defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 33 199184 199217
6300 199184 ▶ if ( blessed($value) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($value)) 7 199177 199184
6301 7 ▶ if ( $value->isa('Zuzu::Value::Boolean') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value->isa("Zuzu::Value::Boolean")) 7 0 7
6302 7 ▶ return $value->value ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$value->value ? : 4 3 7
6303 }
6304 0 ▶ if ( $value->isa('Zuzu::Value::Object') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value->isa("Zuzu::Value::Object")) 0 0 0
6305 0 my $method = $self->_lookup_method( $value->class, 'to_Number', 0 );
6306 0 ▶ if ( $method ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($method) 0 0 0
6307 0 my $result = $self->_call_method(
6308 $method,
6309 $value,
6310 [],
6311 {},
6312 [],
6313 $file,
6314 $line,
6315 );
6316  
6317 0 return $self->_to_Number( $result, $file, $line );
6318 }
6319 }
6320 0 ▶ if ( $value->can('to_Number') and !$self->_is_zuzu_runtime_value($value) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value->can("to_Number") and not $self->_is_zuzu_runtime_value($value)) 0 0 0
Condition0%0/3
$value->can("to_Number") and not $self->_is_zuzu_runtime_value($value)
!ll&&!rl&&r
000
MC/DC0%0/2
$value->can("to_Number") and not $self->_is_zuzu_runtime_value($value)
$value->can("to_Number") not $self->_is_zuzu_runtime_value($value)
Truth table0%0/3
A and not(B)
A= $value->can("to_Number")B= not $self->_is_zuzu_runtime_value($value)
ABresult
0X0
100
111
6321 0 my $result = $value->to_Number;
6322  
6323 0 return $self->_to_Number( $result, $file, $line );
6324 }
6325  
6326 0 $self->_throw_operator_coercion_error( 'Number', $value, $file, $line );
6327 }
6328  
6329 199177 ▶ if ( !ref($value) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $value) 199177 0 199177
6330 199177 ▶ return 0 + $value if equality_type($value) eq 'Number';
Branch: 1 branch
BranchTrueFalseTotal
if equality_type($value) eq "Number" 199157 20 199177
6331 20 ▶ if ( $self->_is_numeric_string($value) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_is_numeric_string($value)) 20 0 20
6332 # Radix-prefixed strings coerce case-insensitively.
6333 20 ▶ if ( $value =~ /\A([+-]?)(0[xXbB][0-9A-Fa-f]+|0[oO][0-7]+)\z/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /\A([+-]?)(0[xXbB][0-9A-Fa-f]+|0[oO][0-7]+)\z/) 0 20 20
6334 0 my ( $sign, $digits ) = ( $1, $2 );
6335 0 $digits =~ s/\A0[oO]/0/;
6336 0 my $magnitude = oct( lc $digits );
6337 0 ▶ return $sign eq '-' ? -$magnitude : $magnitude;
Branch: 1 branch
BranchTrueFalseTotal
$sign eq '-' ? : 0 0 0
6338 }
6339 20 return 0 + $value;
6340 }
6341 }
6342  
6343 0 $self->_throw_operator_coercion_error( 'Number', $value, $file, $line );
6344 }
6345  
6346 78095 ▶sub _to_Boolean {
Subroutine _to_Boolean: called CC=18 SCAR=32.0
6347 78095 my ( $self, $value ) = @_;
6348  
6349 78095 ▶ return 0 if !defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 98 77997 78095
6350 77997 ▶ if ( !ref($value) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $value) 770 77227 77997
6351 770 my $type = equality_type($value);
6352 770 ▶ return 0 if $type eq 'Number' && 0 + $value == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "Number" and 0 + $value == 0 555 215 770
Condition100%3/3
$type eq "Number" and 0 + $value == 0
!ll&&!rl&&r
4211555
MC/DC100%2/2
$type eq "Number" and 0 + $value == 0
$type eq "Number" 0 + $value == 0
Truth table100%3/3
A and B
A= $type eq "Number"B= 0 + $value == 0
ABresult
0X0
100
111
6353 215 ▶ return 0 if $type eq 'String' && $value eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "String" and $value eq "" 1 214 215
Condition100%3/3
$type eq "String" and $value eq ""
!ll&&!rl&&r
21131
MC/DC100%2/2
$type eq "String" and $value eq ""
$type eq "String" $value eq ""
Truth table100%3/3
A and B
A= $type eq "String"B= $value eq ""
ABresult
0X0
100
111
6354 214 return 1;
6355 }
6356 77227 ▶ if ( blessed($value) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($value)) 77227 0 77227
6357 77227 ▶ return $value->{value} ? 1 : 0
Branch: 2 branches
BranchTrueFalseTotal
if $value->isa("Zuzu::Value::Boolean") 77031 196 77227
$value->{'value'} ? : 36049 40982 77031
6358 if $value->isa('Zuzu::Value::Boolean');
6359 196 ▶ if ( $value->isa('Zuzu::Value::Object') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value->isa("Zuzu::Value::Object")) 92 104 196
6360 92 my $method = $self->_lookup_method( $value->class, 'to_Boolean', 0 );
6361 92 ▶ if ( $method ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($method) 0 92 92
6362 0 my $result = $self->_call_method( $method, $value, [], {}, [], '<runtime>', 0 );
6363 0 ▶ return $self->_to_Boolean( $result ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->_to_Boolean($result) ? : 0 0 0
6364 }
6365 }
6366 196 ▶ if ( $value->can('to_Boolean') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value->can("to_Boolean")) 0 196 196
6367 0 my $result = $value->to_Boolean;
6368 0 ▶ return $self->_to_Boolean( $result ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->_to_Boolean($result) ? : 0 0 0
6369 }
6370 196 ▶ return $value->is_truthy ? 1 : 0
Branch: 2 branches
BranchTrueFalseTotal
if $value->can("is_truthy") 196 0 196
$value->is_truthy ? : 191 5 196
6371 if $value->can('is_truthy');
6372 }
6373  
6374 0 ▶ return Zuzu::Util::boolify( $value ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
Zuzu::Util::boolify($value) ? : 0 0 0
6375 }
6376  
6377 20 ▶sub _is_numeric_string {
Subroutine _is_numeric_string: called CC=4 SCAR=14.9
6378 20 my ( $self, $value ) = @_;
6379  
6380 20 ▶ return 0 if ref($value);
Branch: 1 branch
BranchTrueFalseTotal
if ref $value 0 20 20
6381 20 ▶ return 1 if $value =~ /\A[+-]?(?:0[xX][0-9A-Fa-f]+|0[bB][01]+|0[oO][0-7]+)\z/;
Branch: 1 branch
BranchTrueFalseTotal
if $value =~ /\A[+-]?(?:0[xX][0-9A-Fa-f]+|0[bB][01]+|0[oO][0-7]+)\z/ 0 20 20
6382 20 ▶ return $value =~ /\A[+-]?(?:(?:\d+(?:\.\d*)?)|(?:\.\d+))(?:[eE][+-]?\d+)?\z/
Branch: 1 branch
BranchTrueFalseTotal
$value =~ /\A[+-]?(?:(?:\d+(?:\.\d*)?)|(?:\.\d+))(?:[eE][+-]?\d+)?\z/ ? : 20 0 20
6383 ? 1
6384 : 0;
6385 }
6386  
6387 0 ▶sub _is_zuzu_runtime_value {
Subroutine _is_zuzu_runtime_value: not called CC=15 SCAR=54.8
6388 0 my ( $self, $value ) = @_;
6389  
6390 0 ▶ return 0 if !blessed($value);
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($value) 0 0 0
6391 0 ▶ return 1 if $value->isa('Zuzu::Value::Array');
Branch: 1 branch
BranchTrueFalseTotal
if $value->isa("Zuzu::Value::Array") 0 0 0
6392 0 ▶ return 1 if $value->isa('Zuzu::Value::Bag');
Branch: 1 branch
BranchTrueFalseTotal
if $value->isa("Zuzu::Value::Bag") 0 0 0
6393 0 ▶ return 1 if $value->isa('Zuzu::Value::BinaryString');
Branch: 1 branch
BranchTrueFalseTotal
if $value->isa("Zuzu::Value::BinaryString") 0 0 0
6394 0 ▶ return 1 if $value->isa('Zuzu::Value::Boolean');
Branch: 1 branch
BranchTrueFalseTotal
if $value->isa("Zuzu::Value::Boolean") 0 0 0
6395 0 ▶ return 1 if $value->isa('Zuzu::Value::Class');
Branch: 1 branch
BranchTrueFalseTotal
if $value->isa("Zuzu::Value::Class") 0 0 0
6396 0 ▶ return 1 if $value->isa('Zuzu::Value::Dict');
Branch: 1 branch
BranchTrueFalseTotal
if $value->isa("Zuzu::Value::Dict") 0 0 0
6397 0 ▶ return 1 if $value->isa('Zuzu::Value::Function');
Branch: 1 branch
BranchTrueFalseTotal
if $value->isa("Zuzu::Value::Function") 0 0 0
6398 0 ▶ return 1 if $value->isa('Zuzu::Value::Object');
Branch: 1 branch
BranchTrueFalseTotal
if $value->isa("Zuzu::Value::Object") 0 0 0
6399 0 ▶ return 1 if $value->isa('Zuzu::Value::PairList');
Branch: 1 branch
BranchTrueFalseTotal
if $value->isa("Zuzu::Value::PairList") 0 0 0
6400 0 ▶ return 1 if $value->isa('Zuzu::Value::Regexp');
Branch: 1 branch
BranchTrueFalseTotal
if $value->isa("Zuzu::Value::Regexp") 0 0 0
6401 0 ▶ return 1 if $value->isa('Zuzu::Value::Set');
Branch: 1 branch
BranchTrueFalseTotal
if $value->isa("Zuzu::Value::Set") 0 0 0
6402 0 ▶ return 1 if $value->isa('Zuzu::Value::Task');
Branch: 1 branch
BranchTrueFalseTotal
if $value->isa("Zuzu::Value::Task") 0 0 0
6403 0 ▶ return 1 if $value->isa('Zuzu::Value::Trait');
Branch: 1 branch
BranchTrueFalseTotal
if $value->isa("Zuzu::Value::Trait") 0 0 0
6404  
6405 0 return 0;
6406 }
6407  
6408 0 ▶sub _throw_operator_coercion_error {
Subroutine _throw_operator_coercion_error: not called CC=1 SCAR=6.9
6409 0 my ( $self, $target, $value, $file, $line ) = @_;
6410  
6411 0 my $type = $self->_type_name($value);
6412 0 die Zuzu::Error->new_runtime(
6413 message => "TypeException: Cannot coerce $type to $target",
6414 file => $file,
6415 line => $line,
6416 );
6417 }
6418  
6419 18298 ▶sub _instantiate_slots {
Subroutine _instantiate_slots: called CC=11 SCAR=24.3
6420 18298 my ($self, $klass) = @_;
6421  
6422 18298 ▶ my ( $slots, $const, $types, $weak ) = $klass->parent
Branch: 1 branch
BranchTrueFalseTotal
$klass->parent ? : 12954 5344 18298
6423 ? $self->_instantiate_slots($klass->parent)
6424 : ( {}, {}, {}, {} );
6425  
6426 18298 ▶ for my $spec (@{ $klass->field_specs // [] }) {
Condition50%1/2
$klass->field_specs // []
l!l
182980
MC/DC0%0/1
$klass->field_specs // []
$klass->field_specs
Truth table50%1/2
A
A= $klass->field_specs
Aresult
11
00
6427 32540 my $name = $spec->{name};
6428 32540 my $val = undef;
6429 32540 ▶ if ( defined $spec->{init} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $spec->{"init"}) 13578 18962 32540
6430 13578 ▶ my $init_env = Zuzu::Env->_new_fast( $klass->closure_env // $self->_env );
Condition33%1/3
$klass->closure_env // $self->_env
l!l&&r!l&&!r
1357800
MC/DC0%0/2
$klass->closure_env // $self->_env
$klass->closure_env $self->_env
Truth table33%1/3
A // B
A= $klass->closure_envB= $self->_env
ABresult
1X1
011
000
6431 13578 $self->_push_env($init_env);
6432 13578 my $ok = eval {
6433 13578 $val = $spec->{init}->evaluate($self);
6434 13578 1;
6435 };
6436 13578 my $err = $@;
6437 13578 $self->_pop_env;
6438 13578 ▶ die $err if !$ok;
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 0 13578 13578
6439 }
6440 32540 ▶ my $declared_type = $spec->{declared_type} // 'Any';
Condition50%1/2
$spec->{"declared_type"} // "Any"
l!l
325400
MC/DC0%0/1
$spec->{"declared_type"} // "Any"
$spec->{"declared_type"}
Truth table50%1/2
A
A= $spec->{"declared_type"}
Aresult
11
00
6441 32540 ▶ if ( defined $spec->{init} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $spec->{"init"}) 13578 18962 32540
6442 13578 $self->_assert_declared_type( $declared_type, $val, $klass->name, 0, $name );
6443 }
6444 32540 ▶ $const->{$name} = $spec->{is_const} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$spec->{'is_const'} ? : 0 32540 32540
6445 32540 $types->{$name} = $declared_type;
6446 32540 ▶ $weak->{$name} = $spec->{is_weak_storage} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$spec->{'is_weak_storage'} ? : 180 32360 32540
6447 32540 store_value( \$slots->{$name}, $val, $weak->{$name} );
6448 }
6449  
6450 18298 return ($slots, $const, $types, $weak);
6451 }
6452  
6453 65953 ▶sub _lookup_method {
Subroutine _lookup_method: called CC=1 SCAR=0.0
6454 65953 my ($self, $klass, $name, $is_static) = @_;
6455  
6456 65953 my $candidates = $self->_collect_method_candidate_refs( $klass, $name, $is_static );
6457  
6458 65953 return $candidates->[0];
6459 }
6460  
6461 2 ▶sub _collect_method_candidates {
Subroutine _collect_method_candidates: called CC=1 SCAR=0.0
6462 2 my ( $self, $klass, $name, $is_static ) = @_;
6463  
6464 2 my $candidates = $self->_collect_method_candidate_refs( $klass, $name, $is_static );
6465  
6466 2 return @{ $candidates };
6467 }
6468  
6469 71144 ▶sub _collect_method_candidate_refs {
Subroutine _collect_method_candidate_refs: called CC=11 SCAR=24.0
6470 71144 my ( $self, $klass, $name, $is_static ) = @_;
6471  
6472 71144 ▶ return [] if !defined $klass;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $klass 0 71144 71144
6473  
6474 71144 ▶ my $klass_key = refaddr( $klass ) // 0;
Condition50%1/2
builtin::refaddr($klass) // 0
l!l
711440
MC/DC0%0/1
builtin::refaddr($klass) // 0
builtin::refaddr($klass)
Truth table50%1/2
A
A= builtin::refaddr($klass)
Aresult
11
00
6475 71144 ▶ my $cache_key = join "\x1f", $klass_key, ( $name // '' ), ( $is_static ? 1 : 0 );
Branch: 1 branch
BranchTrueFalseTotal
$is_static ? : 249 70895 71144
Condition50%1/2
$name // ""
l!l
711440
MC/DC0%0/1
$name // ""
$name
Truth table50%1/2
A
A= $name
Aresult
11
00
6476 71144 ▶ if ( exists $self->{_method_candidate_cache}{$cache_key} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"_method_candidate_cache"}{$cache_key}) 64114 7030 71144
6477 64114 return $self->{_method_candidate_cache}{$cache_key};
6478 }
6479  
6480 7030 my @candidates;
6481 7030 ▶ if ( $is_static ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_static) { } 106 6924 7030
6482 push @candidates, $klass->static_methods->{ $name }
6483 106 ▶ if exists $klass->static_methods->{ $name };
Branch: 1 branch
BranchTrueFalseTotal
if exists $klass->static_methods->{$name} 59 47 106
6484 }
6485 else {
6486 push @candidates, $klass->methods->{ $name }
6487 6924 ▶ if exists $klass->methods->{ $name };
Branch: 1 branch
BranchTrueFalseTotal
if exists $klass->methods->{$name} 1738 5186 6924
6488 6924 ▶ if ( exists $klass->trait_methods->{ $name } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $klass->trait_methods->{$name}) 6 6918 6924
6489 6 push @candidates, @{ $klass->trait_methods->{ $name } };
6490 }
6491 }
6492  
6493 7030 ▶ if ( $klass->parent ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($klass->parent) 5189 1841 7030
6494 5189 push @candidates, @{ $self->_collect_method_candidate_refs(
6495 $klass->parent,
6496 $name,
6497 $is_static,
6498 ) };
6499 }
6500  
6501 7030 $self->{_method_candidate_cache}{$cache_key} = \@candidates;
6502  
6503 7030 return \@candidates;
6504 }
6505  
6506 2 ▶sub _lookup_next_method {
Subroutine _lookup_next_method: called CC=4 SCAR=15.6
6507 2 my ( $self, $klass, $name, $is_static, $current_fn ) = @_;
6508  
6509 2 my @candidates = $self->_collect_method_candidates( $klass, $name, $is_static );
6510 2 for my $i ( 0 .. $#candidates ) {
6511 2 ▶ next if $candidates[$i] ne $current_fn;
Branch: 1 branch
BranchTrueFalseTotal
if $candidates[$i] ne $current_fn 0 2 2
6512 2 ▶ return $candidates[ $i + 1 ] if $i < $#candidates;
Branch: 1 branch
BranchTrueFalseTotal
if $i < $#candidates 2 0 2
6513 0 last;
6514 }
6515  
6516 0 return undef;
6517 }
6518  
6519 7237 ▶sub _object_get {
Subroutine _object_get: called CC=7 SCAR=37.0
6520 7237 my ($self, $obj, $key) = @_;
6521  
6522 7237 ▶ return slot_value( \$obj->slots->{$key} ) if exists $obj->slots->{$key};
Branch: 1 branch
BranchTrueFalseTotal
if exists $obj->slots->{$key} 7237 0 7237
6523  
6524 0 my $m = $self->_lookup_method($obj->class, $key, 0);
6525 0 ▶ if ($m) {
Branch: 1 branch
BranchTrueFalseTotal
if ($m) 0 0 0
6526 0 ▶ my $obj_key = refaddr( $obj ) // 0;
Condition0%0/2
builtin::refaddr($obj) // 0
l!l
00
MC/DC0%0/1
builtin::refaddr($obj) // 0
builtin::refaddr($obj)
Truth table0%0/2
A
A= builtin::refaddr($obj)
Aresult
11
00
6527 0 my $method_key = join "\x1f", $obj_key, $key;
6528 0 my $cache_entry = $self->{_bound_method_cache}{$method_key};
6529 0 ▶ if ( defined $cache_entry and $cache_entry->{method_ref} == $m ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $cache_entry and $cache_entry->{"method_ref"} == $m) 0 0 0
Condition0%0/3
defined $cache_entry and $cache_entry->{"method_ref"} == $m
!ll&&!rl&&r
000
MC/DC0%0/2
defined $cache_entry and $cache_entry->{"method_ref"} == $m
defined $cache_entry $cache_entry->{"method_ref"} == $m
Truth table0%0/3
A and B
A= defined $cache_entryB= $cache_entry->{"method_ref"} == $m
ABresult
0X0
100
111
6530 0 return $cache_entry->{bound};
6531 }
6532  
6533 0 return $self->_bind_method( $obj, $key, $m );
6534 }
6535  
6536 0 ▶ return $obj->class->nested_classes->{$key} if exists $obj->class->nested_classes->{$key};
Branch: 1 branch
BranchTrueFalseTotal
if exists $obj->class->nested_classes->{$key} 0 0 0
6537  
6538 0 return undef;
6539 }
6540  
6541 0 ▶sub _bind_method {
Subroutine _bind_method: not called CC=15 SCAR=54.8
6542 0 my ( $self, $obj, $method_name, $method ) = @_;
6543  
6544 0 ▶ my $obj_key = refaddr( $obj ) // 0;
Condition0%0/2
builtin::refaddr($obj) // 0
l!l
00
MC/DC0%0/1
builtin::refaddr($obj) // 0
builtin::refaddr($obj)
Truth table0%0/2
A
A= builtin::refaddr($obj)
Aresult
11
00
6545 0 my $method_key = join "\x1f", $obj_key, $method_name;
6546 0 my $cache_entry = $self->{_bound_method_cache}{$method_key};
6547 0 ▶ if ( defined $cache_entry and $cache_entry->{method_ref} == $method ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $cache_entry and $cache_entry->{"method_ref"} == $method) 0 0 0
Condition0%0/3
defined $cache_entry and $cache_entry->{"method_ref"} == $method
!ll&&!rl&&r
000
MC/DC0%0/2
defined $cache_entry and $cache_entry->{"method_ref"} == $method
defined $cache_entry $cache_entry->{"method_ref"} == $method
Truth table0%0/3
A and B
A= defined $cache_entryB= $cache_entry->{"method_ref"} == $method
ABresult
0X0
100
111
6548 0 return $cache_entry->{bound};
6549 }
6550  
6551 my $bound = Zuzu::Value::Function->new(
6552 name => $method->name,
6553 0 ▶ params => [ @{ $method->params // [] } ],
Condition0%0/2
$method->params // []
l!l
00
MC/DC0%0/1
$method->params // []
$method->params
Truth table0%0/2
A
A= $method->params
Aresult
11
00
6554 vararg => $method->vararg,
6555 named_vararg => $method->named_vararg,
6556 0 ▶ param_types => { %{ $method->param_types // {} } },
Condition0%0/6
$method->param_types // {}
l!l
00
$method->vararg_type // "Any"
l!l
00
$method->named_vararg_type // "PairList"
l!l
00
MC/DC0%0/1
$method->param_types // {}
$method->param_types
MC/DC0%0/1
$method->vararg_type // "Any"
$method->vararg_type
MC/DC0%0/1
$method->named_vararg_type // "PairList"
$method->named_vararg_type
Truth table0%0/2
A
A= $method->param_types
Aresult
11
00
Truth table0%0/2
A
A= $method->vararg_type
Aresult
11
00
Truth table0%0/2
A
A= $method->named_vararg_type
Aresult
11
00
6557 vararg_type => $method->vararg_type // 'Any',
6558 named_vararg_type => $method->named_vararg_type // 'PairList',
6559 0 ▶ param_optional => { %{ $method->param_optional // {} } },
Condition0%0/2
$method->param_optional // {}
l!l
00
MC/DC0%0/1
$method->param_optional // {}
$method->param_optional
Truth table0%0/2
A
A= $method->param_optional
Aresult
11
00
6560 0 ▶ param_defaults => { %{ $method->param_defaults // {} } },
Branch: 1 branch
BranchTrueFalseTotal
$method->is_async ? : 0 0 0
Condition0%0/4
$method->param_defaults // {}
l!l
00
$method->return_type // "Any"
l!l
00
MC/DC0%0/1
$method->param_defaults // {}
$method->param_defaults
MC/DC0%0/1
$method->return_type // "Any"
$method->return_type
Truth table0%0/2
A
A= $method->param_defaults
Aresult
11
00
Truth table0%0/2
A
A= $method->return_type
Aresult
11
00
6561 return_type => $method->return_type // 'Any',
6562 body => $method->body,
6563 closure_env => $method->closure_env,
6564 is_async => $method->is_async ? 1 : 0,
6565 source_node => $method->source_node,
6566 );
6567 $bound->{_default_typecheck_safe} =
6568 0 ▶ { %{ $method->{_default_typecheck_safe} // {} } };
Condition0%0/2
$method->{"_default_typecheck_safe"} // {}
l!l
00
MC/DC0%0/1
$method->{"_default_typecheck_safe"} // {}
$method->{"_default_typecheck_safe"}
Truth table0%0/2
A
A= $method->{"_default_typecheck_safe"}
Aresult
11
00
6569 0 $bound->{_bound_self} = $obj;
6570 0 $bound->{_is_method} = 1;
6571 0 $bound->{_owner_class} = $method->{_owner_class};
6572 0 ▶ $bound->{_method_name} = $method->{_method_name} // $method_name;
Condition0%0/3
$method->{"_method_name"} // $method_name
l!l&&r!l&&!r
000
MC/DC0%0/2
$method->{"_method_name"} // $method_name
$method->{"_method_name"} $method_name
Truth table0%0/3
A // B
A= $method->{"_method_name"}B= $method_name
ABresult
1X1
011
000
6573 0 ▶ $bound->{_method_kind} = $method->{_method_kind} // 'instance';
Condition0%0/2
$method->{"_method_kind"} // "instance"
l!l
00
MC/DC0%0/1
$method->{"_method_kind"} // "instance"
$method->{"_method_kind"}
Truth table0%0/2
A
A= $method->{"_method_kind"}
Aresult
11
00
6574 0 $bound->{_uses_super} = $method->{_uses_super};
6575 0 $self->{_bound_method_cache}{$method_key} = {
6576 method_ref => $method,
6577 bound => $bound,
6578 };
6579  
6580 0 return $bound;
6581 }
6582  
6583  
6584 18149 ▶sub _named_pairs_count {
Subroutine _named_pairs_count: called CC=2 SCAR=7.0
6585 18149 my ( $named_pairs ) = @_;
6586  
6587 18149 ▶ return 0 if !defined $named_pairs;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $named_pairs 0 18149 18149
6588  
6589 18149 return scalar @{ $named_pairs };
6590 }
6591  
6592 1 ▶sub _call_missing_method_fallback {
Subroutine _call_missing_method_fallback: called CC=4 SCAR=25.3
6593 1 my ( $self, $obj, $method_name, $positional, $named_pairs, $file, $line, $arg_static_types ) = @_;
6594  
6595 1 ▶ my $fallback = $self->_lookup_method( $obj->class, '__call__', 0 )
Branch: 1 branch
BranchTrueFalseTotal
my $fallback = $self->_lookup_method($obj->class, "__call__", 0) or return undef 0 1 1
6596 or return undef;
6597  
6598 my $args_array = Zuzu::Value::Array->new(
6599 0 ▶ items => [ @{ $positional // $EMPTY_ARRAY } ],
Condition0%0/3
$positional // $Zuzu::Runtime::EMPTY_ARRAY
l!l&&r!l&&!r
000
MC/DC0%0/2
$positional // $Zuzu::Runtime::EMPTY_ARRAY
$positional $Zuzu::Runtime::EMPTY_ARRAY
Truth table0%0/3
A // B
A= $positionalB= $Zuzu::Runtime::EMPTY_ARRAY
ABresult
1X1
011
000
6600 );
6601 my $opts_pairlist = Zuzu::Value::PairList->new(
6602 0 ▶ list => [ map { [ $_->[0], $_->[1] ] } @{ $named_pairs // $EMPTY_ARRAY } ],
Condition0%0/3
$named_pairs // $Zuzu::Runtime::EMPTY_ARRAY
l!l&&r!l&&!r
000
MC/DC0%0/2
$named_pairs // $Zuzu::Runtime::EMPTY_ARRAY
$named_pairs $Zuzu::Runtime::EMPTY_ARRAY
Truth table0%0/3
A // B
A= $named_pairsB= $Zuzu::Runtime::EMPTY_ARRAY
ABresult
1X1
011
000
6603 );
6604  
6605 0 return [ $self->_call_method(
6606 $fallback,
6607 $obj,
6608 [ $method_name, $args_array, $opts_pairlist ],
6609 $EMPTY_HASH,
6610 $EMPTY_ARRAY,
6611 $file,
6612 $line,
6613 $arg_static_types,
6614 ) ];
6615 }
6616  
6617 55349 ▶sub _call_method {
Subroutine _call_method: called CC=29 SCAR=36.0
6618 55349 my ( $self, $fn, $self_value, $args, $named, $named_pairs, $file, $line, $arg_static_types ) = @_;
6619 55349 ▶ if ( defined $named and ref($named) ne 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $named and ref $named ne "HASH") 0 55349 55349
Condition33%1/3
defined $named and ref $named ne "HASH"
!ll&&!rl&&r
0553490
MC/DC0%0/2
defined $named and ref $named ne "HASH"
defined $named ref $named ne "HASH"
Truth table33%1/3
A and B
A= defined $namedB= ref $named ne "HASH"
ABresult
0X0
100
111
6620 0 $arg_static_types = $line;
6621 0 $line = $file;
6622 0 $file = $named_pairs;
6623 0 $named_pairs = [];
6624 0 $named = {};
6625 }
6626 55349 ▶ $named = $EMPTY_HASH if !defined $named;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $named 0 55349 55349
6627 55349 ▶ $named_pairs = $EMPTY_ARRAY if !defined $named_pairs;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $named_pairs 0 55349 55349
6628  
6629 55349 ▶ if ($fn->{_native}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fn->{"_native"}) 144 55205 55349
6630 144 local $self->{_native_call_file} = $file;
6631 144 local $self->{_native_call_line} = $line;
6632 144 ▶ if ( _named_pairs_count( $named_pairs ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (_named_pairs_count($named_pairs)) 0 144 144
6633 die Zuzu::Error->new_runtime(message => "Named arguments are not supported for native methods", file => $file, line => $line)
6634 0 ▶ if !$fn->{_native_accepts_named};
Branch: 1 branch
BranchTrueFalseTotal
unless $fn->{"_native_accepts_named"} 0 0 0
6635 0 return $fn->{_native}->(
6636 $self_value,
6637 @$args,
6638 $named,
6639 $named_pairs,
6640 );
6641 }
6642 144 return $fn->{_native}->($self_value, @$args);
6643 }
6644 55205 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($fn->is_async and !defined($self->{"_run_async_fn_ref"}) || $self->{"_run_async_fn_ref"} != builtin::refaddr($fn)) 2 55203 55205
Condition83%5/6
$fn->is_async and !defined($self->{"_run_async_fn_ref"}) || $self->{"_run_async_fn_ref"} != builtin::refaddr($fn)
!ll&&!rl&&r
5520122
not defined $self->{"_run_async_fn_ref"} or $self->{"_run_async_fn_ref"} != builtin::refaddr($fn)
l!l&&r!l&&!r
022
MC/DC66%2/3
$fn->is_async and !defined($self->{"_run_async_fn_ref"}) || $self->{"_run_async_fn_ref"} != builtin::refaddr($fn)
$fn->is_async not defined $self->{"_run_async_fn_ref"} $self->{"_run_async_fn_ref"} != builtin::refaddr($fn)
Truth table75%3/4
A and not(B) or C
A= $fn->is_asyncB= not defined $self->{"_run_async_fn_ref"}C= $self->{"_run_async_fn_ref"} != builtin::refaddr($fn)
ABCresult
0XX0
1000
11X1
1011
6645 $fn->is_async
6646 and (
6647 !defined $self->{_run_async_fn_ref}
6648 or $self->{_run_async_fn_ref} != refaddr($fn)
6649 )
6650 ) {
6651 2 ▶ my @task_args = @{ $args // [] };
Condition50%1/2
$args // []
l!l
20
MC/DC0%0/1
$args // []
$args
Truth table50%1/2
A
A= $args
Aresult
11
00
6652 2 ▶ my %task_named = %{ $named // {} };
Condition50%1/2
$named // {}
l!l
20
MC/DC0%0/1
$named // {}
$named
Truth table50%1/2
A
A= $named
Aresult
11
00
6653 2 ▶ my @task_named_pairs = @{ $named_pairs // [] };
Condition50%1/2
$named_pairs // []
l!l
20
MC/DC0%0/1
$named_pairs // []
$named_pairs
Truth table50%1/2
A
A= $named_pairs
Aresult
11
00
6654 2 ▶ my @task_arg_static_types = @{ $arg_static_types // [] };
Condition50%1/2
$arg_static_types // []
l!l
20
MC/DC0%0/1
$arg_static_types // []
$arg_static_types
Truth table50%1/2
A
A= $arg_static_types
Aresult
11
00
6655 return $self->_new_task(
6656 name => $fn->name // '<async-method>',
6657 schedule => 1,
6658 file => $file,
6659 line => $line,
6660 2 ▶ thunk => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
6661 2 local $self->{_run_async_fn_ref} = refaddr($fn);
6662 2 return $self->_call_method(
6663 $fn,
6664 $self_value,
6665 \@task_args,
6666 \%task_named,
6667 \@task_named_pairs,
6668 $file,
6669 $line,
6670 \@task_arg_static_types,
6671 );
6672 },
6673 2 ▶ );
Condition50%1/2
$fn->name // "<async-method>"
l!l
20
MC/DC0%0/1
$fn->name // "<async-method>"
$fn->name
Truth table50%1/2
A
A= $fn->name
Aresult
11
00
6674 }
6675  
6676 55203 my $call_env = Zuzu::Env->_new_fast( $fn->{closure_env} );
6677 55203 push @{$self->{_stack}}, $call_env; # inlined $self->_push_env
6678 55203 $call_env->declare('self', $self_value, 1);
6679 55203 ▶ if ( !defined $fn->{_uses_super} or $fn->{_uses_super} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $fn->{"_uses_super"} or $fn->{"_uses_super"}) 2 55201 55203
Condition66%2/3
not defined $fn->{"_uses_super"} or $fn->{"_uses_super"}
l!l&&r!l&&!r
0255201
MC/DC50%1/2
not defined $fn->{"_uses_super"} or $fn->{"_uses_super"}
not defined $fn->{"_uses_super"} $fn->{"_uses_super"}
Truth table66%2/3
not(A) or B
A= not defined $fn->{"_uses_super"}B= $fn->{"_uses_super"}
ABresult
1X1
011
000
6680 # This path runs for methods that reference super; construct the small
6681 # native wrapper directly instead of paying Moo constructor/default costs.
6682 2 my $super_fn = bless {
6683 name => 'super',
6684 params => [],
6685 vararg => '__super_args',
6686 named_vararg => undef,
6687 param_types => {},
6688 vararg_type => 'Any',
6689 named_vararg_type => 'PairList',
6690 param_optional => {},
6691 param_defaults => {},
6692 return_type => 'Any',
6693 body => undef,
6694 closure_env => undef,
6695 is_async => 0,
6696 }, 'Zuzu::Value::Function';
6697 2 ▶ $super_fn->{_native} = sub {
Subroutine __ANON__: called CC=4 SCAR=14.0
6698 2 my (@super_args) = @_;
6699 2 my $owner_class = $fn->{_owner_class};
6700 2 my $method_name = $fn->{_method_name};
6701 2 ▶ my $is_static = $fn->{_method_kind} && $fn->{_method_kind} eq 'static'
Branch: 1 branch
BranchTrueFalseTotal
$fn->{'_method_kind'} && $fn->{'_method_kind'} eq 'static' ? : 1 1 2
Condition66%2/3
$fn->{"_method_kind"} and $fn->{"_method_kind"} eq "static"
!ll&&!rl&&r
011
MC/DC50%1/2
$fn->{"_method_kind"} and $fn->{"_method_kind"} eq "static"
$fn->{"_method_kind"} $fn->{"_method_kind"} eq "static"
Truth table66%2/3
A and B
A= $fn->{"_method_kind"}B= $fn->{"_method_kind"} eq "static"
ABresult
0X0
100
111
6702 ? 1
6703 : 0;
6704 2 my $next = $self->_lookup_next_method(
6705 $owner_class,
6706 $method_name,
6707 $is_static,
6708 $fn,
6709 );
6710 2 ▶ die Zuzu::Error->new_runtime(
Branch: 1 branch
BranchTrueFalseTotal
unless $next 0 2 2
6711 message => "No super method available for '$method_name'",
6712 file => $file,
6713 line => $line,
6714 ) if !$next;
6715  
6716 2 return $self->_call_method( $next, $self_value, \@super_args, $EMPTY_HASH, $EMPTY_ARRAY, $file, $line );
6717 2 };
6718 2 $call_env->declare( 'super', $super_fn, 1 );
6719 }
6720  
6721 55203 ▶ if (blessed($self_value) and $self_value->isa('Zuzu::Value::Object')) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($self_value) and $self_value->isa("Zuzu::Value::Object")) 55046 157 55203
Condition66%2/3
builtin::blessed($self_value) and $self_value->isa("Zuzu::Value::Object")
!ll&&!rl&&r
015755046
MC/DC50%1/2
builtin::blessed($self_value) and $self_value->isa("Zuzu::Value::Object")
builtin::blessed($self_value) $self_value->isa("Zuzu::Value::Object")
Truth table66%2/3
A and B
A= builtin::blessed($self_value)B= $self_value->isa("Zuzu::Value::Object")
ABresult
0X0
100
111
6722 55046 my $slots = $self_value->{slots};
6723 55046 my $call_slots = $call_env->{slots};
6724 55046 my $call_const = $call_env->{const};
6725 55046 my $call_types = $call_env->{types};
6726 55046 my $call_weak = $call_env->{weak};
6727 55046 my $self_const = $self_value->{const};
6728 55046 my $self_types = $self_value->{types};
6729 55046 my $self_weak = $self_value->{weak};
6730 55046 for my $name ( CORE::keys %{ $slots } ) {
6731 473022 $call_slots->{$name} = \$slots->{$name};
6732 473022 ▶ $call_const->{$name} = $self_const->{$name} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self_const->{$name} ? : 0 473022 473022
6733 473022 ▶ $call_types->{$name} = $self_types->{$name} // 'Any';
Condition50%1/2
$self_types->{$name} // "Any"
l!l
4730220
MC/DC0%0/1
$self_types->{$name} // "Any"
$self_types->{$name}
Truth table50%1/2
A
A= $self_types->{$name}
Aresult
11
00
6734 473022 ▶ $call_weak->{$name} = $self_weak->{$name} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self_weak->{$name} ? : 1290 471732 473022
6735 }
6736 }
6737  
6738 55203 my $ret;
6739 eval {
6740 55203 $self->_bind_function_params(
6741 $fn,
6742 $args,
6743 $named,
6744 $named_pairs,
6745 $call_env,
6746 $file,
6747 $line,
6748 $arg_static_types,
6749 );
6750 55201 $ret = $fn->{body}->evaluate($self);
6751 523 1;
6752 55203 ▶ } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $self->_bind_function_params($fn, $args, $named, $named_pairs, $call_env, $file, $line, $arg_static_types); $ret = $fn->{"body"}->evaluate($self); 1 } } or do { my $e = $@; pop @{$$self{"_stack"};}; if (ref $e and ref $e eq "Zuzu::Control" and $e->{"_control"} eq "return") { my $value = $e->{"value"}; $self->_assert_return_type($fn, $value, $file, $line) unless $e->{"skip_type_check"}; return $value; } ; die $e } 523 54680 55203
6753 54680 my $e = $@;
6754 54680 pop @{$self->{_stack}}; # inlined $self->_pop_env
6755 54680 ▶ if (ref($e) && ref($e) eq 'Zuzu::Control' && $e->{_control} eq 'return') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $e and ref $e eq "Zuzu::Control" and $e->{"_control"} eq "return") 54671 9 54680
Condition66%4/6
ref $e and ref $e eq "Zuzu::Control" and $e->{"_control"} eq "return"
!ll&&!rl&&r
9054671
ref $e and ref $e eq "Zuzu::Control"
!ll&&!rl&&r
0954671
MC/DC33%1/3
ref $e and ref $e eq "Zuzu::Control" and $e->{"_control"} eq "return"
ref $e ref $e eq "Zuzu::Control" $e->{"_control"} eq "return"
Truth table50%2/4
A and B and C
A= ref $eB= ref $e eq "Zuzu::Control"C= $e->{"_control"} eq "return"
ABCresult
0XX0
10X0
1100
1111
6756 54671 my $value = $e->{value};
6757 $self->_assert_return_type( $fn, $value, $file, $line )
6758 54671 ▶ if !$e->{skip_type_check};
Branch: 1 branch
BranchTrueFalseTotal
unless $e->{"skip_type_check"} 54671 0 54671
6759 54671 return $value;
6760 }
6761 9 die $e;
6762 };
6763  
6764 523 pop @{$self->{_stack}}; # inlined $self->_pop_env
6765 523 $self->_assert_return_type( $fn, $ret, $file, $line );
6766  
6767 523 return $ret;
6768 }
6769  
6770 19350 ▶sub _call_function {
Subroutine _call_function: called CC=23 SCAR=32.0
6771 19350 my ( $self, $fn, $args, $named, $named_pairs, $file, $line, $arg_static_types ) = @_;
6772 19350 ▶ if ( defined $named and ref($named) ne 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $named and ref $named ne "HASH") 3 19347 19350
Condition66%2/3
defined $named and ref $named ne "HASH"
!ll&&!rl&&r
0193473
MC/DC50%1/2
defined $named and ref $named ne "HASH"
defined $named ref $named ne "HASH"
Truth table66%2/3
A and B
A= defined $namedB= ref $named ne "HASH"
ABresult
0X0
100
111
6773 3 $arg_static_types = $line;
6774 3 $line = $file;
6775 3 $file = $named_pairs;
6776 3 $named_pairs = [];
6777 3 $named = {};
6778 }
6779 19350 ▶ $named = $EMPTY_HASH if !defined $named;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $named 0 19350 19350
6780 19350 ▶ $named_pairs = $EMPTY_ARRAY if !defined $named_pairs;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $named_pairs 0 19350 19350
6781  
6782 19350 ▶ if ($fn->{_native}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fn->{"_native"}) 1053 18297 19350
6783 1053 local $self->{_native_call_file} = $file;
6784 1053 local $self->{_native_call_line} = $line;
6785 1053 ▶ if ( _named_pairs_count( $named_pairs ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (_named_pairs_count($named_pairs)) 8 1045 1053
6786 die Zuzu::Error->new_runtime(message => "Named arguments are not supported for native functions", file => $file, line => $line)
6787 8 ▶ if !$fn->{_native_accepts_named};
Branch: 1 branch
BranchTrueFalseTotal
unless $fn->{"_native_accepts_named"} 0 8 8
6788 8 return $fn->{_native}->( @$args, $named, $named_pairs );
6789 }
6790 1045 return $fn->{_native}->(@$args);
6791 }
6792 18297 ▶ if ( $fn->is_bodyless or !defined $fn->body ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fn->is_bodyless or not defined $fn->body) 0 18297 18297
Condition33%1/3
$fn->is_bodyless or not defined $fn->body
l!l&&r!l&&!r
0018297
MC/DC0%0/2
$fn->is_bodyless or not defined $fn->body
$fn->is_bodyless not defined $fn->body
Truth table33%1/3
A or not(B)
A= $fn->is_bodylessB= not defined $fn->body
ABresult
1X1
011
000
6793 0 die Zuzu::Error->new_runtime(
6794 message => "Function '".$fn->name."' has no body",
6795 file => $file,
6796 line => $line,
6797 );
6798 }
6799 18297 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($fn->is_async and !defined($self->{"_run_async_fn_ref"}) || $self->{"_run_async_fn_ref"} != builtin::refaddr($fn)) 51 18246 18297
Condition100%6/6
$fn->is_async and !defined($self->{"_run_async_fn_ref"}) || $self->{"_run_async_fn_ref"} != builtin::refaddr($fn)
!ll&&!rl&&r
181965051
not defined $self->{"_run_async_fn_ref"} or $self->{"_run_async_fn_ref"} != builtin::refaddr($fn)
l!l&&r!l&&!r
222950
MC/DC100%3/3
$fn->is_async and !defined($self->{"_run_async_fn_ref"}) || $self->{"_run_async_fn_ref"} != builtin::refaddr($fn)
$fn->is_async not defined $self->{"_run_async_fn_ref"} $self->{"_run_async_fn_ref"} != builtin::refaddr($fn)
Truth table100%4/4
A and not(B) or C
A= $fn->is_asyncB= not defined $self->{"_run_async_fn_ref"}C= $self->{"_run_async_fn_ref"} != builtin::refaddr($fn)
ABCresult
0XX0
1000
11X1
1011
6800 $fn->is_async
6801 and (
6802 !defined $self->{_run_async_fn_ref}
6803 or $self->{_run_async_fn_ref} != refaddr($fn)
6804 )
6805 ) {
6806 51 ▶ my @task_args = @{ $args // [] };
Condition50%1/2
$args // []
l!l
510
MC/DC0%0/1
$args // []
$args
Truth table50%1/2
A
A= $args
Aresult
11
00
6807 51 ▶ my %task_named = %{ $named // {} };
Condition50%1/2
$named // {}
l!l
510
MC/DC0%0/1
$named // {}
$named
Truth table50%1/2
A
A= $named
Aresult
11
00
6808 51 ▶ my @task_named_pairs = @{ $named_pairs // [] };
Condition50%1/2
$named_pairs // []
l!l
510
MC/DC0%0/1
$named_pairs // []
$named_pairs
Truth table50%1/2
A
A= $named_pairs
Aresult
11
00
6809 51 ▶ my @task_arg_static_types = @{ $arg_static_types // [] };
Condition100%2/2
$arg_static_types // []
l!l
2328
MC/DC100%1/1
$arg_static_types // []
$arg_static_types
Truth table100%2/2
A
A= $arg_static_types
Aresult
11
00
6810 return $self->_new_task(
6811 name => $fn->name // '<async>',
6812 schedule => 1,
6813 file => $file,
6814 line => $line,
6815 50 ▶ thunk => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
6816 50 local $self->{_run_async_fn_ref} = refaddr($fn);
6817 50 return $self->_call_function(
6818 $fn,
6819 \@task_args,
6820 \%task_named,
6821 \@task_named_pairs,
6822 $file,
6823 $line,
6824 \@task_arg_static_types,
6825 );
6826 },
6827 51 ▶ );
Condition50%1/2
$fn->name // "<async>"
l!l
510
MC/DC0%0/1
$fn->name // "<async>"
$fn->name
Truth table50%1/2
A
A= $fn->name
Aresult
11
00
6828 }
6829  
6830 18246 my $call_env = Zuzu::Env->_new_fast( $fn->{closure_env} );
6831 18246 push @{$self->{_stack}}, $call_env; # inlined $self->_push_env
6832  
6833 18246 my $ret;
6834 eval {
6835 18246 $self->_bind_function_params(
6836 $fn,
6837 $args,
6838 $named,
6839 $named_pairs,
6840 $call_env,
6841 $file,
6842 $line,
6843 $arg_static_types,
6844 );
6845 18239 $ret = $fn->{body}->evaluate($self);
6846 108 1;
6847 18246 ▶ } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $self->_bind_function_params($fn, $args, $named, $named_pairs, $call_env, $file, $line, $arg_static_types); $ret = $fn->{"body"}->evaluate($self); 1 } } or do { my $e = $@; pop @{$$self{"_stack"};}; if (ref $e and ref $e eq "Zuzu::Control" and $e->{"_control"} eq "return") { my $value = $e->{"value"}; $self->_assert_return_type($fn, $value, $file, $line) unless $e->{"skip_type_check"}; return $value; } ; die $e } 108 18138 18246
6848 18138 my $e = $@;
6849 18138 pop @{$self->{_stack}}; # inlined $self->_pop_env
6850 18138 ▶ if (ref($e) && ref($e) eq 'Zuzu::Control' && $e->{_control} eq 'return') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $e and ref $e eq "Zuzu::Control" and $e->{"_control"} eq "return") 18116 22 18138
Condition66%4/6
ref $e and ref $e eq "Zuzu::Control" and $e->{"_control"} eq "return"
!ll&&!rl&&r
22018116
ref $e and ref $e eq "Zuzu::Control"
!ll&&!rl&&r
02218116
MC/DC33%1/3
ref $e and ref $e eq "Zuzu::Control" and $e->{"_control"} eq "return"
ref $e ref $e eq "Zuzu::Control" $e->{"_control"} eq "return"
Truth table50%2/4
A and B and C
A= ref $eB= ref $e eq "Zuzu::Control"C= $e->{"_control"} eq "return"
ABCresult
0XX0
10X0
1100
1111
6851 18116 my $value = $e->{value};
6852 $self->_assert_return_type( $fn, $value, $file, $line )
6853 18116 ▶ if !$e->{skip_type_check};
Branch: 1 branch
BranchTrueFalseTotal
unless $e->{"skip_type_check"} 18114 2 18116
6854 18116 return $value;
6855 }
6856 22 die $e;
6857 };
6858  
6859 108 pop @{$self->{_stack}}; # inlined $self->_pop_env
6860 108 $self->_assert_return_type( $fn, $ret, $file, $line );
6861  
6862 108 return $ret;
6863 }
6864  
6865 73416 ▶sub _assert_return_type {
Subroutine _assert_return_type: called CC=4 SCAR=14.0
6866 73416 my ( $self, $fn, $value, $file, $line ) = @_;
6867  
6868 73416 ▶ my $declared_type = $fn->{return_type} // 'Any';
Condition50%1/2
$fn->{"return_type"} // "Any"
l!l
734160
MC/DC0%0/1
$fn->{"return_type"} // "Any"
$fn->{"return_type"}
Truth table50%1/2
A
A= $fn->{"return_type"}
Aresult
11
00
6869 73416 ▶ return if $declared_type eq 'Any';
Branch: 1 branch
BranchTrueFalseTotal
if $declared_type eq "Any" 58208 15208 73416
6870  
6871 15208 ▶ my $name = $fn->{name} // '<anon>';
Condition50%1/2
$fn->{"name"} // "<anon>"
l!l
152080
MC/DC0%0/1
$fn->{"name"} // "<anon>"
$fn->{"name"}
Truth table50%1/2
A
A= $fn->{"name"}
Aresult
11
00
6872 15208 $self->_assert_declared_type( $declared_type, $value, $file, $line, "return value of '$name'" );
6873  
6874 15208 return;
6875 }
6876  
6877 1227 ▶sub _validate_arity {
Subroutine _validate_arity: called CC=11 SCAR=29.6
6878 1227 my ($self, $fn, $args, $named_pairs, $file, $line, $binding_plan) = @_;
6879  
6880 1227 ▶ $binding_plan //= $self->_function_binding_plan($fn);
Condition33%1/3
$binding_plan //= $self->_function_binding_plan($fn)
l!l&&r!l&&!r
122700
MC/DC0%0/2
$binding_plan //= $self->_function_binding_plan($fn)
$binding_plan $self->_function_binding_plan($fn)
Truth table33%1/3
A //= B
A= $binding_planB= $self->_function_binding_plan($fn)
ABresult
1X1
011
000
6881 1227 my $required = $binding_plan->{required};
6882 1227 ▶ my $given = scalar @{ $args // [] };
Condition50%1/2
$args // []
l!l
12270
MC/DC0%0/1
$args // []
$args
Truth table50%1/2
A
A= $args
Aresult
11
00
6883 1227 my $total = $binding_plan->{total};
6884 1227 ▶ if ( scalar @{ $named_pairs // [] } and ! $binding_plan->{has_named_vararg} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$named_pairs // [];} and not $binding_plan->{"has_named_vararg"}) 0 1227 1227
Condition60%3/5
scalar @{$named_pairs // [];} and not $binding_plan->{"has_named_vararg"}
!ll&&!rl&&r
122430
$named_pairs // []
l!l
12270
MC/DC0%0/2
scalar @{$named_pairs // [];} and not $binding_plan->{"has_named_vararg"}
scalar @{$named_pairs // [];} not $binding_plan->{"has_named_vararg"}
MC/DC0%0/1
$named_pairs // []
$named_pairs
Truth table66%2/3
A and not(B)
A= scalar @{$named_pairs // [];}B= not $binding_plan->{"has_named_vararg"}
ABresult
0X0
100
111
Truth table50%1/2
A
A= $named_pairs
Aresult
11
00
6885 0 die Zuzu::Error->new_runtime(
6886 message => "Function '".$fn->name."' does not accept named arguments",
6887 file => $file,
6888 line => $line,
6889 );
6890 }
6891  
6892 1227 ▶ if ( $binding_plan->{has_vararg} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($binding_plan->{"has_vararg"}) 4 1223 1227
6893 4 ▶ if ( $given < $required ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($given < $required) 0 4 4
6894 0 die Zuzu::Error->new_runtime(
6895 message => "Too few arguments for function '".$fn->name."' (expected at least $required, got $given)",
6896 file => $file,
6897 line => $line,
6898 );
6899 }
6900  
6901 4 return;
6902 }
6903  
6904 1223 ▶ if ( $given < $required || $given > $total ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($given < $required or $given > $total) 0 1223 1223
Condition33%1/3
$given < $required or $given > $total
l!l&&r!l&&!r
001223
MC/DC0%0/2
$given < $required or $given > $total
$given < $required $given > $total
Truth table33%1/3
A or B
A= $given < $requiredB= $given > $total
ABresult
1X1
011
000
6905 0 ▶ my $expected = $required == $total
Branch: 1 branch
BranchTrueFalseTotal
$required == $total ? : 0 0 0
6906 ? "$total"
6907 : "$required to $total";
6908 0 die Zuzu::Error->new_runtime(
6909 message => "Wrong number of arguments for function '".$fn->name."' (expected $expected, got $given)",
6910 file => $file,
6911 line => $line,
6912 );
6913 }
6914 }
6915  
6916 73449 ▶sub _bind_function_params {
Subroutine _bind_function_params: called CC=27 SCAR=33.3
6917 73449 my ( $self, $fn, $args, $named, $named_pairs, $call_env, $file, $line, $arg_static_types ) = @_;
6918  
6919 73449 my $binding_plan = $self->_function_binding_plan( $fn );
6920 73449 my $params = $binding_plan->{params};
6921 73449 ▶ my $arg_count = scalar @{ $args // [] };
Condition50%1/2
$args // []
l!l
734490
MC/DC0%0/1
$args // []
$args
Truth table50%1/2
A
A= $args
Aresult
11
00
6922 73449 ▶ if ( $binding_plan->{simple_bind} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($binding_plan->{"simple_bind"}) 72222 1227 73449
6923 72222 ▶ if ( $arg_count != $binding_plan->{total} or scalar @{ $named_pairs // [] } ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($arg_count != $binding_plan->{"total"} or scalar @{$named_pairs // [];}) 0 72222 72222
Condition50%2/4
$arg_count != $binding_plan->{"total"} or scalar @{$named_pairs // [];}
l!l
072222
$named_pairs // []
l!l
722220
MC/DC0%0/1
$arg_count != $binding_plan->{"total"} or scalar @{$named_pairs // [];}
$arg_count != $binding_plan->{"total"}
MC/DC0%0/1
$named_pairs // []
$named_pairs
Truth table50%1/2
A
A= $arg_count != $binding_plan->{"total"}
Aresult
11
00
Truth table50%1/2
A
A= $named_pairs
Aresult
11
00
6924 0 $self->_validate_arity( $fn, $args, $named_pairs, $file, $line, $binding_plan );
6925 }
6926 72222 my $slots = $call_env->{slots};
6927 72222 my $const = $call_env->{const};
6928 72222 my $types = $call_env->{types};
6929 72222 my $weak = $call_env->{weak};
6930 72222 ▶ die "Internal redeclare __argc__" if exists $slots->{__argc__};
Branch: 1 branch
BranchTrueFalseTotal
if exists $slots->{"__argc__"} 0 72222 72222
6931  
6932 72222 my @values = ( 0 + $arg_count, @{ $args } );
6933 72222 $slots->{__argc__} = \$values[0];
6934 72222 $const->{__argc__} = 1;
6935 72222 $types->{__argc__} = 'Number';
6936 72222 $weak->{__argc__} = 0;
6937  
6938 72222 for my $i ( 0 .. $#{ $params } ) {
6939 32823 my $name = $params->[$i];
6940 32823 ▶ die "Internal redeclare $name" if exists $slots->{$name};
Branch: 1 branch
BranchTrueFalseTotal
if exists $slots->{$name} 0 32823 32823
6941 32823 $slots->{$name} = \$values[ $i + 1 ];
6942 32823 $const->{$name} = 1;
6943 32823 $types->{$name} = 'Any';
6944 32823 $weak->{$name} = 0;
6945 }
6946  
6947 72222 return;
6948 }
6949 1227 $self->_validate_arity( $fn, $args, $named_pairs, $file, $line, $binding_plan );
6950 1227 $call_env->declare( '__argc__', 0 + $arg_count, 1, 'Number' );
6951  
6952 1227 for my $i ( 0 .. $#{ $params } ) {
6953 2643 my $name = $params->[$i];
6954 2643 my $declared_type = $binding_plan->{declared_types}[$i];
6955 2643 ▶ my $has_arg = $i < $arg_count ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$i < $arg_count ? : 2456 187 2643
6956 2643 my $value;
6957 2643 ▶ if ( $has_arg ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($has_arg) { } 2456 187 2643
elsif ($binding_plan->{'has_defaults'}[$i]) { } 13 174 187
6958 2456 $value = $args->[$i];
6959 2456 ▶ if ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 2402 54 2456
6960 2402 ▶ my $static_type = defined $arg_static_types ? $arg_static_types->[$i] : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $arg_static_types ? : 2355 47 2402
6961 2402 ▶ my $skip_type_check = defined $static_type && $declared_type eq $static_type ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $static_type && $declared_type eq $static_type ? : 939 1463 2402
Condition100%3/3
defined $static_type and $declared_type eq $static_type
!ll&&!rl&&r
142340939
MC/DC100%2/2
defined $static_type and $declared_type eq $static_type
defined $static_type $declared_type eq $static_type
Truth table100%3/3
A and B
A= defined $static_typeB= $declared_type eq $static_type
ABresult
0X0
100
111
6962 2402 ▶ $self->_assert_declared_type( $declared_type, $value, $file, $line, $name )
Branch: 1 branch
BranchTrueFalseTotal
unless $skip_type_check 1463 939 2402
6963 if !$skip_type_check;
6964 }
6965 }
6966 elsif ( $binding_plan->{has_defaults}[$i] ) {
6967 13 $value = $binding_plan->{default_exprs}[$i]->evaluate($self);
6968 13 ▶ if ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 13 0 13
6969 13 ▶ my $skip_type_check = $binding_plan->{default_typecheck_safe}[$i] ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$binding_plan->{'default_typecheck_safe'}[$i] ? : 13 0 13
6970 13 ▶ $self->_assert_declared_type( $declared_type, $value, $file, $line, $name )
Branch: 1 branch
BranchTrueFalseTotal
unless $skip_type_check 0 13 13
6971 if !$skip_type_check;
6972 }
6973 }
6974 else {
6975 174 $value = undef;
6976 }
6977 2634 $call_env->declare( $name, $value, 1, $declared_type );
6978 }
6979  
6980 1218 ▶ if ( defined $fn->vararg ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fn->vararg) 4 1214 1218
6981 4 my $param_count = scalar @{ $params };
6982 4 ▶ my @rest = @$args[$param_count .. $#$args] if @$args > $param_count;
Branch: 1 branch
BranchTrueFalseTotal
if @$args > $param_count 1 3 4
6983 4 my $rest_arr = Zuzu::Value::Array->new(items => \@rest);
6984 4 ▶ my $declared_type = $fn->vararg_type // 'Any';
Condition50%1/2
$fn->vararg_type // "Any"
l!l
40
MC/DC0%0/1
$fn->vararg_type // "Any"
$fn->vararg_type
Truth table50%1/2
A
A= $fn->vararg_type
Aresult
11
00
6985 4 $self->_assert_declared_type( $declared_type, $rest_arr, $file, $line, $fn->vararg );
6986 4 $call_env->declare( $fn->vararg, $rest_arr, 1, $declared_type );
6987 }
6988 1218 ▶ if ( defined $fn->named_vararg ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fn->named_vararg) 4 1214 1218
6989 4 ▶ my @pairs = map { [ $_->[0], $_->[1] ] } @{ $named_pairs // [] };
Condition50%1/2
$named_pairs // []
l!l
40
MC/DC0%0/1
$named_pairs // []
$named_pairs
Truth table50%1/2
A
A= $named_pairs
Aresult
11
00
6990 4 my $pairlist = Zuzu::Value::PairList->new( list => \@pairs );
6991 4 ▶ my $declared_type = $fn->named_vararg_type // 'PairList';
Condition50%1/2
$fn->named_vararg_type // "PairList"
l!l
40
MC/DC0%0/1
$fn->named_vararg_type // "PairList"
$fn->named_vararg_type
Truth table50%1/2
A
A= $fn->named_vararg_type
Aresult
11
00
6992 4 $self->_assert_declared_type( $declared_type, $pairlist, $file, $line, $fn->named_vararg );
6993 4 $call_env->declare( $fn->named_vararg, $pairlist, 1, $declared_type );
6994 }
6995  
6996 1218 return;
6997 }
6998  
6999 73449 ▶sub _function_binding_plan {
Subroutine _function_binding_plan: called CC=23 SCAR=31.5
7000 73449 my ( $self, $fn ) = @_;
7001  
7002 73449 my $plan = $fn->{_binding_plan};
7003 73449 ▶ return $plan if defined $plan;
Branch: 1 branch
BranchTrueFalseTotal
if defined $plan 71046 2403 73449
7004  
7005 2403 ▶ my @params = @{ $fn->{params} // [] };
Condition50%1/2
$fn->{"params"} // []
l!l
24030
MC/DC0%0/1
$fn->{"params"} // []
$fn->{"params"}
Truth table50%1/2
A
A= $fn->{"params"}
Aresult
11
00
7006 2403 my @declared_types;
7007 my @has_defaults;
7008 2403 my @default_exprs;
7009 2403 my @default_typecheck_safe;
7010 2403 my $required = 0;
7011 2403 my $all_types_any = 1;
7012 2403 my $has_any_default = 0;
7013 2403 ▶ my $param_types = $fn->{param_types} // {};
Condition50%1/2
$fn->{"param_types"} // {}
l!l
24030
MC/DC0%0/1
$fn->{"param_types"} // {}
$fn->{"param_types"}
Truth table50%1/2
A
A= $fn->{"param_types"}
Aresult
11
00
7014 2403 ▶ my $param_optional = $fn->{param_optional} // {};
Condition50%1/2
$fn->{"param_optional"} // {}
l!l
24030
MC/DC0%0/1
$fn->{"param_optional"} // {}
$fn->{"param_optional"}
Truth table50%1/2
A
A= $fn->{"param_optional"}
Aresult
11
00
7015 2403 ▶ my $param_defaults = $fn->{param_defaults} // {};
Condition50%1/2
$fn->{"param_defaults"} // {}
l!l
24030
MC/DC0%0/1
$fn->{"param_defaults"} // {}
$fn->{"param_defaults"}
Truth table50%1/2
A
A= $fn->{"param_defaults"}
Aresult
11
00
7016 2403 ▶ my $default_typecheck_safe = $fn->{_default_typecheck_safe} // {};
Condition50%1/2
$fn->{"_default_typecheck_safe"} // {}
l!l
24030
MC/DC0%0/1
$fn->{"_default_typecheck_safe"} // {}
$fn->{"_default_typecheck_safe"}
Truth table50%1/2
A
A= $fn->{"_default_typecheck_safe"}
Aresult
11
00
7017 2403 for my $name ( @params ) {
7018 2108 ▶ my $has_default = exists $param_defaults->{$name} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
exists $param_defaults->{$name} ? : 56 2052 2108
7019 2108 ▶ $has_any_default ||= $has_default;
Condition100%3/3
$has_any_default ||= $has_default
l!l&&r!l&&!r
18382052
MC/DC100%2/2
$has_any_default ||= $has_default
$has_any_default $has_default
Truth table100%3/3
A ||= B
A= $has_any_defaultB= $has_default
ABresult
1X1
011
000
7020 2108 ▶ my $is_optional = $param_optional->{$name} || $has_default;
Condition100%3/3
$param_optional->{$name} || $has_default
l!l&&r!l&&!r
91561961
MC/DC100%2/2
$param_optional->{$name} || $has_default
$param_optional->{$name} $has_default
Truth table100%3/3
A || B
A= $param_optional->{$name}B= $has_default
ABresult
1X1
011
000
7021 2108 ▶ $required++ if !$is_optional;
Branch: 1 branch
BranchTrueFalseTotal
unless $is_optional 1961 147 2108
7022 2108 ▶ my $declared_type = $param_types->{$name} // 'Any';
Condition50%1/2
$param_types->{$name} // "Any"
l!l
21080
MC/DC0%0/1
$param_types->{$name} // "Any"
$param_types->{$name}
Truth table50%1/2
A
A= $param_types->{$name}
Aresult
11
00
7023 2108 ▶ $all_types_any = 0 if $declared_type ne 'Any';
Branch: 1 branch
BranchTrueFalseTotal
if $declared_type ne "Any" 456 1652 2108
7024 2108 push @declared_types, $declared_type;
7025 2108 push @has_defaults, $has_default;
7026 2108 ▶ push @default_exprs, $has_default ? $param_defaults->{$name} : undef;
Branch: 1 branch
BranchTrueFalseTotal
$has_default ? : 56 2052 2108
7027 2108 ▶ push @default_typecheck_safe, $default_typecheck_safe->{$name} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$default_typecheck_safe->{$name} ? : 56 2052 2108
7028 }
7029 2403 ▶ my $has_vararg = defined $fn->{vararg} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $fn->{'vararg'} ? : 2 2401 2403
7030 2403 ▶ my $has_named_vararg = defined $fn->{named_vararg} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $fn->{'named_vararg'} ? : 2 2401 2403
7031  
7032 2403 ▶ $plan = {
Branch: 1 branch
BranchTrueFalseTotal
$all_types_any && !$has_any_default && !$has_vararg && !$has_named_vararg && $required == @params ? : 2039 364 2403
Condition91%11/12
$all_types_any and not $has_any_default and not $has_vararg and not $has_named_vararg and $required == @params
!ll&&!rl&&r
337272039
$all_types_any and not $has_any_default and not $has_vararg and not $has_named_vararg
!ll&&!rl&&r
33702066
$all_types_any and not $has_any_default and not $has_vararg
!ll&&!rl&&r
33522066
$all_types_any and not $has_any_default
!ll&&!rl&&r
299362068
MC/DC80%4/5
$all_types_any and not $has_any_default and not $has_vararg and not $has_named_vararg and $required == @params
$all_types_any not $has_any_default not $has_vararg not $has_named_vararg $required == @params
Truth table83%5/6
A and not(B) and not(C) and not(D) and E
A= $all_types_anyB= not $has_any_defaultC= not $has_varargD= not $has_named_varargE= $required == @params
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
7033 params => \@params,
7034 declared_types => \@declared_types,
7035 has_defaults => \@has_defaults,
7036 default_exprs => \@default_exprs,
7037 default_typecheck_safe => \@default_typecheck_safe,
7038 required => $required,
7039 total => scalar @params,
7040 has_vararg => $has_vararg,
7041 has_named_vararg => $has_named_vararg,
7042 simple_bind => (
7043 $all_types_any
7044 and !$has_any_default
7045 and !$has_vararg
7046 and !$has_named_vararg
7047 and $required == @params
7048 ) ? 1 : 0,
7049 };
7050 2403 $fn->{_binding_plan} = $plan;
7051  
7052 2403 return $plan;
7053 }
7054  
7055 # === Module loading ===
7056  
7057 343 ▶sub _module_search_paths {
Subroutine _module_search_paths: called CC=8 SCAR=21.5
7058 343 my ( $self, $module, $from_file ) = @_;
7059  
7060 343 my @paths;
7061 343 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (defined $from_file and $from_file ne "" and not $from_file =~ /\A</ and $from_file ne "(command line)") 339 4 343
Condition55%5/9
defined $from_file and $from_file ne "" and not $from_file =~ /\A</ and $from_file ne "(command line)"
!ll&&!rl&&r
40339
defined $from_file and $from_file ne "" and not $from_file =~ /\A</
!ll&&!rl&&r
04339
defined $from_file and $from_file ne ""
!ll&&!rl&&r
00343
MC/DC25%1/4
defined $from_file and $from_file ne "" and not $from_file =~ /\A</ and $from_file ne "(command line)"
defined $from_file $from_file ne "" not $from_file =~ /\A</ $from_file ne "(command line)"
Truth table40%2/5
A and B and not(C) and D
A= defined $from_fileB= $from_file ne ""C= not $from_file =~ /\A</D= $from_file ne "(command line)"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
7062 defined $from_file
7063 and $from_file ne ''
7064 and $from_file !~ /\A</
7065 and $from_file ne '(command line)'
7066 ) {
7067 339 my $local_lib = File::Spec->catdir( dirname($from_file), 'lib' );
7068 339 ▶ push @paths, $local_lib if -d $local_lib;
Branch: 1 branch
BranchTrueFalseTotal
if -d $local_lib 30 309 339
7069 }
7070 343 ▶ push @paths, @{$self->lib // []};
Condition50%1/2
$self->lib // []
l!l
3430
MC/DC0%0/1
$self->lib // []
$self->lib
Truth table50%1/2
A
A= $self->lib
Aresult
11
00
7071  
7072 343 my %seen;
7073 343 ▶ @paths = grep { defined $_ and !$seen{$_}++ } @paths;
Condition66%2/3
defined $_ && !$seen{$_}++
!ll&&!rl&&r
012626
MC/DC50%1/2
defined $_ && !$seen{$_}++
defined $_ !$seen{$_}++
Truth table66%2/3
A && not(B)
A= defined $_B= !$seen{$_}++
ABresult
0X0
100
111
7074  
7075 343 return @paths;
7076 }
7077  
7078 343 ▶sub _module_candidates {
Subroutine _module_candidates: called CC=10 SCAR=32.0
7079 343 my ( $self, $module, $from_file ) = @_;
7080  
7081 343 ▶ my $lib_key = join "\x1e", @{ $self->lib // [] };
Condition50%1/2
$self->lib // []
l!l
3430
MC/DC0%0/1
$self->lib // []
$self->lib
Truth table50%1/2
A
A= $self->lib
Aresult
11
00
7082 343 ▶ my $from_key = defined $from_file ? $from_file : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $from_file ? : 343 0 343
7083 343 my $cache_key = join "\x1f", $module, $from_key, $lib_key;
7084 343 ▶ if ( exists $self->{_module_candidate_cache}{$cache_key} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"_module_candidate_cache"}{$cache_key}) 0 343 343
7085 0 return @{ $self->{_module_candidate_cache}{$cache_key} };
7086 }
7087  
7088 343 my @out;
7089 343 ▶ if ( File::Spec->file_name_is_absolute($module) or $module =~ /\A\.\.?(?:[\/\\]|\z)/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ('File::Spec'->file_name_is_absolute($module) or $module =~ m(\A\.\.?(?:[/\\]|\z))) { } 0 343 343
Condition33%1/3
"File::Spec"->file_name_is_absolute($module) or $module =~ m(\A\.\.?(?:[/\\]|\z))
l!l&&r!l&&!r
00343
MC/DC0%0/2
"File::Spec"->file_name_is_absolute($module) or $module =~ m(\A\.\.?(?:[/\\]|\z))
"File::Spec"->file_name_is_absolute($module) $module =~ m(\A\.\.?(?:[/\\]|\z))
Truth table33%1/3
A or B
A= "File::Spec"->file_name_is_absolute($module)B= $module =~ m(\A\.\.?(?:[/\\]|\z))
ABresult
1X1
011
000
7090 0 ▶ my $base = (
Branch: 1 branch
BranchTrueFalseTotal
defined $from_file && $from_file ne '' && !($from_file =~ /\A</) ? : 0 0 0
Condition0%0/6
defined $from_file and $from_file ne "" and not $from_file =~ /\A</
!ll&&!rl&&r
000
defined $from_file and $from_file ne ""
!ll&&!rl&&r
000
MC/DC0%0/3
defined $from_file and $from_file ne "" and not $from_file =~ /\A</
defined $from_file $from_file ne "" not $from_file =~ /\A</
Truth table0%0/4
A and B and not(C)
A= defined $from_fileB= $from_file ne ""C= not $from_file =~ /\A</
ABCresult
0XX0
10X0
1100
1111
7091 defined $from_file
7092 and $from_file ne ''
7093 and $from_file !~ /\A</
7094 ) ? dirname($from_file) : $INITIAL_CWD;
7095 0 ▶ my $path = File::Spec->file_name_is_absolute($module)
Branch: 1 branch
BranchTrueFalseTotal
'File::Spec'->file_name_is_absolute($module) ? : 0 0 0
7096 ? $module
7097 : File::Spec->catfile( $base, $module );
7098 0 @out = ( "$path.zzm", "$path.zzs" );
7099 }
7100 else {
7101 343 my @paths = $self->_module_search_paths( $module, $from_file );
7102 @out = map {
7103 343 my $base = $_;
7104 (
7105 626 File::Spec->catfile( $base, "$module.zzm" ),
7106 File::Spec->catfile( $base, "$module.zzs" ),
7107 );
7108 } @paths;
7109 }
7110 343 $self->{_module_candidate_cache}{$cache_key} = [ @out ];
7111  
7112 343 return @out;
7113 }
7114  
7115 9 ▶sub _module_not_found_message {
Subroutine _module_not_found_message: called CC=1 SCAR=0.0
7116 9 my ( $self, $module, $from_file ) = @_;
7117  
7118 9 return "Cannot find module '$module' in lib paths";
7119 }
7120  
7121 547 ▶sub _refresh_module_builtin_alias_cache {
Subroutine _refresh_module_builtin_alias_cache: called CC=4 SCAR=13.9
7122 547 my ( $self ) = @_;
7123  
7124 547 my @aliases;
7125 my %slot_set;
7126 547 for my $k ( sort CORE::keys %{ $self->{_builtin_global_names} } ) {
7127 19145 my $ref = $self->{_global}{slots}{$k};
7128 19145 ▶ next if !defined $ref;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ref 0 19145 19145
7129 19145 $slot_set{$k} = 1;
7130 push @aliases, [
7131 $k,
7132 $ref,
7133 19145 ▶ ( $self->{_global}{const}{$k} ? 1 : 0 ),
Branch: 1 branch
BranchTrueFalseTotal
$self->{'_global'}{'const'}{$k} ? : 18598 547 19145
7134 ];
7135 }
7136 547 $self->{_module_builtin_aliases} = \@aliases;
7137 547 $self->{_module_builtin_slot_set} = \%slot_set;
7138  
7139 547 return;
7140 }
7141  
7142 1360 ▶sub _file_value_for_path {
Subroutine _file_value_for_path: called CC=12 SCAR=26.6
7143 1360 my ( $self, $path, $force_absolute ) = @_;
7144  
7145 1360 ▶ return undef if $self->is_denied( 'fs' );
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_denied("fs") 8 1352 1360
7146 1352 ▶ return undef if !defined $path or $path eq '' or $path =~ /\A</;
Branch: 1 branch
BranchTrueFalseTotal
if not defined $path or $path eq "" or $path =~ /\A</ 61 1291 1352
Condition50%3/6
not defined $path or $path eq "" or $path =~ /\A</
l!l&&r!l&&!r
0611291
not defined $path or $path eq ""
l!l&&r!l&&!r
001352
MC/DC33%1/3
not defined $path or $path eq "" or $path =~ /\A</
not defined $path $path eq "" $path =~ /\A</
Truth table50%2/4
not(A) or B or C
A= not defined $pathB= $path eq ""C= $path =~ /\A</
ABCresult
1XX1
01X1
0011
0000
7147 1291 ▶ return undef if $path eq '(command line)';
Branch: 1 branch
BranchTrueFalseTotal
if $path eq "(command line)" 0 1291 1291
7148  
7149 1291 ▶ my $file_path = $force_absolute
Branch: 1 branch
BranchTrueFalseTotal
$force_absolute ? : 813 478 1291
7150 ? File::Spec->rel2abs( $path, $INITIAL_CWD )
7151 : $path;
7152 1291 my $module_env = eval { $self->_load_module( 'std/io', $file_path, 0 ) };
7153 1291 ▶ return undef if !defined $module_env;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $module_env 2 1289 1291
7154 1289 my $class_ref = $module_env->find_ref('Path');
7155 1289 ▶ return undef if !defined $class_ref;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $class_ref 0 1289 1289
7156 1289 my $path_class = ${ $class_ref };
7157 return undef
7158 1289 ▶ if !blessed($path_class)
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($path_class) and $path_class->isa("Zuzu::Value::Class") and $path_class->native_constructor 0 1289 1289
Condition33%2/6
builtin::blessed($path_class) and $path_class->isa("Zuzu::Value::Class") and $path_class->native_constructor
!ll&&!rl&&r
001289
builtin::blessed($path_class) and $path_class->isa("Zuzu::Value::Class")
!ll&&!rl&&r
001289
MC/DC0%0/3
builtin::blessed($path_class) and $path_class->isa("Zuzu::Value::Class") and $path_class->native_constructor
builtin::blessed($path_class) $path_class->isa("Zuzu::Value::Class") $path_class->native_constructor
Truth table25%1/4
A and B and C
A= builtin::blessed($path_class)B= $path_class->isa("Zuzu::Value::Class")C= $path_class->native_constructor
ABCresult
0XX0
10X0
1100
1111
7159 or !$path_class->isa('Zuzu::Value::Class')
7160 or !$path_class->native_constructor;
7161  
7162 1289 return $path_class->native_constructor->(
7163 $self,
7164 $path_class,
7165 [ $file_path ],
7166 {},
7167 $file_path,
7168 0,
7169 );
7170 }
7171  
7172 1360 ▶sub _declare_file_const {
Subroutine _declare_file_const: called CC=3 SCAR=12.0
7173 1360 my ( $self, $env, $path, $force_absolute ) = @_;
7174  
7175 1360 ▶ return if !defined $env or $env->{slots}{'__file__'};
Branch: 1 branch
BranchTrueFalseTotal
if not defined $env or $env->{"slots"}{"__file__"} 0 1360 1360
Condition33%1/3
not defined $env or $env->{"slots"}{"__file__"}
l!l&&r!l&&!r
001360
MC/DC0%0/2
not defined $env or $env->{"slots"}{"__file__"}
not defined $env $env->{"slots"}{"__file__"}
Truth table33%1/3
not(A) or B
A= not defined $envB= $env->{"slots"}{"__file__"}
ABresult
1X1
011
000
7176 1360 $env->declare(
7177 '__file__',
7178 $self->_file_value_for_path( $path, $force_absolute ),
7179 1,
7180 );
7181  
7182 1360 return;
7183 }
7184  
7185 819 ▶sub _module_path_cache_key {
Subroutine _module_path_cache_key: called CC=3 SCAR=11.3
7186 819 my ( $self, $module, $from_file ) = @_;
7187  
7188 819 ▶ my $lib_key = join "\x1e", @{ $self->lib // [] };
Condition50%1/2
$self->lib // []
l!l
8190
MC/DC0%0/1
$self->lib // []
$self->lib
Truth table50%1/2
A
A= $self->lib
Aresult
11
00
7189 819 ▶ my $from_key = defined $from_file ? $from_file : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $from_file ? : 819 0 819
7190  
7191 819 return join "\x1f", $module, $from_key, $lib_key;
7192 }
7193  
7194 819 ▶sub _resolve_module_file {
Subroutine _resolve_module_file: called CC=5 SCAR=16.1
7195 819 my ( $self, $module, $from_file ) = @_;
7196  
7197 819 my $cache_key = $self->_module_path_cache_key( $module, $from_file );
7198 819 my $cached = $MODULE_PATH_CACHE{ $cache_key };
7199 819 ▶ if ( defined $cached and -f $cached ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $cached and -f $cached) 476 343 819
Condition66%2/3
defined $cached and -f $cached
!ll&&!rl&&r
3430476
MC/DC50%1/2
defined $cached and -f $cached
defined $cached -f $cached
Truth table66%2/3
A and B
A= defined $cachedB= -f $cached
ABresult
0X0
100
111
7200 476 return $cached;
7201 }
7202  
7203 343 for my $cand ( $self->_module_candidates( $module, $from_file ) ) {
7204 379 ▶ next if !-f $cand;
Branch: 1 branch
BranchTrueFalseTotal
unless -f $cand 42 337 379
7205 337 $MODULE_PATH_CACHE{ $cache_key } = $cand;
7206 337 return $cand;
7207 }
7208  
7209 6 delete $MODULE_PATH_CACHE{ $cache_key };
7210  
7211 6 return undef;
7212 }
7213  
7214 359 ▶sub _persistent_ast_cache_root_path {
Subroutine _persistent_ast_cache_root_path: called CC=8 SCAR=27.1
7215 359 ▶ return $PERSISTENT_AST_CACHE_ROOT
Branch: 1 branch
BranchTrueFalseTotal
if defined $Zuzu::Runtime::PERSISTENT_AST_CACHE_ROOT and $Zuzu::Runtime::PERSISTENT_AST_CACHE_ROOT ne "" 13 346 359
Condition66%2/3
defined $Zuzu::Runtime::PERSISTENT_AST_CACHE_ROOT and $Zuzu::Runtime::PERSISTENT_AST_CACHE_ROOT ne ""
!ll&&!rl&&r
346013
MC/DC50%1/2
defined $Zuzu::Runtime::PERSISTENT_AST_CACHE_ROOT and $Zuzu::Runtime::PERSISTENT_AST_CACHE_ROOT ne ""
defined $Zuzu::Runtime::PERSISTENT_AST_CACHE_ROOT $Zuzu::Runtime::PERSISTENT_AST_CACHE_ROOT ne ""
Truth table66%2/3
A and B
A= defined $Zuzu::Runtime::PERSISTENT_AST_CACHE_ROOTB= $Zuzu::Runtime::PERSISTENT_AST_CACHE_ROOT ne ""
ABresult
0X0
100
111
7216 if defined $PERSISTENT_AST_CACHE_ROOT
7217 and $PERSISTENT_AST_CACHE_ROOT ne '';
7218  
7219 346 ▶ if ( $^O eq 'MSWin32' and defined $ENV{LOCALAPPDATA} and $ENV{LOCALAPPDATA} ne '' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq "MSWin32" and defined $ENV{"LOCALAPPDATA"} and $ENV{"LOCALAPPDATA"} ne "") 0 346 346
Condition33%2/6
$^O eq "MSWin32" and defined $ENV{"LOCALAPPDATA"} and $ENV{"LOCALAPPDATA"} ne ""
!ll&&!rl&&r
34600
$^O eq "MSWin32" and defined $ENV{"LOCALAPPDATA"}
!ll&&!rl&&r
34600
MC/DC0%0/3
$^O eq "MSWin32" and defined $ENV{"LOCALAPPDATA"} and $ENV{"LOCALAPPDATA"} ne ""
$^O eq "MSWin32" defined $ENV{"LOCALAPPDATA"} $ENV{"LOCALAPPDATA"} ne ""
Truth table25%1/4
A and B and C
A= $^O eq "MSWin32"B= defined $ENV{"LOCALAPPDATA"}C= $ENV{"LOCALAPPDATA"} ne ""
ABCresult
0XX0
10X0
1100
1111
7220 0 return File::Spec->catdir( $ENV{LOCALAPPDATA}, 'Zuzu', 'cache', 'zuzu-perl' );
7221 }
7222  
7223 return File::Spec->catdir( $ENV{HOME}, '.zuzu', 'cache', 'zuzu-perl' )
7224 346 ▶ if defined $ENV{HOME} and $ENV{HOME} ne '';
Branch: 1 branch
BranchTrueFalseTotal
if defined $ENV{"HOME"} and $ENV{"HOME"} ne "" 346 0 346
Condition33%1/3
defined $ENV{"HOME"} and $ENV{"HOME"} ne ""
!ll&&!rl&&r
00346
MC/DC0%0/2
defined $ENV{"HOME"} and $ENV{"HOME"} ne ""
defined $ENV{"HOME"} $ENV{"HOME"} ne ""
Truth table33%1/3
A and B
A= defined $ENV{"HOME"}B= $ENV{"HOME"} ne ""
ABresult
0X0
100
111
7225  
7226 0 return undef;
7227 }
7228  
7229 358 ▶sub _persistent_ast_cache_root {
Subroutine _persistent_ast_cache_root: called CC=2 SCAR=7.1
7230 358 my ( $self ) = @_;
7231  
7232 358 ▶ return undef if !$self->persistent_ast_cache;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->persistent_ast_cache 0 358 358
7233  
7234 358 return _persistent_ast_cache_root_path();
7235 }
7236  
7237 1 ▶sub clear_persistent_ast_cache {
Subroutine clear_persistent_ast_cache: called CC=8 SCAR=25.1
Pod undocumented
7238 1 my ( $self ) = @_;
7239  
7240 1 my $root = _persistent_ast_cache_root_path();
7241 1 ▶ return if !defined $root or $root eq '' or !-d $root;
Branch: 1 branch
BranchTrueFalseTotal
if not defined $root or $root eq "" or not -d $root 0 1 1
Condition33%2/6
not defined $root or $root eq "" or not -d $root
l!l&&r!l&&!r
001
not defined $root or $root eq ""
l!l&&r!l&&!r
001
MC/DC0%0/3
not defined $root or $root eq "" or not -d $root
not defined $root $root eq "" not -d $root
Truth table25%1/4
not(A) or B or not(C)
A= not defined $rootB= $root eq ""C= not -d $root
ABCresult
1XX1
01X1
0011
0000
7242  
7243 1 eval {
7244 1 ▶ opendir my $dh, $root
Branch: 1 branch
BranchTrueFalseTotal
opendir my $dh, $root or return 1 0 1
7245 or return;
7246 1 ▶ while ( defined( my $name = readdir $dh ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $name = readdir $dh)) 2 1 3
7247 2 ▶ next if $name !~ /(?:\.stor\z|\A\.ast-cache-)/;
Branch: 1 branch
BranchTrueFalseTotal
unless $name =~ /(?:\.stor\z|\A\.ast-cache-)/ 2 0 2
7248 0 my $path = File::Spec->catfile( $root, $name );
7249 0 ▶ unlink $path if -f $path;
Branch: 1 branch
BranchTrueFalseTotal
if -f $path 0 0 0
7250 }
7251 1 closedir $dh;
7252 };
7253  
7254 1 return;
7255 }
7256  
7257 232 ▶sub _read_module_source_bytes {
Subroutine _read_module_source_bytes: called CC=2 SCAR=7.0
7258 232 my ( $self, $path, $file, $line ) = @_;
7259  
7260 232 ▶ open my $fh, '<:raw', $path
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<:raw", $path or die "Zuzu::Error"->new_runtime("message", "Cannot open '${path}': $!", "file", $file, "line", $line) 232 0 232
7261 or die Zuzu::Error->new_runtime(
7262 message => "Cannot open '$path': $!",
7263 file => $file,
7264 line => $line,
7265 );
7266 232 local $/;
7267 232 my $bytes = <$fh>;
7268 232 close $fh;
7269  
7270 232 return $bytes;
7271 }
7272  
7273 230 ▶sub _persistent_ast_cache_path {
Subroutine _persistent_ast_cache_path: called CC=3 SCAR=11.8
7274 230 my ( $self, $module, $path, $source_md5 ) = @_;
7275  
7276 230 my $root = $self->_persistent_ast_cache_root;
7277 230 ▶ return if !defined $root or $root eq '';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $root or $root eq "" 0 230 230
Condition33%1/3
not defined $root or $root eq ""
l!l&&r!l&&!r
00230
MC/DC0%0/2
not defined $root or $root eq ""
not defined $root $root eq ""
Truth table33%1/3
not(A) or B
A= not defined $rootB= $root eq ""
ABresult
1X1
011
000
7278  
7279 my $id = md5_hex(
7280 join "\x1f",
7281 $PERSISTENT_AST_CACHE_MAGIC,
7282 $PERSISTENT_AST_CACHE_VERSION,
7283 $],
7284 $module,
7285 $path,
7286 $source_md5,
7287 $self->{_parser}->visitor_cache_key,
7288 230 );
7289  
7290 230 return File::Spec->catfile( $root, "$id.stor" );
7291 }
7292  
7293 230 ▶sub _persistent_ast_cache_load {
Subroutine _persistent_ast_cache_load: called CC=32 SCAR=44.1
7294 230 my ( $self, $cache_path, $module, $path, $source_md5, $st ) = @_;
7295  
7296 230 ▶ return if !defined $cache_path or !-f $cache_path;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $cache_path and -f $cache_path 101 129 230
Condition66%2/3
defined $cache_path and -f $cache_path
!ll&&!rl&&r
0101129
MC/DC50%1/2
defined $cache_path and -f $cache_path
defined $cache_path -f $cache_path
Truth table66%2/3
A and B
A= defined $cache_pathB= -f $cache_path
ABresult
0X0
100
111
7297  
7298 129 ▶ if ( ( $PERSISTENT_AST_CACHE_MAX_AGE // 0 ) > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (($Zuzu::Runtime::PERSISTENT_AST_CACHE_MAX_AGE // 0) > 0) 129 0 129
Condition50%1/2
$Zuzu::Runtime::PERSISTENT_AST_CACHE_MAX_AGE // 0
l!l
1290
MC/DC0%0/1
$Zuzu::Runtime::PERSISTENT_AST_CACHE_MAX_AGE // 0
$Zuzu::Runtime::PERSISTENT_AST_CACHE_MAX_AGE
Truth table50%1/2
A
A= $Zuzu::Runtime::PERSISTENT_AST_CACHE_MAX_AGE
Aresult
11
00
7299 129 my @cache_st = stat $cache_path;
7300 129 ▶ if ( @cache_st and time - ( $cache_st[9] // 0 ) > $PERSISTENT_AST_CACHE_MAX_AGE ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@cache_st and time - ($cache_st[9] // 0) > $Zuzu::Runtime::PERSISTENT_AST_CACHE_MAX_AGE) 0 129 129
Condition40%2/5
@cache_st and time - ($cache_st[9] // 0) > $Zuzu::Runtime::PERSISTENT_AST_CACHE_MAX_AGE
!ll&&!rl&&r
01290
$cache_st[9] // 0
l!l
1290
MC/DC0%0/2
@cache_st and time - ($cache_st[9] // 0) > $Zuzu::Runtime::PERSISTENT_AST_CACHE_MAX_AGE
@cache_st time - ($cache_st[9] // 0) > $Zuzu::Runtime::PERSISTENT_AST_CACHE_MAX_AGE
MC/DC0%0/1
$cache_st[9] // 0
$cache_st[9]
Truth table33%1/3
A and B
A= @cache_stB= time - ($cache_st[9] // 0) > $Zuzu::Runtime::PERSISTENT_AST_CACHE_MAX_AGE
ABresult
0X0
100
111
Truth table50%1/2
A
A= $cache_st[9]
Aresult
11
00
7301 0 unlink $cache_path;
7302 0 return;
7303 }
7304 }
7305  
7306 129 my $entry = eval { retrieve($cache_path) };
7307 129 ▶ return if $@ or ref($entry) ne 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if $@ or ref $entry ne "HASH" 1 128 129
Condition66%2/3
$@ or ref $entry ne "HASH"
l!l&&r!l&&!r
10128
MC/DC50%1/2
$@ or ref $entry ne "HASH"
$@ ref $entry ne "HASH"
Truth table66%2/3
A or B
A= $@B= ref $entry ne "HASH"
ABresult
1X1
011
000
7308  
7309 128 ▶ return if ( $entry->{magic} // '' ) ne $PERSISTENT_AST_CACHE_MAGIC;
Branch: 1 branch
BranchTrueFalseTotal
if ($entry->{"magic"} // "") ne $Zuzu::Runtime::PERSISTENT_AST_CACHE_MAGIC 0 128 128
Condition50%1/2
$entry->{"magic"} // ""
l!l
1280
MC/DC0%0/1
$entry->{"magic"} // ""
$entry->{"magic"}
Truth table50%1/2
A
A= $entry->{"magic"}
Aresult
11
00
7310 128 ▶ return if ( $entry->{version} // -1 ) != $PERSISTENT_AST_CACHE_VERSION;
Branch: 1 branch
BranchTrueFalseTotal
if ($entry->{"version"} // -1) != $Zuzu::Runtime::PERSISTENT_AST_CACHE_VERSION 0 128 128
Condition50%1/2
$entry->{"version"} // -1
l!l
1280
MC/DC0%0/1
$entry->{"version"} // -1
$entry->{"version"}
Truth table50%1/2
A
A= $entry->{"version"}
Aresult
11
00
7311 128 ▶ return if ( $entry->{perl_version} // '' ) ne $];
Branch: 1 branch
BranchTrueFalseTotal
if ($entry->{"perl_version"} // "") ne $] 0 128 128
Condition50%1/2
$entry->{"perl_version"} // ""
l!l
1280
MC/DC0%0/1
$entry->{"perl_version"} // ""
$entry->{"perl_version"}
Truth table50%1/2
A
A= $entry->{"perl_version"}
Aresult
11
00
7312 128 ▶ return if ( $entry->{module} // '' ) ne $module;
Branch: 1 branch
BranchTrueFalseTotal
if ($entry->{"module"} // "") ne $module 0 128 128
Condition50%1/2
$entry->{"module"} // ""
l!l
1280
MC/DC0%0/1
$entry->{"module"} // ""
$entry->{"module"}
Truth table50%1/2
A
A= $entry->{"module"}
Aresult
11
00
7313 128 ▶ return if ( $entry->{path} // '' ) ne $path;
Branch: 1 branch
BranchTrueFalseTotal
if ($entry->{"path"} // "") ne $path 0 128 128
Condition50%1/2
$entry->{"path"} // ""
l!l
1280
MC/DC0%0/1
$entry->{"path"} // ""
$entry->{"path"}
Truth table50%1/2
A
A= $entry->{"path"}
Aresult
11
00
7314 128 ▶ return if ( $entry->{source_md5} // '' ) ne $source_md5;
Branch: 1 branch
BranchTrueFalseTotal
if ($entry->{"source_md5"} // "") ne $source_md5 0 128 128
Condition50%1/2
$entry->{"source_md5"} // ""
l!l
1280
MC/DC0%0/1
$entry->{"source_md5"} // ""
$entry->{"source_md5"}
Truth table50%1/2
A
A= $entry->{"source_md5"}
Aresult
11
00
7315 128 ▶ return if ( $entry->{visitor_key} // '' ) ne $self->{_parser}->visitor_cache_key;
Branch: 1 branch
BranchTrueFalseTotal
if ($entry->{"visitor_key"} // "") ne $self->{"_parser"}->visitor_cache_key 0 128 128
Condition50%1/2
$entry->{"visitor_key"} // ""
l!l
1280
MC/DC0%0/1
$entry->{"visitor_key"} // ""
$entry->{"visitor_key"}
Truth table50%1/2
A
A= $entry->{"visitor_key"}
Aresult
11
00
7316 128 ▶ return if ( $entry->{source_size} // -1 ) != ( $st->[7] // -1 );
Branch: 1 branch
BranchTrueFalseTotal
if ($entry->{"source_size"} // -1) != ($st->[7] // -1) 0 128 128
Condition50%2/4
$entry->{"source_size"} // -1
l!l
1280
$st->[7] // -1
l!l
1280
MC/DC0%0/1
$entry->{"source_size"} // -1
$entry->{"source_size"}
MC/DC0%0/1
$st->[7] // -1
$st->[7]
Truth table50%1/2
A
A= $entry->{"source_size"}
Aresult
11
00
Truth table50%1/2
A
A= $st->[7]
Aresult
11
00
7317 128 ▶ return if ( $entry->{source_mtime} // -1 ) != ( $st->[9] // -1 );
Branch: 1 branch
BranchTrueFalseTotal
if ($entry->{"source_mtime"} // -1) != ($st->[9] // -1) 0 128 128
Condition50%2/4
$entry->{"source_mtime"} // -1
l!l
1280
$st->[9] // -1
l!l
1280
MC/DC0%0/1
$entry->{"source_mtime"} // -1
$entry->{"source_mtime"}
MC/DC0%0/1
$st->[9] // -1
$st->[9]
Truth table50%1/2
A
A= $entry->{"source_mtime"}
Aresult
11
00
Truth table50%1/2
A
A= $st->[9]
Aresult
11
00
7318  
7319 128 my $ast = $entry->{ast};
7320 return
7321 128 ▶ if !blessed($ast)
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($ast) and $ast->isa("Zuzu::AST::Program") 0 128 128
Condition33%1/3
builtin::blessed($ast) and $ast->isa("Zuzu::AST::Program")
!ll&&!rl&&r
00128
MC/DC0%0/2
builtin::blessed($ast) and $ast->isa("Zuzu::AST::Program")
builtin::blessed($ast) $ast->isa("Zuzu::AST::Program")
Truth table33%1/3
A and B
A= builtin::blessed($ast)B= $ast->isa("Zuzu::AST::Program")
ABresult
0X0
100
111
7322 or !$ast->isa('Zuzu::AST::Program');
7323  
7324 128 eval { utime time, time, $cache_path };
7325  
7326 128 return $ast;
7327 }
7328  
7329 102 ▶sub _persistent_ast_cache_store {
Subroutine _persistent_ast_cache_store: called CC=12 SCAR=29.5
7330 102 my ( $self, $cache_path, $module, $path, $source_md5, $st, $ast ) = @_;
7331  
7332 102 ▶ return if !defined $cache_path;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $cache_path 0 102 102
7333  
7334 102 my $root = $self->_persistent_ast_cache_root;
7335 102 ▶ return if !defined $root or $root eq '';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $root or $root eq "" 0 102 102
Condition33%1/3
not defined $root or $root eq ""
l!l&&r!l&&!r
00102
MC/DC0%0/2
not defined $root or $root eq ""
not defined $root $root eq ""
Truth table33%1/3
not(A) or B
A= not defined $rootB= $root eq ""
ABresult
1X1
011
000
7336  
7337 102 eval {
7338 102 ▶ make_path( $root, { mode => 0700 } ) if !-d $root;
Branch: 1 branch
BranchTrueFalseTotal
unless -d $root 2 100 102
7339 102 ▶ return if !-d $root;
Branch: 1 branch
BranchTrueFalseTotal
unless -d $root 0 102 102
7340  
7341 102 my ( $tmp_fh, $tmp_path ) = tempfile(
7342 '.ast-cache-XXXXXX',
7343 DIR => $root,
7344 UNLINK => 0,
7345 );
7346 102 close $tmp_fh;
7347  
7348 my $entry = {
7349 magic => $PERSISTENT_AST_CACHE_MAGIC,
7350 version => $PERSISTENT_AST_CACHE_VERSION,
7351 perl_version => $],
7352 module => $module,
7353 path => $path,
7354 source_md5 => $source_md5,
7355 visitor_key => $self->{_parser}->visitor_cache_key,
7356 102 ▶ source_size => $st->[7] // -1,
Condition50%2/4
$st->[7] // -1
l!l
1020
$st->[9] // -1
l!l
1020
MC/DC0%0/1
$st->[7] // -1
$st->[7]
MC/DC0%0/1
$st->[9] // -1
$st->[9]
Truth table50%1/2
A
A= $st->[7]
Aresult
11
00
Truth table50%1/2
A
A= $st->[9]
Aresult
11
00
7357 source_mtime => $st->[9] // -1,
7358 ast => $ast,
7359 };
7360  
7361 eval {
7362 102 nstore( $entry, $tmp_path );
7363 102 chmod 0600, $tmp_path;
7364 102 ▶ rename $tmp_path, $cache_path
Branch: 1 branch
BranchTrueFalseTotal
rename $tmp_path, $cache_path or die "Cannot rename '${tmp_path}' to '${cache_path}': $!" 102 0 102
7365 or die "Cannot rename '$tmp_path' to '$cache_path': $!";
7366 102 1;
7367 102 ▶ } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { nstore($entry, $tmp_path); chmod 0600, $tmp_path; rename $tmp_path, $cache_path or die "Cannot rename '${tmp_path}' to '${cache_path}': $!"; 1 } } or do { unlink $tmp_path if defined $tmp_path and -e $tmp_path } 102 0 102
7368 0 ▶ unlink $tmp_path if defined $tmp_path and -e $tmp_path;
Branch: 1 branch
BranchTrueFalseTotal
if defined $tmp_path and -e $tmp_path 0 0 0
Condition0%0/3
defined $tmp_path and -e $tmp_path
!ll&&!rl&&r
000
MC/DC0%0/2
defined $tmp_path and -e $tmp_path
defined $tmp_path -e $tmp_path
Truth table0%0/3
A and B
A= defined $tmp_pathB= -e $tmp_path
ABresult
0X0
100
111
7369 };
7370 };
7371  
7372 102 return;
7373 }
7374  
7375 230 ▶sub _expire_persistent_ast_cache {
Subroutine _expire_persistent_ast_cache: called CC=22 SCAR=33.8
7376 230 my ( $self ) = @_;
7377  
7378 230 ▶ return if $PERSISTENT_AST_CACHE_EXPIRY_RAN;
Branch: 1 branch
BranchTrueFalseTotal
if $Zuzu::Runtime::PERSISTENT_AST_CACHE_EXPIRY_RAN 204 26 230
7379 26 $PERSISTENT_AST_CACHE_EXPIRY_RAN = 1;
7380  
7381 26 my $root = $self->_persistent_ast_cache_root;
7382 26 ▶ return if !defined $root or $root eq '' or !-d $root;
Branch: 1 branch
BranchTrueFalseTotal
if not defined $root or $root eq "" or not -d $root 0 26 26
Condition33%2/6
not defined $root or $root eq "" or not -d $root
l!l&&r!l&&!r
0026
not defined $root or $root eq ""
l!l&&r!l&&!r
0026
MC/DC0%0/3
not defined $root or $root eq "" or not -d $root
not defined $root $root eq "" not -d $root
Truth table25%1/4
not(A) or B or not(C)
A= not defined $rootB= $root eq ""C= not -d $root
ABCresult
1XX1
01X1
0011
0000
7383  
7384 26 my $now = time;
7385 26 ▶ my $max_age = $PERSISTENT_AST_CACHE_MAX_AGE // 0;
Condition50%1/2
$Zuzu::Runtime::PERSISTENT_AST_CACHE_MAX_AGE // 0
l!l
260
MC/DC0%0/1
$Zuzu::Runtime::PERSISTENT_AST_CACHE_MAX_AGE // 0
$Zuzu::Runtime::PERSISTENT_AST_CACHE_MAX_AGE
Truth table50%1/2
A
A= $Zuzu::Runtime::PERSISTENT_AST_CACHE_MAX_AGE
Aresult
11
00
7386 26 ▶ my $max_size = $PERSISTENT_AST_CACHE_MAX_SIZE // 0;
Condition50%1/2
$Zuzu::Runtime::PERSISTENT_AST_CACHE_MAX_SIZE // 0
l!l
260
MC/DC0%0/1
$Zuzu::Runtime::PERSISTENT_AST_CACHE_MAX_SIZE // 0
$Zuzu::Runtime::PERSISTENT_AST_CACHE_MAX_SIZE
Truth table50%1/2
A
A= $Zuzu::Runtime::PERSISTENT_AST_CACHE_MAX_SIZE
Aresult
11
00
7387  
7388 26 eval {
7389 26 ▶ opendir my $dh, $root
Branch: 1 branch
BranchTrueFalseTotal
opendir my $dh, $root or return 26 0 26
7390 or return;
7391  
7392 26 my @entries;
7393 26 ▶ while ( defined( my $name = readdir $dh ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $name = readdir $dh)) 832 26 858
7394 832 ▶ next if $name !~ /\.stor\z/;
Branch: 1 branch
BranchTrueFalseTotal
unless $name =~ /\.stor\z/ 52 780 832
7395 780 my $path = File::Spec->catfile( $root, $name );
7396 780 my @st = stat $path;
7397 780 ▶ next if !@st or !-f _;
Branch: 1 branch
BranchTrueFalseTotal
unless @st and -f _ 0 780 780
Condition33%1/3
@st and -f _
!ll&&!rl&&r
00780
MC/DC0%0/2
@st and -f _
@st -f _
Truth table33%1/3
A and B
A= @stB= -f _
ABresult
0X0
100
111
7398  
7399 780 ▶ if ( $max_age > 0 and $now - $st[9] > $max_age ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($max_age > 0 and $now - $st[9] > $max_age) 2 778 780
Condition66%2/3
$max_age > 0 and $now - $st[9] > $max_age
!ll&&!rl&&r
07782
MC/DC50%1/2
$max_age > 0 and $now - $st[9] > $max_age
$max_age > 0 $now - $st[9] > $max_age
Truth table66%2/3
A and B
A= $max_age > 0B= $now - $st[9] > $max_age
ABresult
0X0
100
111
7400 2 unlink $path;
7401 2 next;
7402 }
7403  
7404 778 ▶ push @entries, [ $path, $st[7] // 0, $st[9] // 0 ];
Condition50%2/4
$st[7] // 0
l!l
7780
$st[9] // 0
l!l
7780
MC/DC0%0/1
$st[7] // 0
$st[7]
MC/DC0%0/1
$st[9] // 0
$st[9]
Truth table50%1/2
A
A= $st[7]
Aresult
11
00
Truth table50%1/2
A
A= $st[9]
Aresult
11
00
7405 }
7406 26 closedir $dh;
7407  
7408 26 ▶ return if $max_size <= 0;
Branch: 1 branch
BranchTrueFalseTotal
if $max_size <= 0 0 26 26
7409  
7410 26 my $total = 0;
7411 26 $total += $_->[1] for @entries;
7412 26 ▶ return if $total <= $max_size;
Branch: 1 branch
BranchTrueFalseTotal
if $total <= $max_size 25 1 26
7413  
7414 0 for my $entry ( sort { $a->[2] <=> $b->[2] } @entries ) {
7415 1 ▶ last if $total <= $max_size;
Branch: 1 branch
BranchTrueFalseTotal
if $total <= $max_size 0 1 1
7416 1 ▶ next if !unlink $entry->[0];
Branch: 1 branch
BranchTrueFalseTotal
unless unlink $entry->[0] 0 1 1
7417 1 $total -= $entry->[1];
7418 }
7419 };
7420  
7421 26 return;
7422 }
7423  
7424 3621 ▶sub _load_module {
Subroutine _load_module: called CC=20 SCAR=31.0
7425 3621 my ($self, $module, $file, $line) = @_;
7426  
7427 3621 ▶ if ( $module =~ m{(?:\A|/)\.\.(?:/|\z)} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($module =~ m[(?:\A|/)\.\.(?:/|\z)]) 0 3621 3621
7428 0 die Zuzu::Error->new_compile(
7429 message => "Import module path cannot contain '..' segments",
7430 file => $file,
7431 line => $line,
7432 );
7433 }
7434  
7435 3621 ▶ if ( $self->_module_denied_as_missing($module) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_module_denied_as_missing($module)) 3 3618 3621
7436 3 die Zuzu::Error->new_compile(
7437 message => $self->_module_not_found_message( $module, $file ),
7438 file => $file,
7439 line => $line,
7440 );
7441 }
7442  
7443 3618 ▶ if ( $self->_is_denied_module($module) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_is_denied_module($module)) 0 3618 3618
7444 0 die Zuzu::Error->new_compile(
7445 message => "Module '$module' is denied by runtime policy",
7446 file => $file,
7447 line => $line,
7448 );
7449 }
7450  
7451 3618 ▶ if ( $self->{_module_loading}{$module} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_module_loading"}{$module}) 0 3618 3618
7452 0 die Zuzu::Error->new_runtime(
7453 message => "Circular module loading detected",
7454 file => $file,
7455 line => $line,
7456 );
7457 }
7458  
7459 3618 ▶ return $self->{_modules}{$module} if $self->{_modules}{$module};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_modules"}{$module} 1741 1877 3618
7460 1877 ▶ if ( exists $self->builtin->{$module} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->builtin->{$module}) 1058 819 1877
7461 1058 return $self->_load_builtin_module( $module, $file, $line );
7462 }
7463  
7464 819 my $found = $self->_resolve_module_file( $module, $file );
7465 819 ▶ die Zuzu::Error->new_compile(
Branch: 1 branch
BranchTrueFalseTotal
unless $found 6 813 819
7466 message => $self->_module_not_found_message( $module, $file ),
7467 file => $file,
7468 line => $line,
7469 )
7470 if !$found;
7471  
7472 813 my @st = stat $found;
7473 my $ast_cache_key = join "\x1f",
7474 $found,
7475 ( defined $st[9] ? $st[9] : -1 ),
7476 ( defined $st[7] ? $st[7] : -1 ),
7477 813 ▶ $self->{_parser}->visitor_cache_key;
Branch: 2 branches
BranchTrueFalseTotal
defined $st[9] ? : 813 0 813
defined $st[7] ? : 813 0 813
7478 813 my $ast = $MODULE_AST_CACHE{$ast_cache_key};
7479 813 ▶ if ( !defined $ast ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $ast) 232 581 813
7480 232 my $source_bytes = $self->_read_module_source_bytes( $found, $file, $line );
7481 232 my ( $source_md5, $persistent_cache_path );
7482  
7483 232 ▶ if ( $self->persistent_ast_cache ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->persistent_ast_cache) 230 2 232
7484 230 $source_md5 = md5_hex($source_bytes);
7485 230 $persistent_cache_path = $self->_persistent_ast_cache_path(
7486 $module,
7487 $found,
7488 $source_md5,
7489 );
7490  
7491 230 $ast = $self->_persistent_ast_cache_load(
7492 $persistent_cache_path,
7493 $module,
7494 $found,
7495 $source_md5,
7496 \@st,
7497 );
7498 230 ▶ $self->_expire_persistent_ast_cache if defined $ast;
Branch: 1 branch
BranchTrueFalseTotal
if defined $ast 128 102 230
7499 }
7500  
7501 232 ▶ if ( !defined $ast ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $ast) 104 128 232
7502 104 my $src = eval { decode( 'UTF-8', $source_bytes, FB_CROAK ) };
7503 104 ▶ die Zuzu::Error->new_compile(
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 104 104
7504 message => "Cannot decode '$found' as UTF-8: $@",
7505 file => $file,
7506 line => $line,
7507 ) if $@;
7508  
7509 104 $ast = $self->{_parser}->parse($src, $found);
7510 104 ▶ $self->_persistent_ast_cache_store(
Branch: 1 branch
BranchTrueFalseTotal
if defined $persistent_cache_path 102 2 104
7511 $persistent_cache_path,
7512 $module,
7513 $found,
7514 $source_md5,
7515 \@st,
7516 $ast,
7517 ) if defined $persistent_cache_path;
7518 104 ▶ $self->_expire_persistent_ast_cache if defined $persistent_cache_path;
Branch: 1 branch
BranchTrueFalseTotal
if defined $persistent_cache_path 102 2 104
7519 }
7520  
7521 232 $MODULE_AST_CACHE{$ast_cache_key} = $ast;
7522 }
7523  
7524 813 my $mod_env = Zuzu::Env->_new_fast(undef);
7525 # share builtins by aliasing builtin refs into module env
7526 813 for my $alias ( @{ $self->{_module_builtin_aliases} } ) {
7527 28455 $mod_env->alias_to_ref(
7528 $alias->[0],
7529 $alias->[1],
7530 $alias->[2],
7531 );
7532 }
7533 813 $self->_declare_file_const( $mod_env, $found, 1 );
7534  
7535 813 $self->{_module_loading}{$module} = 1;
7536 813 $self->{_modules}{$module} = $mod_env;
7537 my $pre_slots = {
7538 813 ▶ %{ $self->{_module_builtin_slot_set} // {} },
Condition50%1/2
$self->{"_module_builtin_slot_set"} // {}
l!l
8130
MC/DC0%0/1
$self->{"_module_builtin_slot_set"} // {}
$self->{"_module_builtin_slot_set"}
Truth table50%1/2
A
A= $self->{"_module_builtin_slot_set"}
Aresult
11
00
7539 __file__ => 1,
7540 };
7541  
7542 813 $self->_push_env($mod_env);
7543 813 ▶ eval { $self->evaluate($ast); 1 } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $self->evaluate($ast); 1 } } or do { my $e = $@; $self->_pop_env; delete $self->{"_module_loading"}{$module}; delete $self->{"_modules"}{$module}; delete $self->{"_module_exports"}{$module}; die $e } 813 0 813
7544 0 my $e = $@;
7545 0 $self->_pop_env;
7546 0 delete $self->{_module_loading}{$module};
7547 0 delete $self->{_modules}{$module};
7548 0 delete $self->{_module_exports}{$module};
7549 0 die $e;
7550 };
7551 813 $self->_pop_env;
7552 813 delete $self->{_module_loading}{$module};
7553  
7554 my %exports = map {
7555 14111 $_ => 1
7556 } grep {
7557 43379 !$pre_slots->{$_}
7558 813 } sort CORE::keys %{ $mod_env->{slots} };
7559 813 $self->{_module_exports}{$module} = \%exports;
7560  
7561 813 return $mod_env;
7562 }
7563  
7564 3621 ▶sub _module_denied_as_missing {
Subroutine _module_denied_as_missing: called CC=17 SCAR=34.9
7565 3621 my ( $self, $module ) = @_;
7566  
7567 3621 ▶ return 1 if $self->is_denied( 'fs' ) and $module =~ m{\Astd/io(?:/|\z)};
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_denied("fs") and $module =~ m[\Astd/io(?:/|\z)] 2 3619 3621
Condition100%3/3
$self->is_denied("fs") and $module =~ m[\Astd/io(?:/|\z)]
!ll&&!rl&&r
361812
MC/DC100%2/2
$self->is_denied("fs") and $module =~ m[\Astd/io(?:/|\z)]
$self->is_denied("fs") $module =~ m[\Astd/io(?:/|\z)]
Truth table100%3/3
A and B
A= $self->is_denied("fs")B= $module =~ m[\Astd/io(?:/|\z)]
ABresult
0X0
100
111
7568 3619 ▶ return 1 if $self->is_denied( 'net' ) and $module =~ m{\Astd/net(?:/|\z)};
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_denied("net") and $module =~ m[\Astd/net(?:/|\z)] 0 3619 3619
Condition33%1/3
$self->is_denied("net") and $module =~ m[\Astd/net(?:/|\z)]
!ll&&!rl&&r
361900
MC/DC0%0/2
$self->is_denied("net") and $module =~ m[\Astd/net(?:/|\z)]
$self->is_denied("net") $module =~ m[\Astd/net(?:/|\z)]
Truth table33%1/3
A and B
A= $self->is_denied("net")B= $module =~ m[\Astd/net(?:/|\z)]
ABresult
0X0
100
111
7569 3619 ▶ return 1 if $self->is_denied( 'net' ) and $module eq 'std/io/socks';
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_denied("net") and $module eq "std/io/socks" 0 3619 3619
Condition33%1/3
$self->is_denied("net") and $module eq "std/io/socks"
!ll&&!rl&&r
361900
MC/DC0%0/2
$self->is_denied("net") and $module eq "std/io/socks"
$self->is_denied("net") $module eq "std/io/socks"
Truth table33%1/3
A and B
A= $self->is_denied("net")B= $module eq "std/io/socks"
ABresult
0X0
100
111
7570 3619 ▶ return 1 if $self->is_denied( 'proc' ) and $module eq 'std/proc';
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_denied("proc") and $module eq "std/proc" 0 3619 3619
Condition33%1/3
$self->is_denied("proc") and $module eq "std/proc"
!ll&&!rl&&r
361900
MC/DC0%0/2
$self->is_denied("proc") and $module eq "std/proc"
$self->is_denied("proc") $module eq "std/proc"
Truth table33%1/3
A and B
A= $self->is_denied("proc")B= $module eq "std/proc"
ABresult
0X0
100
111
7571 3619 ▶ return 1 if $self->is_denied( 'db' ) and $module eq 'std/db';
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_denied("db") and $module eq "std/db" 1 3618 3619
Condition66%2/3
$self->is_denied("db") and $module eq "std/db"
!ll&&!rl&&r
361801
MC/DC50%1/2
$self->is_denied("db") and $module eq "std/db"
$self->is_denied("db") $module eq "std/db"
Truth table66%2/3
A and B
A= $self->is_denied("db")B= $module eq "std/db"
ABresult
0X0
100
111
7572 3618 ▶ return 1 if $self->is_denied( 'clib' ) and $module eq 'std/clib';
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_denied("clib") and $module eq "std/clib" 0 3618 3618
Condition33%1/3
$self->is_denied("clib") and $module eq "std/clib"
!ll&&!rl&&r
361800
MC/DC0%0/2
$self->is_denied("clib") and $module eq "std/clib"
$self->is_denied("clib") $module eq "std/clib"
Truth table33%1/3
A and B
A= $self->is_denied("clib")B= $module eq "std/clib"
ABresult
0X0
100
111
7573 3618 ▶ return 1 if $self->is_denied( 'js' ) and $module eq 'javascript';
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_denied("js") and $module eq "javascript" 0 3618 3618
Condition33%1/3
$self->is_denied("js") and $module eq "javascript"
!ll&&!rl&&r
036180
MC/DC0%0/2
$self->is_denied("js") and $module eq "javascript"
$self->is_denied("js") $module eq "javascript"
Truth table33%1/3
A and B
A= $self->is_denied("js")B= $module eq "javascript"
ABresult
0X0
100
111
7574 3618 ▶ return 1 if $self->is_denied( 'worker' ) and $module eq 'std/worker';
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_denied("worker") and $module eq "std/worker" 0 3618 3618
Condition33%1/3
$self->is_denied("worker") and $module eq "std/worker"
!ll&&!rl&&r
361800
MC/DC0%0/2
$self->is_denied("worker") and $module eq "std/worker"
$self->is_denied("worker") $module eq "std/worker"
Truth table33%1/3
A and B
A= $self->is_denied("worker")B= $module eq "std/worker"
ABresult
0X0
100
111
7575  
7576 3618 return 0;
7577 }
7578  
7579 3618 ▶sub _is_denied_module {
Subroutine _is_denied_module: called CC=5 SCAR=23.0
7580 3618 my ( $self, $module ) = @_;
7581  
7582 3618 ▶ for my $denied ( @{ $self->deny_modules // [] } ) {
Condition50%1/2
$self->deny_modules // []
l!l
36180
MC/DC0%0/1
$self->deny_modules // []
$self->deny_modules
Truth table50%1/2
A
A= $self->deny_modules
Aresult
11
00
7583 0 ▶ return 1 if defined $denied and $denied eq $module;
Branch: 1 branch
BranchTrueFalseTotal
if defined $denied and $denied eq $module 0 0 0
Condition0%0/3
defined $denied and $denied eq $module
!ll&&!rl&&r
000
MC/DC0%0/2
defined $denied and $denied eq $module
defined $denied $denied eq $module
Truth table0%0/3
A and B
A= defined $deniedB= $denied eq $module
ABresult
0X0
100
111
7584 }
7585  
7586 3618 return 0;
7587 }
7588  
7589 1058 ▶sub _load_builtin_module {
Subroutine _load_builtin_module: called CC=8 SCAR=21.4
7590 1058 my ( $self, $module, $file, $line ) = @_;
7591  
7592 1058 ▶ return $self->{_modules}{$module} if $self->{_modules}{$module};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_modules"}{$module} 0 1058 1058
7593  
7594 1058 my $pkg = $self->builtin->{$module};
7595 1058 ▶ die Zuzu::Error->new_compile(
Branch: 1 branch
BranchTrueFalseTotal
if not defined $pkg or $pkg eq "" 0 1058 1058
Condition33%1/3
not defined $pkg or $pkg eq ""
l!l&&r!l&&!r
001058
MC/DC0%0/2
not defined $pkg or $pkg eq ""
not defined $pkg $pkg eq ""
Truth table33%1/3
not(A) or B
A= not defined $pkgB= $pkg eq ""
ABresult
1X1
011
000
7596 message => "Builtin module '$module' has no package mapping",
7597 file => $file,
7598 line => $line,
7599 ) if !defined $pkg or $pkg eq '';
7600  
7601 1058 ▶ eval "require $pkg; 1" or die Zuzu::Error->new_runtime(
Branch: 1 branch
BranchTrueFalseTotal
eval "require $pkg; 1" or die "Zuzu::Error"->new_runtime("message", "Failed loading builtin module '${module}' ($pkg): $@", "file", $file, "line", $line) 1057 1 1058
7602 message => "Failed loading builtin module '$module' ($pkg): $@",
7603 file => $file,
7604 line => $line,
7605 );
7606 1057 ▶ die Zuzu::Error->new_runtime(
Branch: 1 branch
BranchTrueFalseTotal
unless $pkg->can("IMPORT") 0 1057 1057
7607 message => "Builtin module '$module' ($pkg) does not provide IMPORT",
7608 file => $file,
7609 line => $line,
7610 ) if !$pkg->can('IMPORT');
7611  
7612 1057 my $symbols = $pkg->IMPORT( $self );
7613 1057 ▶ die Zuzu::Error->new_runtime(
Branch: 1 branch
BranchTrueFalseTotal
if ref $symbols ne "HASH" 0 1057 1057
7614 message => "Builtin module '$module' ($pkg) returned non-hashref exports",
7615 file => $file,
7616 line => $line,
7617 ) if ref($symbols) ne 'HASH';
7618  
7619 1057 my $mod_env = Zuzu::Env->_new_fast(undef);
7620 1057 for my $name ( sort CORE::keys %{ $symbols } ) {
7621 8846 $mod_env->declare( $name, $symbols->{$name}, 1 );
7622 }
7623  
7624 1057 $self->{_modules}{$module} = $mod_env;
7625 $self->{_module_exports}{$module} = {
7626 1057 map { $_ => 1 } sort CORE::keys %{ $symbols }
7627 };
7628  
7629 1057 return $mod_env;
7630 }
7631  
7632 69 1;
7633  
7634 =pod
7635  
7636 =head1 NAME
7637  
7638 Zuzu::Runtime - interpreter and evaluator for ZuzuScript programs
7639  
7640 =head1 DESCRIPTION
7641  
7642 Creates runtime state, installs built-ins, and evaluates AST nodes produced by the parser.
7643  
7644 =head1 INHERITANCE
7645  
7646 Inherits from C<Moo::Object>.
7647  
7648 =head1 ROLES
7649  
7650 None.
7651  
7652 =head1 ATTRIBUTES
7653  
7654 =head2 lib
7655  
7656 Type: B<ArrayRef[Str]>.
7657  
7658 Module search paths used by C<import> resolution.
7659  
7660 =head1 METHODS
7661  
7662 =head2 new
7663  
7664 Constructs and returns a new instance of this class.
7665  
7666 =head2 evaluate
7667  
7668 Dispatches this AST node to the matching runtime evaluator.
7669  
7670 =head2 finish
7671  
7672 Runs pending object demolition hooks for a completed runtime.
7673  
7674 =head2 call
7675  
7676 Invokes a global function by name with arguments.
7677  
7678 =head2 eval_program
7679  
7680 Evaluates the corresponding AST node kind and returns its runtime value.
7681  
7682 =head2 eval_block
7683  
7684 Evaluates the corresponding AST node kind and returns its runtime value.
7685  
7686 =head2 eval_let
7687  
7688 Evaluates the corresponding AST node kind and returns its runtime value.
7689  
7690 =head2 eval_assign
7691  
7692 Evaluates the corresponding AST node kind and returns its runtime value.
7693  
7694 =head2 eval_if
7695  
7696 Evaluates the corresponding AST node kind and returns its runtime value.
7697  
7698 =head2 eval_while
7699  
7700 Evaluates the corresponding AST node kind and returns its runtime value.
7701  
7702 =head2 eval_for
7703  
7704 Evaluates the corresponding AST node kind and returns its runtime value.
7705  
7706 =head2 eval_function_def
7707  
7708 Evaluates the corresponding AST node kind and returns its runtime value.
7709  
7710 =head2 eval_class_def
7711  
7712 Evaluates the corresponding AST node kind and returns its runtime value.
7713  
7714 =head2 eval_method_def
7715  
7716 Evaluates the corresponding AST node kind and returns its runtime value.
7717  
7718 =head2 eval_return
7719  
7720 Evaluates the corresponding AST node kind and returns its runtime value.
7721  
7722 =head2 eval_next
7723  
7724 Evaluates the corresponding AST node kind and returns its runtime value.
7725  
7726 =head2 eval_last
7727  
7728 Evaluates the corresponding AST node kind and returns its runtime value.
7729  
7730 =head2 eval_expr_stmt
7731  
7732 Evaluates the corresponding AST node kind and returns its runtime value.
7733  
7734 =head2 eval_import
7735  
7736 Evaluates the corresponding AST node kind and returns its runtime value.
7737  
7738 =head2 eval_literal
7739  
7740 Evaluates the corresponding AST node kind and returns its runtime value.
7741  
7742 =head2 eval_var
7743  
7744 Evaluates the corresponding AST node kind and returns its runtime value.
7745  
7746 =head2 eval_array
7747  
7748 Evaluates the corresponding AST node kind and returns its runtime value.
7749  
7750 =head2 eval_dict
7751  
7752 Evaluates the corresponding AST node kind and returns its runtime value.
7753  
7754 =head2 eval_index
7755  
7756 Evaluates the corresponding AST node kind and returns its runtime value.
7757  
7758 =head2 eval_dict_get
7759  
7760 Evaluates the corresponding AST node kind and returns its runtime value.
7761  
7762 =head2 eval_unary
7763  
7764 Evaluates the corresponding AST node kind and returns its runtime value.
7765  
7766 =head2 eval_binary
7767  
7768 Evaluates the corresponding AST node kind and returns its runtime value.
7769  
7770 =head2 eval_call
7771  
7772 Evaluates the corresponding AST node kind and returns its runtime value.
7773  
7774 =head2 eval_member_call
7775  
7776 Evaluates the corresponding AST node kind and returns its runtime value.
7777  
7778 =head2 eval_new
7779  
7780 Evaluates the corresponding AST node kind and returns its runtime value.
7781  
7782 =head1 SEE ALSO
7783  
7784 Subclasses: none in this distribution.
7785  
7786 =head1 COPYRIGHT AND LICENCE
7787  
7788 B<< Zuzu::Runtime >> is copyright Toby Inkster.
7789  
7790 It is free software; you may redistribute it and/or modify it under
7791 the terms of either the Artistic License 1.0 or the GNU General Public
7792 License version 2.
7793  
7794 =cut
7795  
7796 69 1;
« blib/lib/Zuzu/Module/Secure.pm ↑ Summary blib/lib/Zuzu/Module/CLib.pm »