Branch Coverage

blib/lib/Template/Sandbox.pm
Criterion Covered Total %
branch 566 636 88.9


line true false branch
140 510 39 if ref $ret ne 'ARRAY'
581 30 396 unless ref $self
601 4 416 unless ref $func eq 'ARRAY' or ref $func eq 'CODE'
608 1 415 if $^W and $$local_functions{$name}
614 1 415 if ref $func eq 'CODE'
636 1 19 if $^W and not $$local_functions{$name}
655 4 26 unless ref $self
682 4 20 unless ref $syntax eq 'HASH'
688 2 18 unless $$syntax{'compile'}
690 2 16 unless $$syntax{'run'}
693 1 15 if $^W and $$local_syntaxes{$name}
725 2 4 unless ($$local_syntaxes{$name})
727 1 1 if $^W
783 356 37 if ($valid_singular{$param_name}) { }
36 1 elsif ($valid_multiple{$param_name}) { }
810 3 1456 if exists $$param{'logger'}
815 1 1458 if exists $$param{'copy_global_functions'}
817 19 1440 if (exists $$param{'template_function'})
824 9 1448 if (exists $$param{'template_syntax'})
831 6 1447 if (exists $$param{'library'})
844 0 1453 if exists $$param{'ignore_module_dependencies'}
846 5 1448 if ($$param{'template_toolkit_compat'})
849 4 1 unless exists $$param{'open_delimiter'}
851 4 1 unless exists $$param{'close_delimiter'}
853 4 1 unless exists $$param{'allow_bare_expr'}
855 4 1 unless exists $$param{'vmethods'}
859 65 1388 if exists $$param{'open_delimiter'}
861 65 1388 if exists $$param{'close_delimiter'}
863 212 1241 if exists $$param{'allow_bare_expr'}
865 1 1452 if exists $$param{'vmethods'}
870 0 1453 if exists $$param{'cache'}
872 2 1451 if exists $$param{'template_root'}
874 3 1450 if exists $$param{'template'}
886 0 0 if exists $$self{'cache_uses_extended_set'}
895 0 0 if exists $$self{'cache_uses_extended_set'}
898 0 0 if $cache->isa('Cache::CacheFactory') or $cache->can('set_takes_named_param') and $cache->set_takes_named_param
917 4 16 $$self{'template_root'} ? :
925 14 0 $current_dir ? :
938 18 2 if -e $candidate
954 13 1 if -e $candidate
988 1 19 $defines ? :
1001 0 18 if $$self{'cache'} and $$self{'template'} = $$self{'cache'}->get($cache_key = $self->cache_key($defines))
1011 0 18 if ($$self{'cache'} and not $$self{'ignore_module_dependencies'})
1028 0 14 if ($$self{'cache'})
1034 0 0 if ($self->_cache_uses_extended_set) { }
1057 5 1408 $defines ? :
1071 0 1413 if $$self{'cache'} and $$self{'template'} = $$self{'cache'}->get($cache_key = $self->cache_key($defines))
1081 0 1413 if ($$self{'cache'} and not $$self{'ignore_module_dependencies'})
1098 0 1314 if ($$self{'cache'})
1104 0 0 if ($self->_cache_uses_extended_set) { }
1125 2 157 unless ref $self
1128 148 11 $$self{'phase'} ? :
1131 126 33 if ($pos)
1135 23 103 if ($$self{'template'} and ref $$self{'template'} eq 'HASH' and $$self{'template'}{'files'}) { }
103 0 elsif ($$self{'files'}) { }
1151 103 23 if ($$self{'pos_stack'})
1158 1 103 unless $first
1173 135 22 unless exists $$self{'logger'}
1180 1 138 unless ref $self
1182 137 1 if $$self{'logger'}
1189 1 19 unless ref $self
1191 18 1 if $$self{'logger'}
1255 1 513 if $var =~ /\./o
1272 1 368 if @bad_vars = grep(/\./o, keys %{$vars;})
1291 8 2 unless $ref
1298 0 4 unless (exists $$ref{$var} and ref $value and ref $value eq 'HASH' || ref $value eq 'ARRAY')
1306 2 2 if (ref $value eq 'HASH') { }
2 0 elsif (ref $value eq 'ARRAY') { }
1315 2 0 if (ref $$ref{$var} eq 'ARRAY') { }
1359 1 18 if ($$self{'seen_defines'}{$define}++) { }
13 5 elsif (defined $$defines{$define}) { }
3 2 elsif (defined $default) { }
1379 4 15 if $quote
1381 18 1 if (defined $pos)
1386 4 14 $quote ? :
3 15 defined $default ? :
1390 1 17 if ($lines) { }
1413 1442 19 unless ($$self{'seen_defines'})
1420 18 1 $top ? :
1422 1442 19 if ($top)
1425 1429 13 unless @{$$self{'offsets'};}
1426 13 1429 if ($$self{'offsets'})
1462 0 29 unless $fh
1502 17 14 $$syntax{'positional_args'} ? :
1503 1 30 $$syntax{'valid_args'} ? :
1513 5 33 if ($instr) { }
1515 2 3 if $words[$count] =~ /\"$/
1523 27 6 unless $words[$count] =~ /^\"/ or $words[$count] =~ /=\"/
1524 4 2 if $words[$count] =~ /\"$/
1532 10 17 if $words[$count] =~ /=/
1535 16 15 $count ? :
1536 10 21 $count < @words ? :
1541 0 31 if @pos_param > @positions
1548 4 13 if $word =~ /^\"(.*)\"$/
1558 1 15 unless (defined $value)
1564 2 13 if $value =~ /^\"(.*)\"$/
1620 9 1422 if $local_syntax_regexp
1634 212 1219 if $$self{'allow_bare_expr'}
1655 2375 1159 if ($hunk =~ /$hunk_regexp/) { }
1665 0 2375 if $args =~ /$open_regexp/
1669 981 1394 if (defined $rest)
1677 55 2320 if ($token eq 'end')
1679 0 55 unless @nest_stack
1681 5 50 $nest_stack[0][0] eq 5 ? :
1685 0 2375 if $$local_token_aliases{$token}
1687 220 2155 if $token_aliases{$token}
1695 58 2317 if ($$syntax{'zero_width'} and $i < @hunks - 1 and !@compiled || $compiled[@compiled - 1][0] == 0 && $compiled[@compiled - 1][2] =~ /\n\ *$/ || $compiled[@compiled - 1][0] == 7 and $hunks[$i + 1] =~ /^\n\ */) { }
1710 14 2361 if ($$syntax{'compile'}) { }
1 2360 elsif ($token eq 'debug') { }
1031 1329 elsif ($token eq 'expr' or $token eq 'var') { }
352 977 elsif ($token eq 'if' or $token eq 'unless') { }
316 661 elsif ($token eq 'elsif' or $token eq 'elsunless') { }
157 504 elsif ($token eq 'else') { }
349 155 elsif ($token eq 'endif' or $token eq 'endunless') { }
65 90 elsif ($token eq 'for') { }
62 28 elsif ($token eq 'endfor') { }
16 12 elsif ($token eq 'include') { }
10 2 elsif ($token eq 'endinclude') { }
2 0 elsif ($token eq '#') { }
1719 13 1 if defined $args
1725 0 1 unless keys %{$args;}
1736 1 983 $$expr[0] == 100 && $$expr[2] eq '=' ? :
1747 153 199 if ($token ne 'if')
1749 24 129 if ($$expr[0] == 0) { }
1770 2 314 if (not @nest_stack or $nest_stack[0][0] ne 'if' and $nest_stack[0][0] ne 'elsif')
1781 122 192 if ($token ne 'elsif')
1783 16 106 if ($$expr[0] == 0) { }
1804 2 155 if (not @nest_stack or $nest_stack[0][0] ne 'if' and $nest_stack[0][0] ne 'elsif')
1819 2 317 if (not @nest_stack or $nest_stack[0][0] ne 'if' and $nest_stack[0][0] ne 'elsif' and $nest_stack[0][0] ne 'else')
1829 192 155 unless $nest_stack[0][0] eq 'else'
1836 347 469 if ($$last[0] eq 'if') { }
469 0 elsif ($$last[0] eq 'elsif' or $$last[0] eq 'else') { }
1870 2 60 if (not @nest_stack or $nest_stack[0][0] ne 5)
1903 14 1 if ($filename = $$args{'filename'})
1931 11 3 unless keys %{$args;}
1935 2 11 if $includes{$filename}
1952 10 1 unless (exists $file_numbers{$filename})
1969 0 10 unless @pos_stack
1993 42 1117 if ($hunk =~ /^$open_regexp/)
2000 1117 0 if (length $hunk)
2002 54 1063 if $trim_next
2061 1 17 if $$offset[2]
2069 98 3325 if ($lines) { }
2072 11 87 $hunk =~ /\n(.+)\z/mo ? :
2080 15 3408 if ($offset_index != -1)
2085 13 2 unless @{$$pos[4];}
2087 5 10 $lines ? :
2093 6 12 if $$offset[0] < $nlpos
2101 11 3412 if $queue_pos
2104 2 1328 if @nest_stack
2107 0 1328 if @pos_stack > 1
2114 0 54 unless $compiled[$addr][0] == 0
2165 3155 204 unless $$program[$i][0] == 2 and $$program[$i][2][0] == 0
2179 3265 94 unless $$program[$i][0] == 4 and $$program[$i][3][0] == 0
2185 48 46 if ($value) { }
2199 36 1292 if %deletes
2207 10 3301 if ($$program[$i][0] == 7)
2210 7 3 unless $$program[$i][2]
2213 10 3291 if ($$program[$i][0] == 8)
2218 7 3 if $deletes{$match}
2222 6 1322 if %deletes
2233 2095 120 unless $$line[0] == 3 or $$line[0] == 4 or $$line[0] == 5 or $$line[0] == 6
2244 1898 75 if $$program[$i][0] != 0 or $$program[$i - 1][0] != 0
2248 32 43 if $jump_targets{$i}
2258 29 1299 if %deletes
2265 3194 60 if $$program[$i][0] != 5
2280 47 81 if ($$line[0] == 2) { }
3 78 elsif ($$line[0] == 5) { }
4 74 elsif ($$line[0] == 4) { }
1 73 elsif ($$line[0] == 7) { }
2297 73 55 unless @exprs
2304 54 9 if ($type == 104) { }
1 8 elsif ($type == 100) { }
1 7 elsif ($type == 101) { }
6 1 elsif ($type == 102) { }
1 0 elsif ($type == 103) { }
2310 20 34 unless $$expr[4] > 0
2312 1 33 unless $$segments[0] eq $$block[2]
2315 31 2 if (ref $$segments[1] or exists $special_values_names{$$segments[1]})
2343 29 31 unless $special_vars_needed
2443 294 30 unless ($instr = $$line[0]) == 3 or $instr == 4 or $instr == 5 or $instr == 6
2448 16 117 if (exists $renumbers{$num = $$line[2]})
2458 90 27 if ($lastnum <= $num) { }
2466 35 60 if $addrs[$offset] >= $num
2474 16 10 if $addrs[$offset - 1] < $num
2495 6 3602 unless $expression =~ /^$expr_regexp$/so
2507 319 3283 if @top_level
2513 45 3238 if (my($op, $subexpr) = $expression =~ /$capture_unary_operator_regexp/)
2519 24 21 if $$subexpr[0] == 0
2530 5 3233 if $expression =~ /^\((.*)\)$/so
2534 413 2820 if $expression =~ /^$literal_number_regexp$/so
2538 1012 1808 if ($expression =~ /^$single_quoted_text_regexp$/so)
2549 1808 0 if $expression =~ /^$chained_operation_regexp$/so
2568 0 801 unless @{$arr;}
2574 483 639 if ref $$arr[$i]
2578 481 320 if @{$arr;} == 1
2596 79 241 if ($i < 3 || $weight <= $operators{$$arr[$i - 2]}[0] and $i >= @{$arr;} - 2 || $weight <= $operators{$$arr[$i + 2]}[0] and $$lhs[0] == 0 and $$rhs[0] == 0)
2605 0 79 $$lhs[3] ? :
0 79 $$rhs[3] ? :
2612 79 0 $i <= 3 ? :
2617 79 241 if @{$arr;} == 1
2626 241 1 if ($operators{$op}[0] > $highest_weight)
2649 277 1818 if @segments == 1 and ref $segments[0]
2652 4 1814 if ($segments[@segments - 1] eq '__size__')
2672 3 1805 if exists $symbolic_literals{$chain}
2679 1805 0 if (($segment, $chain) = $chain =~ /$capture_chained_operation_top_regexp/) { }
2688 315 1490 if ($segment =~ /$capture_function_regexp/) { }
2692 112 162 unless $chain
2693 0 162 if $$segment[0] == 0
2716 486 904 if ($segment =~ /$capture_literal_subscript_regexp/)
2724 465 439 if (($subscript) = $segment =~ /$capture_expr_subscript_regexp/)
2735 451 14 if ($$index[0] == 0) { }
2749 439 0 if (my($method, $args) = $segment =~ /$capture_method_subscript_regexp/)
2757 1 438 if ($$self{'vmethods'}) { }
2765 0 1 if $$func[0] == 0
2780 0 1652 if $chain
2793 70 246 if $functions{$func}
2796 208 108 if $$self{'local_functions'} and $$self{'local_functions'}{$func}
2798 39 277 unless $func_def
2801 1 276 if $prepend_args
2804 276 1 if (($numargs = $$func_def[1]) >= 0)
2808 1 275 if @{$args;} < $numargs
2811 1 274 if @{$args;} > $numargs
2814 274 1 unless ($$func_def[3])
2820 67 178 if $$arg[0] == 0
2826 96 178 unless ($nonliteral)
2833 1 95 ref $ret eq 'SCALAR' ? :
2837 1 178 if $$func_def[2]
2863 0 715 if $arglist
2879 958 2450 if (($type = $$expr[0]) == 0) { }
1499 951 elsif ($type == 104) { }
245 706 elsif ($type == 100) { }
57 649 elsif ($type == 101) { }
206 443 elsif ($type == 102) { }
442 1 elsif ($type == 103) { }
1 0 elsif ($type == 105) { }
2895 49 196 if ($$val[2]) { }
2922 29 177 if $functions{$$expr[2]}
2925 175 31 if $$self{'local_functions'} and $$self{'local_functions'}{$$expr[2]}
2926 2 204 unless $val
2927 26 178 if ($$val[4]) { }
2953 10 8 unless defined $val or $undef_ok or $$expr[1] eq 'undef'
2975 63 16 unless $$op[2]
2989 16 65 if $op eq '!'
2991 48 17 if $op eq 'not'
2994 17 0 if $op eq '-'
3006 0 1 if $$lhs[0] != 104
3011 0 1 if @{$$lhs[2];} > 1
3021 0 0 unless exists $$var_stack[$counter]{$var}
3034 855 644 unless $_[5]
3044 160 484 if ($last >= 1 and $$special_values{$stem} and exists $special_values_names{$$segments[1]}) { }
3058 324 160 if (ref $stem) { }
3072 22 904 if (ref($leaf = $$segments[$i]))
3075 2 20 unless (defined($leaf = $self->_eval_expression($leaf)))
3077 0 2 if $undef_ok
3086 15 5 if ($i == 1)
3088 5 10 if ($$special_values{$stem} and exists $special_values_names{$leaf})
3098 2 917 unless (defined $val)
3100 0 2 if $undef_ok
3101 2 0 $$originals[$i] ne $leaf ? :
3109 2 915 if (not $type = ref $val) { }
9 906 elsif ($type eq 'ARRAY') { }
3114 2 0 $$originals[$i] ne $leaf ? :
3122 2 0 $$originals[$i] ne $leaf ? :
2 7 unless $leaf =~ /^\d+$/o
3147 64 32 if $functions{$func}
3150 33 63 if $$self{'local_functions'} and $$self{'local_functions'}{$func}
3151 0 96 unless $val
3153 2 94 if ($$val[4]) { }
3169 1 95 if ($$val[2]) { }
3187 1 441 unless defined $expr
3189 1 440 unless ref $expr
3195 1 439 unless $expr->valid_template_method($method)
3261 638 1449 if (($instr = $$line[0]) == 0) { }
952 497 elsif ($instr == 2) { }
110 387 elsif ($instr == 3) { }
102 285 elsif ($instr == 4) { }
55 230 elsif ($instr == 5) { }
205 25 elsif ($instr == 6) { }
6 19 elsif ($instr == 7) { }
6 13 elsif ($instr == 8) { }
11 2 elsif ($$self{'local_syntaxes'}{'.instr'}{$instr}) { }
2 0 elsif ($syntaxes{'.instr'}{$instr}) { }
0 0 elsif ($instr == 1) { }
3268 1 937 ref $value eq 'SCALAR' ? :
938 1 unless $$line[3]
3281 45 57 unless $value
3292 1 54 unless defined $set_value
3294 16 39 if (ref $set_value eq 'HASH') { }
30 9 elsif (not ref $set_value) { }
3308 3 52 if ($last == -1) { }
3317 1 33 $last == 0 ? :
1 33 $last == 0 ? :
11 23 $hash ? :
34 18 if $specials_needed
3332 3 49 if ($var_stack[0]{$iterator}) { }
3343 3 49 $context ? :
3359 153 52 if ($counter <= $last) { }
3366 57 53 $counter % 2 ? :
33 77 $counter == $last ? :
33 77 $counter == $last ? :
33 77 $counter == $last ? :
20 90 $hash ? :
110 43 if $specials_needed
3386 3 49 if ($for_stack[0][4]) { }
3429 10 1 if defined $value
3440 2 0 if defined $value
3491 29 0 if $file =~ m[^string:///]
3497 17 12 if ($instr == 0) { }
5 7 elsif ($instr == 2) { }
2 5 elsif ($instr == 3) { }
1 4 elsif ($instr == 4) { }
2 2 elsif ($instr == 5) { }
2 0 elsif ($instr == 6) { }
0 0 elsif ($instr == 7) { }
0 0 elsif ($instr == 8) { }
3504 0 5 $$line[3] ? :
3520 1 1 unless $$line[5]