Branch Coverage

blib/lib/Template/Sandbox.pm
Criterion Covered Total %
branch 588 642 91.5


line true false branch
149 536 42 if ref $ret ne 'ARRAY'
590 31 396 unless ref $self
610 4 417 unless ref $func eq 'ARRAY' or ref $func eq 'CODE'
617 1 416 if $^W and $$local_functions{$name}
623 1 416 if ref $func eq 'CODE'
645 1 19 if $^W and not $$local_functions{$name}
664 4 26 unless ref $self
691 4 20 unless ref $syntax eq 'HASH'
697 2 18 unless $$syntax{'compile'}
699 2 16 unless $$syntax{'run'}
702 1 15 if $^W and $$local_syntaxes{$name}
734 2 4 unless ($$local_syntaxes{$name})
736 1 1 if $^W
794 380 37 if ($valid_singular{$param_name}) { }
36 1 elsif ($valid_multiple{$param_name}) { }
821 3 1472 if (exists $$param{'logger'}) { }
823 1 2 if $$param{'logger'}
833 1 1474 if exists $$param{'copy_global_functions'}
835 19 1456 if (exists $$param{'template_function'})
842 9 1464 if (exists $$param{'template_syntax'})
849 6 1463 if (exists $$param{'library'})
862 8 1461 if exists $$param{'ignore_module_dependencies'}
864 5 1464 if ($$param{'template_toolkit_compat'})
867 4 1 unless exists $$param{'open_delimiter'}
869 4 1 unless exists $$param{'close_delimiter'}
871 4 1 unless exists $$param{'allow_bare_expr'}
873 4 1 unless exists $$param{'vmethods'}
877 65 1404 if exists $$param{'open_delimiter'}
879 65 1404 if exists $$param{'close_delimiter'}
881 212 1257 if exists $$param{'allow_bare_expr'}
883 1 1468 if exists $$param{'vmethods'}
886 16 1453 if exists $$param{'cache'}
888 2 1467 if exists $$param{'template_root'}
890 3 1466 if exists $$param{'template'}
910 0 8 if exists $$self{'cache_uses_extended_set'}
913 4 4 if $cache->isa('Cache::CacheFactory') or $cache->can('set_takes_named_param') and $cache->set_takes_named_param
932 4 24 $$self{'template_root'} ? :
940 14 0 $current_dir ? :
953 26 2 if -e $candidate
969 13 1 if -e $candidate
999 1 27 $defines ? :
1007 8 18 if ($$self{'cache'})
1020 22 4 unless ($$self{'template'})
1031 2 20 if ($$self{'cache'} and not $$self{'ignore_module_dependencies'})
1048 4 14 if ($$self{'cache'})
1054 2 2 if ($self->_cache_uses_extended_set) { }
1083 5 1416 $defines ? :
1092 8 1413 if ($$self{'cache'})
1105 1417 4 unless ($$self{'template'})
1116 2 1415 if ($$self{'cache'} and not $$self{'ignore_module_dependencies'})
1133 4 1314 if ($$self{'cache'})
1139 2 2 if ($self->_cache_uses_extended_set) { }
1164 2 157 unless ref $self
1167 148 11 $$self{'phase'} ? :
1170 126 33 if ($pos)
1174 23 103 if ($$self{'template'} and ref $$self{'template'} eq 'HASH' and $$self{'template'}{'files'}) { }
103 0 elsif ($$self{'files'}) { }
1190 103 23 if ($$self{'pos_stack'})
1197 1 103 unless $first
1212 1 138 unless ref $self
1213 136 2 if $$self{'logger'}
1220 1 19 unless ref $self
1221 18 1 if $$self{'logger'}
1285 1 513 if $var =~ /\./o
1302 1 368 if @bad_vars = grep(/\./o, keys %{$vars;})
1321 8 2 unless $ref
1328 0 4 unless (exists $$ref{$var} and ref $value and ref $value eq 'HASH' || ref $value eq 'ARRAY')
1336 2 2 if (ref $value eq 'HASH') { }
2 0 elsif (ref $value eq 'ARRAY') { }
1345 2 0 if (ref $$ref{$var} eq 'ARRAY') { }
1389 1 18 if ($$self{'seen_defines'}{$define}++) { }
13 5 elsif (defined $$defines{$define}) { }
3 2 elsif (defined $default) { }
1409 4 15 if $quote
1411 18 1 if (defined $pos)
1416 4 14 $quote ? :
3 15 defined $default ? :
1420 1 17 if ($lines) { }
1443 1450 19 unless ($$self{'seen_defines'})
1450 18 1 $top ? :
1452 1450 19 if ($top)
1455 1437 13 unless @{$$self{'offsets'};}
1456 13 1437 if ($$self{'offsets'})
1492 0 33 unless $fh
1532 17 14 $$syntax{'positional_args'} ? :
1533 1 30 $$syntax{'valid_args'} ? :
1543 5 33 if ($instr) { }
1545 2 3 if $words[$count] =~ /\"$/
1553 27 6 unless $words[$count] =~ /^\"/ or $words[$count] =~ /=\"/
1554 4 2 if $words[$count] =~ /\"$/
1562 10 17 if $words[$count] =~ /=/
1565 16 15 $count ? :
1566 10 21 $count < @words ? :
1571 0 31 if @pos_param > @positions
1578 4 13 if $word =~ /^\"(.*)\"$/
1588 1 15 unless (defined $value)
1594 2 13 if $value =~ /^\"(.*)\"$/
1650 9 1430 if $local_syntax_regexp
1664 212 1227 if $$self{'allow_bare_expr'}
1685 2383 1167 if ($hunk =~ /$hunk_regexp/) { }
1695 0 2383 if $args =~ /$open_regexp/
1699 989 1394 if (defined $rest)
1707 55 2328 if ($token eq 'end')
1709 0 55 unless @nest_stack
1711 5 50 $nest_stack[0][0] eq 5 ? :
1715 0 2383 if $$local_token_aliases{$token}
1717 220 2163 if $token_aliases{$token}
1725 58 2325 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\ */) { }
1740 14 2369 if ($$syntax{'compile'}) { }
1 2368 elsif ($token eq 'debug') { }
1039 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 '#') { }
1749 13 1 if defined $args
1755 0 1 unless keys %{$args;}
1766 1 991 $$expr[0] == 100 && $$expr[2] eq '=' ? :
1777 153 199 if ($token ne 'if')
1779 24 129 if ($$expr[0] == 0) { }
1800 2 314 if (not @nest_stack or $nest_stack[0][0] ne 'if' and $nest_stack[0][0] ne 'elsif')
1811 122 192 if ($token ne 'elsif')
1813 16 106 if ($$expr[0] == 0) { }
1834 2 155 if (not @nest_stack or $nest_stack[0][0] ne 'if' and $nest_stack[0][0] ne 'elsif')
1849 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')
1859 192 155 unless $nest_stack[0][0] eq 'else'
1866 347 469 if ($$last[0] eq 'if') { }
469 0 elsif ($$last[0] eq 'elsif' or $$last[0] eq 'else') { }
1900 2 60 if (not @nest_stack or $nest_stack[0][0] ne 5)
1933 14 1 if ($filename = $$args{'filename'})
1961 11 3 unless keys %{$args;}
1965 2 11 if $includes{$filename}
1982 10 1 unless (exists $file_numbers{$filename})
1999 0 10 unless @pos_stack
2023 42 1125 if ($hunk =~ /^$open_regexp/)
2030 1125 0 if (length $hunk)
2032 54 1071 if $trim_next
2091 1 17 if $$offset[2]
2099 106 3333 if ($lines) { }
2102 11 95 $hunk =~ /\n(.+)\z/mo ? :
2110 15 3424 if ($offset_index != -1)
2115 13 2 unless @{$$pos[4];}
2117 5 10 $lines ? :
2123 6 12 if $$offset[0] < $nlpos
2131 11 3428 if $queue_pos
2134 2 1336 if @nest_stack
2137 0 1336 if @pos_stack > 1
2144 0 54 unless $compiled[$addr][0] == 0
2195 3163 212 unless $$program[$i][0] == 2 and $$program[$i][2][0] == 0
2209 3281 94 unless $$program[$i][0] == 4 and $$program[$i][3][0] == 0
2215 48 46 if ($value) { }
2229 36 1300 if %deletes
2237 10 3317 if ($$program[$i][0] == 7)
2240 7 3 unless $$program[$i][2]
2243 10 3307 if ($$program[$i][0] == 8)
2248 7 3 if $deletes{$match}
2252 6 1330 if %deletes
2263 2111 120 unless $$line[0] == 3 or $$line[0] == 4 or $$line[0] == 5 or $$line[0] == 6
2274 1898 83 if $$program[$i][0] != 0 or $$program[$i - 1][0] != 0
2278 32 51 if $jump_targets{$i}
2288 37 1299 if %deletes
2295 3202 60 if $$program[$i][0] != 5
2310 47 81 if ($$line[0] == 2) { }
3 78 elsif ($$line[0] == 5) { }
4 74 elsif ($$line[0] == 4) { }
1 73 elsif ($$line[0] == 7) { }
2327 73 55 unless @exprs
2334 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) { }
2340 20 34 unless $$expr[4] > 0
2342 1 33 unless $$segments[0] eq $$block[2]
2345 31 2 if (ref $$segments[1] or exists $special_values_names{$$segments[1]})
2373 29 31 unless $special_vars_needed
2473 302 30 unless ($instr = $$line[0]) == 3 or $instr == 4 or $instr == 5 or $instr == 6
2478 16 117 if (exists $renumbers{$num = $$line[2]})
2488 90 27 if ($lastnum <= $num) { }
2496 35 60 if $addrs[$offset] >= $num
2504 16 10 if $addrs[$offset - 1] < $num
2525 6 3610 unless $expression =~ /^$expr_regexp$/so
2537 319 3291 if @top_level
2543 45 3246 if (my($op, $subexpr) = $expression =~ /$capture_unary_operator_regexp/)
2549 24 21 if $$subexpr[0] == 0
2560 5 3241 if $expression =~ /^\((.*)\)$/so
2564 413 2828 if $expression =~ /^$literal_number_regexp$/so
2568 1012 1816 if ($expression =~ /^$single_quoted_text_regexp$/so)
2579 1816 0 if $expression =~ /^$chained_operation_regexp$/so
2598 0 801 unless @{$arr;}
2604 483 639 if ref $$arr[$i]
2608 481 320 if @{$arr;} == 1
2626 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)
2635 0 79 $$lhs[3] ? :
0 79 $$rhs[3] ? :
2642 79 0 $i <= 3 ? :
2647 79 241 if @{$arr;} == 1
2656 241 1 if ($operators{$op}[0] > $highest_weight)
2679 277 1818 if @segments == 1 and ref $segments[0]
2682 4 1814 if ($segments[@segments - 1] eq '__size__')
2702 3 1813 if exists $symbolic_literals{$chain}
2709 1813 0 if (($segment, $chain) = $chain =~ /$capture_chained_operation_top_regexp/) { }
2718 323 1490 if ($segment =~ /$capture_function_regexp/) { }
2722 120 162 unless $chain
2723 0 162 if $$segment[0] == 0
2747 486 904 if ($segment =~ /$capture_literal_subscript_regexp/)
2755 465 439 if (($subscript) = $segment =~ /$capture_expr_subscript_regexp/)
2766 451 14 if ($$index[0] == 0) { }
2780 439 0 if (my($method, $args) = $segment =~ /$capture_method_subscript_regexp/)
2788 1 438 if ($$self{'vmethods'}) { }
2796 0 1 if $$func[0] == 0
2812 0 1652 if $chain
2825 78 246 if $functions{$func}
2828 208 116 if $$self{'local_functions'} and $$self{'local_functions'}{$func}
2830 39 285 unless $func_def
2833 1 284 if $prepend_args
2836 284 1 if (($numargs = $$func_def[1]) >= 0)
2840 1 283 if @{$args;} < $numargs
2843 1 282 if @{$args;} > $numargs
2846 282 1 unless ($$func_def[3])
2852 67 178 if $$arg[0] == 0
2858 104 178 unless ($nonliteral)
2865 1 103 ref $ret eq 'SCALAR' ? :
2869 1 178 if $$func_def[2]
2895 0 723 if $arglist
2911 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) { }
2927 49 196 if ($$val[2]) { }
2954 29 177 if $functions{$$expr[2]}
2957 175 31 if $$self{'local_functions'} and $$self{'local_functions'}{$$expr[2]}
2958 2 204 unless $val
2959 26 178 if ($$val[4]) { }
2985 10 8 unless defined $val or $undef_ok or $$expr[1] eq 'undef'
3007 63 16 unless $$op[2]
3021 16 65 if $op eq '!'
3023 48 17 if $op eq 'not'
3026 17 0 if $op eq '-'
3038 0 1 if $$lhs[0] != 104
3043 0 1 if @{$$lhs[2];} > 1
3053 0 0 unless exists $$var_stack[$counter]{$var}
3066 855 644 unless $_[5]
3076 160 484 if ($last >= 1 and $$special_values{$stem} and exists $special_values_names{$$segments[1]}) { }
3090 324 160 if (ref $stem) { }
3104 22 904 if (ref($leaf = $$segments[$i]))
3107 2 20 unless (defined($leaf = $self->_eval_expression($leaf)))
3109 0 2 if $undef_ok
3118 15 5 if ($i == 1)
3120 5 10 if ($$special_values{$stem} and exists $special_values_names{$leaf})
3130 2 917 unless (defined $val)
3132 0 2 if $undef_ok
3133 2 0 $$originals[$i] ne $leaf ? :
3141 2 915 if (not $type = ref $val) { }
9 906 elsif ($type eq 'ARRAY') { }
3146 2 0 $$originals[$i] ne $leaf ? :
3154 2 0 $$originals[$i] ne $leaf ? :
2 7 unless $leaf =~ /^\d+$/o
3160 7 0 defined $$val[$leaf] ? :
3164 904 2 defined $$val{$leaf} ? :
3179 72 32 if $functions{$func}
3182 33 71 if $$self{'local_functions'} and $$self{'local_functions'}{$func}
3183 0 104 unless $val
3185 2 102 if ($$val[4]) { }
3201 1 103 if ($$val[2]) { }
3219 1 441 unless defined $expr
3221 1 440 unless ref $expr
3227 1 439 unless $expr->valid_template_method($method)
3293 654 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) { }
3300 1 937 ref $value eq 'SCALAR' ? :
938 1 unless $$line[3]
3313 45 57 unless $value
3324 1 54 unless defined $set_value
3326 16 39 if (ref $set_value eq 'HASH') { }
30 9 elsif (not ref $set_value) { }
3340 3 52 if ($last == -1) { }
3349 1 33 $last == 0 ? :
1 33 $last == 0 ? :
11 23 $hash ? :
34 18 if $specials_needed
3364 3 49 if ($var_stack[0]{$iterator}) { }
3375 3 49 $context ? :
3391 153 52 if ($counter <= $last) { }
3398 57 53 $counter % 2 ? :
33 77 $counter == $last ? :
33 77 $counter == $last ? :
33 77 $counter == $last ? :
20 90 $hash ? :
110 43 if $specials_needed
3418 3 49 if ($for_stack[0][4]) { }
3461 10 1 if defined $value
3472 2 0 if defined $value
3523 29 0 if $file =~ m[^string:///]
3529 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) { }
3536 0 5 $$line[3] ? :
3552 1 1 unless $$line[5]