Branch Coverage

blib/lib/Template/Alloy.pm
Criterion Covered Total %
branch 391 502 77.8


line true false branch
51 41 2 $AUTOLOAD && $AUTOLOAD =~ /::(\w+)$/ ? :
52 1 40 unless ($self->can($meth))
61 41 1 if $ROLEMAP->{$meth}
70 6 72 if $item =~ /^(load|1)$/i
71 2 70 if (lc $item eq 'all')
77 7 63 if ($type = $STANDIN{$item})
79 4 3 unless ($INC{$file} and $item->isa('Template::Alloy'))
80 1 3 if ($INC{$file})
83 0 3 unless $Template::Alloy::AUTOROLE->{$type}
86 61 2 $Template::Alloy::AUTOROLE->{$item} ? :
103 1 4300 ref $_[0] ? :
106 253 4048 if (my(@keys) = grep({/^[a-z][a-z_]+$/;} keys %$args))
130 40 730 if (my $err = $@)
131 40 0 if (not $err->type =~ /stop|return|next|last|break/) { }
0 0 elsif ($err->type eq 'return' and UNIVERSAL::isa($err->info, 'HASH')) { }
133 0 40 if $self->{'RAISE_ERROR'}
153 145 5204 ref $file eq 'HASH' ? :
157 6 5155 if not $self->{'RECURSION'} and $self->{'_in'}{$doc->{'name'}} and $doc->{'name'} ne 'input text'
161 4329 838 $self->{'_top_level'} ? :
165 1356 3811 if ($self->{'STREAM'}) { }
0 3811 elsif ($self->{'COMPILE_JS'}) { }
1869 1942 elsif ($doc->{'_perl'}) { }
1941 1 elsif ($doc->{'_tree'}) { }
166 0 1356 unless $doc->{'_tree'}
179 27 4945 if ($self->{'TRIM'})
186 377 4972 if (my $err = $@)
187 2 375 unless UNIVERSAL::can($err, 'type')
188 161 40 if $doc and $err->can('doc') and not $err->doc
189 104 273 unless $self->{'_top_level'}
190 235 12 if $err->type ne 'stop' and $err->type ne 'return' || $err->info
200 1 5380 unless defined $file
203 13 5367 unless ref $docs
207 4581 799 if (ref $file) { }
19 780 elsif ($docs->{$file}) { }
13 767 elsif ($self->{'_not_found'}{$file}) { }
235 532 elsif ($self->{'BLOCKS'}{$file}) { }
208 1 4580 if ref $file eq 'HASH'
210 4577 3 if (not defined $self->{'CACHE_STR_REFS'} or $self->{'CACHE_STR_REFS'}) { }
212 193 4384 if ($docs->{$_file})
214 2 130 if not $doc->{'_perl'} and $self->{'COMPILE_PERL'}
219 1 2 $self->{'FORCE_STR_REF_PERL'} ? :
229 19 0 if (time - $doc->{'cache_time'} < ($self->{'STAT_TTL'} || $STAT_TTL) or $doc->{'modtime'} == (stat $doc->{'_filename'})[9])
231 1 12 if not $doc->{'_perl'} and $self->{'COMPILE_PERL'}
239 7 6 if (time - $doc->{'cache_time'} < ($self->{'NEGATIVE_STAT_TTL'} || $self->{'STAT_TTL'} || $STAT_TTL))
247 1 234 if UNIVERSAL::isa($block, 'CODE')
248 4 231 unless (UNIVERSAL::isa($block, 'HASH'))
249 1 3 if ref $block
252 229 4 $block->{'name'} && $block->{'name'} ne 'input text' ? :
253 232 1 if $block->{'_filename'}
254 81 152 if ($block->{'_perl'}) { }
151 1 elsif ($block->{'_tree'}) { }
265 538 3 unless ($doc->{'_filename'} or ref $file)
268 71 467 if (my $err = $@)
270 18 53 if ($self->{'EXPOSE_BLOCKS'} and not $self->{'_looking_in_block_file'}) { }
0 53 elsif ($self->{'DEFAULT'}) { }
274 0 12 length $block_name ? :
278 0 30 unless ref $node
279 12 18 if $node->[0] eq 'META'
280 0 18 if $node->[0] ne 'BLOCK'
281 6 12 if $block_name ne $node->[3]
288 4 0 if $ref->{'_perl'} and $ref->{'_perl'}{'blocks'} and $ref->{'_perl'}{'blocks'}{$block_name}
289 0 0 if $self->{'COMPILE_JS'} and $ref->{'_js'}
294 0 0 if $doc->{'_filename'} = eval { do { $self->include_filename($self->{'DEFAULT'}) } }
296 59 0 if ($err)
298 59 0 if (not defined $self->{'NEGATIVE_STAT_TTL'} or $self->{'NEGATIVE_STAT_TTL'})
299 0 59 unless UNIVERSAL::can($err, 'type')
311 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'}) { }
320 4469 252 if (not defined $self->{'CACHE_SIZE'} or $self->{'CACHE_SIZE'})
322 4024 445 if (ref $file) { }
323 4021 3 if $doc->{'_filename'}
329 0 4469 if ($self->{'CACHE_SIZE'})
330 0 0 if (scalar keys %$docs > $self->{'CACHE_SIZE'})
333 0 0 if ++$n > $self->{'CACHE_SIZE'}
349 1 4577 ref $self && $self->{'ENCODING'} && eval { do { require Encode } } && defined &Encode::encode ? :
359 4850 3 if ($doc->{'_filename'})
361 16 4834 if ($self->{'COMPILE_DIR'} or $self->{'COMPILE_EXT'})
363 8 8 if ($self->{'COMPILE_DIR'}) { }
2 6 elsif ($doc->{'_is_str_ref'}) { }
364 0 8 if $^O eq 'MSWin32'
369 12 4 if defined $self->{'COMPILE_EXT'}
370 16 0 if defined $EXTRA_COMPILE_EXT
372 1 0 if (-e $file and $doc->{'_is_str_ref'} || (stat $file)[9] == $doc->{'modtime'})
383 33 4819 if ($self->{'CONSTANTS'})
393 15 4704 if ($doc->{'_storable_filename'})
396 10 5 unless (-d $dir)
412 9553 18936 unless ref $_[1]
423 9292 9644 if (ref $name) { }
9644 0 elsif (defined $name) { }
424 9118 174 if (not defined $name->[0]) { }
425 192 8926 if wantarray and $name->[1] eq '..'
426 110 8816 $name->[1] eq '-temp-' ? :
429 174 0 if (defined $name)
430 3 171 if $QR_PRIVATE and $name =~ /$QR_PRIVATE/
431 0 111 if $i >= $#$var and $ARGS->{'return_ref'} and not ref $self->{'_vars'}{$name}
436 15 9629 if $QR_PRIVATE and $name =~ /$QR_PRIVATE/
437 6 7068 if $i >= $#$var and $ARGS->{'return_ref'} and not ref $self->{'_vars'}{$name}
439 873 8750 unless (defined $ref)
440 175 698 $name eq 'template' || $name eq 'component' ? :
441 665 6 if not $ref and !defined($self->{'VMETHOD_FUNCTIONS'}) || $self->{'VMETHOD_FUNCTIONS'}
442 59 576 if not defined $ref and $self->{'LOWER_CASE_VAR_FALLBACK'}
450 547 20724 if (UNIVERSAL::isa($ref, 'CODE'))
451 15 505 if $i >= $#$var and $ARGS->{'return_ref'}
452 161 371 $args ? :
454 39 493 if ($type eq 'item') { }
458 33 457 if ($type eq 'list') { }
453 4 elsif (defined $results[0]) { }
0 4 elsif (defined $results[1]) { }
461 21 432 $#results > 0 ? :
472 17796 3453 if $i >= $#$var
473 0 3453 $ARGS->{'no_dots'} ? :
478 60 3393 if (ref $name)
479 60 0 if (ref $name eq 'ARRAY') { }
481 0 60 if (not defined $name or $QR_PRIVATE and $name =~ /$QR_PRIVATE/ or $name =~ /^\./)
489 3 3450 if (not defined $name or $QR_PRIVATE and $name =~ /$QR_PRIVATE/)
495 939 2511 if (not ref $ref) { }
496 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}) { }
497 60 163 $args ? :
500 343 322 $args ? :
503 0 9 $args ? :
510 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')) { }
512 0 9 if (my $err = $@)
513 0 0 unless UNIVERSAL::can($err, 'type')
522 6 3 if ($filter->[1])
523 3 3 $args ? :
524 0 6 if (not $sub and $err) { }
0 6 elsif (not UNIVERSAL::isa($sub, 'CODE')) { }
525 0 0 unless UNIVERSAL::can($err, 'type')
528 0 0 unless UNIVERSAL::can($sub, 'type')
535 0 9 if (my $err = $@)
536 0 0 unless UNIVERSAL::can($err, 'type')
540 0 18 if $seen_filters{$name}++
544 0 36 if (scalar keys %seen_filters and $seen_filters{$$var[$i - 5] or ''})
555 845 1666 if ($was_dot_call and UNIVERSAL::can($ref, 'can'))
556 0 805 if $i >= $#$var and $ARGS->{'return_ref'}
558 139 706 $args ? :
559 21 824 if ($type eq 'item') { }
21 803 elsif ($type eq 'list') { }
567 13 790 if ($@) { }
790 0 elsif (defined $results[0]) { }
0 0 elsif (defined $results[1]) { }
569 0 9 if ref $@ or not $@ =~ /Can\'t locate object method "\Q$name\E" via package "\Q$class\E"/ or $type eq 'list'
571 23 767 $#results > 0 ? :
582 1056 619 if (UNIVERSAL::isa($ref, 'HASH')) { }
619 0 elsif (UNIVERSAL::isa($ref, 'ARRAY')) { }
583 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'}) { }
584 12 592 if $i >= $#$var and $ARGS->{'return_ref'} and not ref $ref->{$name}
587 72 99 $args ? :
591 3 117 if $i >= $#$var and $ARGS->{'return_ref'}
596 155 464 if ($name =~ / ^ -? $QR_INDEX $ /ox) { }
464 0 elsif ($Template::Alloy::LIST_OPS->{$name}) { }
597 6 137 if $i >= $#$var and $ARGS->{'return_ref'} and not ref $ref->[$name]
600 146 318 $args ? :
611 831 17796 unless (defined $ref)
612 27 804 if $self->{'STRICT'}
613 6 801 if $self->{'_debug_undef'}
626 331 5752 unless ref $var
631 18 6065 if (ref $ref) { }
6065 0 elsif (defined $ref) { }
633 0 18 if ref $ref ne 'ARRAY'
634 6 12 if (not defined $ref->[0]) { }
635 0 6 unless $ref->[1] and $ref->[1] =~ /^[\$\@]\(\)$/
640 12 0 if (defined $ref and not $QR_PRIVATE && $ref =~ /$QR_PRIVATE/) { }
641 6 6 if ($#$var <= $i) { }
651 3 6062 if $QR_PRIVATE and $ref =~ /$QR_PRIVATE/
652 5880 182 if ($#$var <= $i) { }
662 6 250 if (UNIVERSAL::isa($ref, 'CODE'))
664 0 6 $args ? :
665 0 6 if ($type eq 'item') { }
669 3 3 if ($type eq 'list') { }
3 0 elsif (defined $results[0]) { }
0 0 elsif (defined $results[1]) { }
672 0 3 $#results > 0 ? :
682 0 256 if $i >= $#$var
683 6 250 $ARGS->{'no_dots'} ? :
688 18 238 if (ref $name)
689 18 0 if (ref $name eq 'ARRAY') { }
691 0 18 if (not defined $name or $name =~ /^[_.]/)
698 0 256 if ($QR_PRIVATE and $name =~ /$QR_PRIVATE/)
703 0 256 if (not ref $ref) { }
49 207 elsif (UNIVERSAL::can($ref, 'can')) { }
710 0 49 $args ? :
711 40 9 if ($i >= $#$var)
715 3 46 if ($type eq 'item') { }
3 43 elsif ($type eq 'list') { }
717 3 0 if $lvalueish
721 3 0 if $lvalueish
725 39 4 unless ($@)
726 39 0 if (defined $results[0]) { }
0 0 elsif (defined $results[1]) { }
727 0 39 $#results > 0 ? :
733 30 9 if $lvalueish
737 4 0 if ref $@ or not $@ =~ /Can\'t locate object method "\Q$name\E" via package "\Q$class\E"/
741 189 18 if (UNIVERSAL::isa($ref, 'HASH')) { }
18 0 elsif (UNIVERSAL::isa($ref, 'ARRAY')) { }
742 142 47 if ($#$var <= $i) { }
750 18 0 if ($name =~ / ^ -? $QR_INDEX $ /ox) { }
751 12 6 if ($#$var <= $i) { }
772 0 332 if @_ == 1
778 0 559 if ($file =~ m[^/]) { }
0 559 elsif ($file =~ m[(^|/)\.\./]) { }
779 0 0 unless $self->{'ABSOLUTE'}
780 0 0 if -e $file
782 0 0 unless $self->{'RELATIVE'}
783 0 0 if -e $file
787 60 0 if ($self->{'ADD_LOCAL_PATH'} and $self->{'_component'} and $self->{'_component'}{'_filename'} and $self->{'_component'}{'_filename'} =~ m[^(.+)/[^/]+$])
791 12 48 $self->{'ADD_LOCAL_PATH'} < 0 ? :
795 488 112 if -e "$path/$file"
806 0 426 if UNIVERSAL::isa($paths, 'CODE')
807 404 22 unless UNIVERSAL::isa($paths, 'ARRAY')
814 27 521 if UNIVERSAL::isa($path, 'ARRAY')
816 0 521 $delim eq ':' && $^O eq 'MSWin32' ? :
822 0 490 unless open my $fh, '<', $file
825 3 487 if ($self->{'ENCODING'})
827 0 3 if ($@ or not defined &Encode::decode) { }
843 13 522 if UNIVERSAL::can($type, 'type')
844 100 422 if (ref $info eq 'ARRAY')
845 0 100 ref $info->[-1] eq 'HASH' ? :
846 0 100 if (@$info >= 2 or scalar keys %$hash) { }
87 13 elsif (@$info == 1) { }
877 0 614 if $self->{'UNDEFINED_GET'}
883 0 801 if $self->{'UNDEFINED_ANY'}
892 3 24 $comp ne $temp ? :
893 6 21 if $self->{'STRICT_THROW'}
916 0 0 unless $doc->{'_filename'} or $doc->{'_content'}
930 0 3924 if (not $index or $index <= 0)
931 0 0 $include_char ? :
940 1680 504 if $i == 0
948 3350 574 if ($index > $lines->[-1]) { }
952 574 1530 if abs $i - $j <= 1
954 657 873 if $lines->[$k] >= $index
955 883 647 if $lines->[$k] <= $index
958 3822 102 $include_char ? :
964 2070 33178 unless defined $var
965 9986 23192 if ref $var
966 10155 13037 if $var =~ /^(-?[1-9]\d{0,13}|0)$/
974 3 33 unless (ref $ident)
975 3 0 if $ident eq '0' or $ident =~ /^[1-9]\d{0,12}$/
982 9 42 if $$ident[$i++]
983 18 33 if $i < @$ident
990 0 223 unless defined $text
995 30 193 if ++$self->{'_eval_recurse'} > ($self->{'MAX_EVAL_RECURSE'} || $MAX_EVAL_RECURSE)
1000 3 190 if exists $ARGS{'STRICT'} and not $ARGS{'STRICT'}
1004 11 179 unless $self->process_simple(\$text, $self->_vars, \$out)