Branch Coverage

blib/lib/Template/Alloy.pm
Criterion Covered Total %
branch 392 502 78.0


line true false branch
54 41 2 $AUTOLOAD && $AUTOLOAD =~ /::(\w+)$/ ? :
55 1 40 unless ($self->can($meth))
64 41 1 if $$ROLEMAP{$meth}
73 6 72 if $item =~ /^(load|1)$/i
74 2 70 if (lc $item eq 'all')
80 7 63 if ($type = $STANDIN{$item})
82 4 3 unless ($INC{$file} and $item->isa('Template::Alloy'))
83 1 3 if ($INC{$file})
86 0 3 unless $$AUTOROLE{$type}
89 61 2 $$AUTOROLE{$item} ? :
106 1 4300 ref $_[0] ? :
109 253 4048 if (my(@keys) = grep({/^[a-z][a-z_]+$/;} keys %$args))
133 40 730 if (my $err = $@)
134 40 0 if (not $err->type =~ /stop|return|next|last|break/) { }
0 0 elsif ($err->type eq 'return' and UNIVERSAL::isa($err->info, 'HASH')) { }
136 0 40 if $$self{'RAISE_ERROR'}
156 145 5204 ref $file eq 'HASH' ? :
159 6 5155 if not $$self{'RECURSION'} and $$self{'_in'}{$$doc{'name'}} and $$doc{'name'} ne 'input text'
164 4329 838 $$self{'_top_level'} ? :
168 1356 3811 if ($$self{'STREAM'}) { }
0 3811 elsif ($$self{'COMPILE_JS'}) { }
1869 1942 elsif ($$doc{'_perl'}) { }
1941 1 elsif ($$doc{'_tree'}) { }
169 0 1356 unless $$doc{'_tree'}
182 27 4945 if ($$self{'TRIM'})
189 377 4972 if (my $err = $@)
190 5 372 unless UNIVERSAL::can($err, 'type')
191 161 40 if $doc and $err->can('doc') and not $err->doc
192 104 273 unless $$self{'_top_level'}
193 235 12 if $err->type ne 'stop' and $err->type ne 'return' || $err->info
203 1 5380 unless defined $file
206 13 5367 unless ref $docs
210 4581 799 if (ref $file) { }
19 780 elsif ($$docs{$file}) { }
13 767 elsif ($$self{'_not_found'}{$file}) { }
235 532 elsif ($$self{'BLOCKS'}{$file}) { }
211 1 4580 if ref $file eq 'HASH'
213 4577 3 if (not defined $$self{'CACHE_STR_REFS'} or $$self{'CACHE_STR_REFS'}) { }
215 193 4384 if ($$docs{$_file})
217 2 191 if not $$doc{'_perl'} and $$self{'COMPILE_PERL'}
222 1 2 $$self{'FORCE_STR_REF_PERL'} ? :
232 19 0 if (time - $$doc{'cache_time'} < ($$self{'STAT_TTL'} || $STAT_TTL) or $$doc{'modtime'} == (stat $$doc{'_filename'})[9])
234 1 18 if not $$doc{'_perl'} and $$self{'COMPILE_PERL'}
242 7 6 if (time - $$doc{'cache_time'} < ($$self{'NEGATIVE_STAT_TTL'} || $$self{'STAT_TTL'} || $STAT_TTL))
250 1 234 if UNIVERSAL::isa($block, 'CODE')
251 4 231 unless (UNIVERSAL::isa($block, 'HASH'))
252 1 3 if ref $block
255 229 4 $$block{'name'} && $$block{'name'} ne 'input text' ? :
256 232 1 if $$block{'_filename'}
257 81 152 if ($$block{'_perl'}) { }
151 1 elsif ($$block{'_tree'}) { }
268 538 3 unless ($$doc{'_filename'} or ref $file)
271 71 467 if (my $err = $@)
273 18 53 if ($$self{'EXPOSE_BLOCKS'} and not $$self{'_looking_in_block_file'}) { }
0 53 elsif ($$self{'DEFAULT'}) { }
277 0 12 length $block_name ? :
281 0 30 unless ref $node
282 12 18 if $$node[0] eq 'META'
283 0 18 if $$node[0] ne 'BLOCK'
284 6 12 if $block_name ne $$node[3]
287 4 0 if $$ref{'_perl'} and $$ref{'_perl'}{'blocks'} and $$ref{'_perl'}{'blocks'}{$block_name}
292 0 12 if $$self{'COMPILE_JS'} and $$ref{'_js'}
297 0 0 if $$doc{'_filename'} = eval { do { $self->include_filename($$self{'DEFAULT'}) } }
299 59 0 if ($err)
301 59 0 if (not defined $$self{'NEGATIVE_STAT_TTL'} or $$self{'NEGATIVE_STAT_TTL'})
302 0 59 unless UNIVERSAL::can($err, 'type')
314 1742 3112 if (not $$doc{'_no_perl'} and $$self{'COMPILE_PERL'} and $$self{'COMPILE_PERL'} ne '2' || $$self{'_tree'}) { }
0 3112 elsif ($$self{'COMPILE_JS'}) { }
323 4469 252 if (not defined $$self{'CACHE_SIZE'} or $$self{'CACHE_SIZE'})
325 4024 445 if (ref $file) { }
326 4021 3 if $$doc{'_filename'}
332 0 4469 if ($$self{'CACHE_SIZE'})
333 0 0 if (scalar keys %$docs > $$self{'CACHE_SIZE'})
336 0 0 if ++$n > $$self{'CACHE_SIZE'}
350 1 4577 ref $self && $$self{'ENCODING'} && eval { do { require Encode } } && defined &Encode::encode ? :
362 4850 3 if ($$doc{'_filename'})
364 16 4834 if ($$self{'COMPILE_DIR'} or $$self{'COMPILE_EXT'})
366 8 8 if ($$self{'COMPILE_DIR'}) { }
2 6 elsif ($$doc{'_is_str_ref'}) { }
367 0 8 if $^O eq 'MSWin32'
372 12 4 if defined $$self{'COMPILE_EXT'}
373 16 0 if defined $EXTRA_COMPILE_EXT
375 1 0 if (-e $file and $$doc{'_is_str_ref'} || (stat $file)[9] == $$doc{'modtime'})
386 33 4819 if ($$self{'CONSTANTS'})
396 15 4704 if ($$doc{'_storable_filename'})
399 10 5 unless (-d $dir)
415 9553 18936 unless ref $_[1]
426 9292 9644 if (ref $name) { }
9644 0 elsif (defined $name) { }
427 9118 174 if (not defined $$name[0]) { }
428 192 8926 if wantarray and $$name[1] eq '..'
429 110 8816 $$name[1] eq '-temp-' ? :
432 174 0 if (defined $name)
433 3 171 if $QR_PRIVATE and $name =~ /$QR_PRIVATE/
434 0 111 if $i >= $#$var and $$ARGS{'return_ref'} and not ref $$self{'_vars'}{$name}
439 15 9629 if $QR_PRIVATE and $name =~ /$QR_PRIVATE/
440 6 7068 if $i >= $#$var and $$ARGS{'return_ref'} and not ref $$self{'_vars'}{$name}
442 873 8750 unless (defined $ref)
443 175 698 $name eq 'template' || $name eq 'component' ? :
444 665 6 if not $ref and !defined($$self{'VMETHOD_FUNCTIONS'}) || $$self{'VMETHOD_FUNCTIONS'}
445 59 814 if not defined $ref and $$self{'LOWER_CASE_VAR_FALLBACK'}
453 547 20724 if (UNIVERSAL::isa($ref, 'CODE'))
454 15 532 if $i >= $#$var and $$ARGS{'return_ref'}
455 161 371 $args ? :
457 39 493 if ($type eq 'item') { }
461 33 457 if ($type eq 'list') { }
453 4 elsif (defined $results[0]) { }
0 4 elsif (defined $results[1]) { }
464 21 432 $#results > 0 ? :
475 17796 3453 if $i >= $#$var
476 0 3453 $$ARGS{'no_dots'} ? :
481 60 3393 if (ref $name)
482 60 0 if (ref $name eq 'ARRAY') { }
484 0 60 if (not defined $name or $QR_PRIVATE and $name =~ /$QR_PRIVATE/ or $name =~ /^\./)
492 3 3450 if (not defined $name or $QR_PRIVATE and $name =~ /$QR_PRIVATE/)
498 939 2511 if (not ref $ref) { }
499 223 716 if ($$Template::Alloy::ITEM_METHODS{$name}) { }
665 51 elsif ($$Template::Alloy::ITEM_OPS{$name}) { }
9 42 elsif ($$Template::Alloy::LIST_OPS{$name}) { }
36 6 elsif (my $filter = $$self{'FILTERS'}{$name} || $$Template::Alloy::FILTER_OPS{$name} || UNIVERSAL::isa($name, 'CODE') && $name || $self->list_filters->{$name}) { }
500 60 163 $args ? :
503 343 322 $args ? :
506 0 9 $args ? :
513 9 27 if (UNIVERSAL::isa($filter, 'CODE')) { }
0 27 elsif (not UNIVERSAL::isa($filter, 'ARRAY')) { }
9 18 elsif (@$filter == 2 and UNIVERSAL::isa($$filter[0], 'CODE')) { }
515 0 9 if (my $err = $@)
516 0 0 unless UNIVERSAL::can($err, 'type')
525 6 3 if ($$filter[1])
526 3 3 $args ? :
527 0 6 if (not $sub and $err) { }
0 6 elsif (not UNIVERSAL::isa($sub, 'CODE')) { }
528 0 0 unless UNIVERSAL::can($err, 'type')
531 0 0 unless UNIVERSAL::can($sub, 'type')
538 0 9 if (my $err = $@)
539 0 0 unless UNIVERSAL::can($err, 'type')
543 0 18 if $seen_filters{$name}++
547 0 36 if (scalar keys %seen_filters and $seen_filters{$$var[$i - 5] or ''})
558 845 1666 if ($was_dot_call and UNIVERSAL::can($ref, 'can'))
559 0 845 if $i >= $#$var and $$ARGS{'return_ref'}
561 139 706 $args ? :
562 21 824 if ($type eq 'item') { }
21 803 elsif ($type eq 'list') { }
570 13 790 if ($@) { }
790 0 elsif (defined $results[0]) { }
0 0 elsif (defined $results[1]) { }
572 0 9 if ref $@ or not $@ =~ /Can\'t locate object method "\Q$name\E" via package "\Q$class\E"/ or $type eq 'list'
574 23 767 $#results > 0 ? :
585 1056 619 if (UNIVERSAL::isa($ref, 'HASH')) { }
619 0 elsif (UNIVERSAL::isa($ref, 'ARRAY')) { }
586 756 300 if ($was_dot_call and exists $$ref{$name}) { }
171 129 elsif ($$Template::Alloy::HASH_OPS{$name}) { }
6 123 elsif ($$ARGS{'is_namespace_during_compile'}) { }
587 12 592 if $i >= $#$var and $$ARGS{'return_ref'} and not ref $$ref{$name}
590 72 99 $args ? :
594 3 120 if $i >= $#$var and $$ARGS{'return_ref'}
599 155 464 if ($name =~ / ^ -? $QR_INDEX $ /ox) { }
464 0 elsif ($$Template::Alloy::LIST_OPS{$name}) { }
600 6 137 if $i >= $#$var and $$ARGS{'return_ref'} and not ref $$ref[$name]
603 146 318 $args ? :
612 831 17796 unless (defined $ref)
613 27 804 if $$self{'STRICT'}
614 6 801 if $$self{'_debug_undef'}
627 331 5752 unless ref $var
632 18 6065 if (ref $ref) { }
6065 0 elsif (defined $ref) { }
634 0 18 if ref $ref ne 'ARRAY'
635 6 12 if (not defined $$ref[0]) { }
636 0 6 unless $$ref[1] and $$ref[1] =~ /^[\$\@]\(\)$/
641 12 0 if (defined $ref and not $QR_PRIVATE && $ref =~ /$QR_PRIVATE/) { }
642 6 6 if ($#$var <= $i) { }
652 3 6062 if $QR_PRIVATE and $ref =~ /$QR_PRIVATE/
653 5880 182 if ($#$var <= $i) { }
663 6 250 if (UNIVERSAL::isa($ref, 'CODE'))
665 0 6 $args ? :
666 0 6 if ($type eq 'item') { }
670 3 3 if ($type eq 'list') { }
3 0 elsif (defined $results[0]) { }
0 0 elsif (defined $results[1]) { }
673 0 3 $#results > 0 ? :
683 0 256 if $i >= $#$var
684 6 250 $$ARGS{'no_dots'} ? :
689 18 238 if (ref $name)
690 18 0 if (ref $name eq 'ARRAY') { }
692 0 18 if (not defined $name or $name =~ /^[_.]/)
699 0 256 if ($QR_PRIVATE and $name =~ /$QR_PRIVATE/)
704 0 256 if (not ref $ref) { }
49 207 elsif (UNIVERSAL::can($ref, 'can')) { }
711 0 49 $args ? :
712 40 9 if ($i >= $#$var)
716 3 46 if ($type eq 'item') { }
3 43 elsif ($type eq 'list') { }
718 3 0 if $lvalueish
722 3 0 if $lvalueish
726 39 4 unless ($@)
727 39 0 if (defined $results[0]) { }
0 0 elsif (defined $results[1]) { }
728 0 39 $#results > 0 ? :
734 30 9 if $lvalueish
738 4 0 if ref $@ or not $@ =~ /Can\'t locate object method "\Q$name\E" via package "\Q$class\E"/
742 189 18 if (UNIVERSAL::isa($ref, 'HASH')) { }
18 0 elsif (UNIVERSAL::isa($ref, 'ARRAY')) { }
743 142 47 if ($#$var <= $i) { }
751 18 0 if ($name =~ / ^ -? $QR_INDEX $ /ox) { }
752 12 6 if ($#$var <= $i) { }
773 0 332 if @_ == 1
779 0 559 if ($file =~ m[^/]) { }
0 559 elsif ($file =~ m[(^|/)\.\./]) { }
780 0 0 unless $$self{'ABSOLUTE'}
781 0 0 if -e $file
783 0 0 unless $$self{'RELATIVE'}
784 0 0 if -e $file
788 60 0 if ($$self{'ADD_LOCAL_PATH'} and $$self{'_component'} and $$self{'_component'}{'_filename'} and $$self{'_component'}{'_filename'} =~ m[^(.+)/[^/]+$])
792 12 48 $$self{'ADD_LOCAL_PATH'} < 0 ? :
796 488 112 if -e "$path/$file"
807 0 426 if UNIVERSAL::isa($paths, 'CODE')
808 404 22 unless UNIVERSAL::isa($paths, 'ARRAY')
815 27 521 if UNIVERSAL::isa($path, 'ARRAY')
817 0 521 $delim eq ':' && $^O eq 'MSWin32' ? :
823 0 490 unless open my $fh, '<', $file
826 3 487 if ($$self{'ENCODING'})
828 0 3 if ($@ or not defined &Encode::decode) { }
844 13 522 if UNIVERSAL::can($type, 'type')
845 100 422 if (ref $info eq 'ARRAY')
846 0 100 ref $$info[-1] eq 'HASH' ? :
847 0 100 if (@$info >= 2 or scalar keys %$hash) { }
87 13 elsif (@$info == 1) { }
878 0 614 if $$self{'UNDEFINED_GET'}
884 0 801 if $$self{'UNDEFINED_ANY'}
893 3 24 $comp ne $temp ? :
894 6 21 if $$self{'STRICT_THROW'}
914 0 0 unless $$doc{'_filename'} or $$doc{'_content'}
931 0 3924 if (not $index or $index <= 0)
932 0 0 $include_char ? :
941 1680 504 if $i == 0
949 3350 574 if ($index > $$lines[-1]) { }
953 574 1530 if abs $i - $j <= 1
955 657 873 if $$lines[$k] >= $index
956 883 647 if $$lines[$k] <= $index
959 3822 102 $include_char ? :
965 2070 33178 unless defined $var
966 9986 23192 if ref $var
967 10155 13037 if $var =~ /^(-?[1-9]\d{0,13}|0)$/
975 3 33 unless (ref $ident)
976 3 0 if $ident eq '0' or $ident =~ /^[1-9]\d{0,12}$/
983 9 42 if $$ident[$i++]
984 18 33 if $i < @$ident
991 0 223 unless defined $text
995 30 193 if ++$$self{'_eval_recurse'} > ($$self{'MAX_EVAL_RECURSE'} || $MAX_EVAL_RECURSE)
1001 3 190 if exists $ARGS{'STRICT'} and not $ARGS{'STRICT'}
1005 11 179 unless $self->process_simple(\$text, $self->_vars, \$out)