Branch Coverage

blib/lib/Template/Sluz.pm
Criterion Covered Total %
branch 322 434 74.1


line true false branch
36 3 0 if (ref $v eq "ARRAY")
40 0 0 if (ref $v eq "HASH")
44 0 0 if (defined $v)
96 9 235 if (@_ == 1 and ref $_[0] eq 'HASH') { }
234 1 elsif (@_ % 2 == 0) { }
120 1 2 unless ($self->{'perl_file'})
125 0 3 unless ($tpl_file)
130 1 2 if (defined $parent) { }
135 2 1 if ($parent_tpl)
171 2 0 if (@_)
183 0 1 unless (defined $open and defined $close)
187 0 1 if (length $open != 1 or length $close != 1)
191 0 1 if ($open eq $close)
216 0 128 unless (defined $needle and defined $haystack)
219 97 31 if (exists $haystack->{$needle})
228 0 55 unless (defined $arr)
229 10 45 if (ref $arr eq 'ARRAY') { }
45 0 elsif (ref $arr eq 'HASH') { }
230 0 10 unless ($elem =~ /^\d+$/u and $elem < @$arr)
233 9 36 unless (exists $arr->{$elem})
247 1 31 if (ref $str eq "ARRAY")
248 0 31 if (ref $str eq "HASH")
269 125 12 unless ($self->{'auto_escape'})
270 0 12 if (ref $val)
280 5 68 if (length $str and substr($str, 0, 1) eq $char)
295 0 15 if ($pos < 0)
299 10 5 if ($open_count == 1)
308 0 13 if ($pos < 0)
313 5 8 if ($open_count == $close_count)
327 172 0 if defined $_
334 36 129 if ($str eq $self->{'_tag_else'})
335 27 102 if ($str eq $self->{'_tag_if_close'})
336 58 44 if (index($str, $self->{'_tag_if'}) == 0 or index($str, $self->{'_tag_elseif'}) == 0)
432 13 0 if ($self->{'perl_file_dir'})
436 0 13 if ($tpl_file eq "INLINE_TEMPLATE")
438 0 0 if (defined $c)
442 0 13 if ($tf and not -r $tf)
446 13 0 if ($tf)
448 0 13 unless open my $fh, "<", $tf
461 0 0 unless open my $fh, "<", $file
465 0 0 if ($idx < 0)
479 15 302 if (exists $self->{'_blocks_cache'}{$str})
494 40 262 if ($z < 0)
501 284 266 unless ($is_open or $is_closed)
503 157 127 if ($next_open < 0)
505 12 272 if ($next_close < 0)
506 7 277 if ($next_open < $next_close) { }
517 276 266 if ($is_open)
519 28 248 if ($i > 0) { }
525 276 0 if ($i + 1 < $slen) { }
531 2 274 if ($chk =~ /$self->{'_space_guard_re'}/u)
532 15 261 if ($next_c eq "*")
535 26 516 if ($is_open and $has_len) { }
266 250 elsif ($is_closed) { }
543 54 212 if (index($block, $tag_if) == 0) { }
39 173 elsif (index($block, $tag_foreach) == 0) { }
7 166 elsif (index($block, $tag_literal) == 0) { }
547 100 166 if ($matched_block)
550 220 1734 if (substr($str, $j, 1) eq $cd)
554 99 121 if ($oc == $cc)
562 266 0 if (length $block)
567 15 527 if ($is_comment)
569 0 15 unless (defined $end)
578 62 240 if ($start < $slen)
593 4 350 if ($prev_is_if)
595 2 2 if ($blocks[$i - 1][0] =~ /^\Q$tag_foreach\E.+?\}(.*)\Q$tag_foreach_close\E$/su)
596 1 1 substr($1, -1) eq "\n" ? :
598 3 1 if ($should_strip)
619 0 275 if ($out)
622 0 0 unless length $block
624 0 0 if ($first ne $od)
630 0 0 if (substr($block, 0, 2) eq $var_tag and index($block, "|") == -1 and $block =~ /$var_re/u)
634 0 0 if (index($var, '.') == -1) { }
639 0 0 if (ref $val eq 'ARRAY') { }
0 0 elsif (ref $val eq 'HASH') { }
0 0 elsif (defined $val) { }
652 0 318 unless length $block
654 82 236 if ($first ne $od)
659 62 58 if (substr($block, 0, 2) eq $var_tag and index($block, "|") == -1 and $block =~ /$var_re/u)
663 54 8 if (index($var, '.') == -1) { }
668 4 58 if (ref $val eq 'ARRAY') { }
0 58 elsif (ref $val eq 'HASH') { }
51 7 elsif (defined $val) { }
674 46 128 if (substr($block, 0, $self->{'_tag_if_len'}) eq $self->{'_tag_if'} and substr($block, -$self->{'_tag_if_close_len'}) eq $self->{'_tag_if_close'})
697 60 80 if (substr($str, 0, 2) eq "$od\$" and $str =~ /$self->{'_re_var_full'}/u)
702 0 80 if (substr($str, 0, $self->{'_tag_if_len'}) eq $self->{'_tag_if'} and substr($str, -$self->{'_tag_if_close_len'}) eq $self->{'_tag_if_close'})
708 39 41 if (substr($str, 0, $self->{'_tag_foreach_len'}) eq $self->{'_tag_foreach'} and $str =~ /$self->{'_re_foreach'}/u)
713 9 32 if (substr($str, 0, $self->{'_tag_include_len'}) eq $self->{'_tag_include'})
718 7 25 if (substr($str, 0, $self->{'_tag_literal_len'}) eq $self->{'_tag_literal'} and $str =~ /$self->{'_re_literal'}/u)
723 21 4 if ($str =~ /$self->{'_re_expr'}/u)
728 3 1 if (substr($str, -1) ne $cd)
747 0 60 if (index($str, "|") == -1)
750 0 0 if (index($str, '.') == -1) { }
755 0 0 if (ref $ret eq "ARRAY")
756 0 0 if (ref $ret eq "HASH")
757 0 0 if (defined $ret)
761 60 0 if ($str =~ /(.+?)\|(.*)/u)
769 6 54 if ($is_nothing and $is_default) { }
3 51 elsif (not $is_nothing and $is_default) { }
773 6 0 if (defined $ret)
778 6 45 if ($is_nothing)
792 19 30 if ($func eq "escape")
793 7 42 if ($func eq "noescape")
797 15 34 if (length $param_str)
814 0 49 unless ($callable)
819 11 38 if (defined &{"main::$func";}) { }
31 7 elsif (defined &{$func;}) { }
828 0 49 if ($@)
833 1 8 if ($self->{'auto_escape'} and not $seen_noescape and not $seen_escape)
841 0 0 if (ref $ret eq "ARRAY")
842 0 0 if (ref $ret eq "HASH")
843 0 0 if (defined $ret)
852 12 52 if (exists $self->{'_if_rules_cache'}{$str}) { }
861 31 21 if ($is_simple) { }
880 15 63 (index($raw, '$') == -1) ? :
883 53 25 if ($res)
886 13 40 $cached ? :
911 6 56 if defined $b->[2]
913 0 56 if (not length $bs) { }
16 40 elsif (substr($bs, 0, 1) ne $od) { }
30 10 elsif (substr($bs, 0, 2) eq "$od\$" and index($bs, '|') == -1 and $bs =~ /$self->{'_re_var_simple'}/u) { }
6 4 elsif (substr($bs, 0, $self->{'_tag_if_len'}) eq $self->{'_tag_if'} and substr($bs, -$self->{'_tag_if_close_len'}) eq $self->{'_tag_if_close'}) { }
931 2 37 if (not defined $src) { }
1 68 elsif (ref $src ne 'ARRAY' and ref $src ne 'HASH') { }
941 9 30 defined $oval ? :
957 9 30 if (defined $oval)
961 2 37 if $need_first
962 2 37 if $need_first
963 1 38 if $need_last
964 1 38 if $need_last
965 1 38 if $need_index
966 1 38 if $need_index
973 35 4 if (ref $src eq 'ARRAY') { }
4 0 elsif (ref $src eq 'HASH') { }
976 6 82 if ($need_first)
977 2 4 $idx == 0 ? :
978 2 4 $idx == 0 ? :
980 3 85 if ($need_last)
981 1 2 $idx == $last ? :
982 1 2 $idx == $last ? :
984 3 85 if ($need_index)
988 16 72 if (defined $oval) { }
1000 34 98 if ($type == 0) { }
68 30 elsif ($type == 1) { }
18 12 elsif ($type == 2) { }
0 12 elsif ($type == -1) { }
1005 56 12 if (index($var, '.') == -1) { }
1010 0 68 if (ref $val eq 'ARRAY') { }
0 68 elsif (ref $val eq 'HASH') { }
68 0 elsif (defined $val) { }
1029 0 11 if ($need_first)
1030 0 0 $idx == 0 ? :
1031 0 0 $idx == 0 ? :
1033 0 11 if ($need_last)
1034 0 0 $idx == $last ? :
1035 0 0 $idx == $last ? :
1037 0 11 if ($need_index)
1041 6 5 if (defined $oval) { }
1053 15 17 if ($type == 0) { }
17 0 elsif ($type == 1) { }
0 0 elsif ($type == 2) { }
0 0 elsif ($type == -1) { }
1058 17 0 if (index($var, '.') == -1) { }
1063 0 17 if (ref $val eq 'ARRAY') { }
0 17 elsif (ref $val eq 'HASH') { }
17 0 elsif (defined $val) { }
1081 23 29 if ($tpl_exists[$i]) { }
1086 23 29 if ($ks_exists[$i]) { }
1103 9 0 if ($self->{'perl_file_dir'})
1110 8 1 if ($key eq "file")
1113 1 0 if (defined $res) { }
1120 0 9 unless (-f $inc_tpl and -r $inc_tpl)
1127 0 9 unless open my $fh, "<", $inc_tpl
1145 5 16 unless ($str =~ /["\d\$\(]/u)
1154 14 2 if (defined $ret and !ref($ret) || ref $ret eq '') { }
1160 2 14 if ($err or not $valid)
1175 13 84 if (index($str, "\$") == -1)
1179 21 63 if (exists $self->{'_convert_cache'}{$str})
1189 3 60 if (index($str, "[") != -1)
1205 1 5 if ($p =~ /^\d+$/u) { }
1217 18 147 if ($str =~ /^-?\d+(?:\.\d+)?$/u)
1219 1 146 unless (length $str)
1223 10 136 if ($first eq "'" and $last eq "'")
1225 10 0 if (index($tmp, "'") == -1)
1228 16 120 if ($first eq "\"" and $last eq "\"")
1230 13 3 if (index($tmp, "\$") == -1 and index($tmp, "\"") == -1)
1233 83 40 if ($str =~ /^\$__S->\{sluz_pfx_(\w+)\}$/u)
1234 72 11 if (exists $self->{'tpl_vars'}{$1})
1237 4 47 if ($str =~ /^!\$__S->\{sluz_pfx_(\w+)\}$/u)
1238 3 1 if (exists $self->{'tpl_vars'}{$1})
1241 3 0 if ($str =~ /^(\w+)$/u and exists $self->{'tpl_vars'}{$1})
1245 0 0 if ($str =~ /^!(\w+)$/u and exists $self->{'tpl_vars'}{$1})
1256 0 165 if (index($str, "===") != -1)
1261 117 48 if (defined $opt)
1271 11 37 if ($vsub)
1277 37 0 unless (defined $sub)
1280 1 36 if ($@)
1288 36 1 if ($sub)
1291 33 3 unless ($@)
1304 1 3 if ($@)
1309 1 3 if ($@)
1332 0 10 if ($self->{'inc_tpl_file'})
1335 0 10 if ($pos < 0 or not defined $str)
1341 0 4 if (substr($str, $i, 1) eq "\n")
1345 1 3 if ($pos == $i)
1348 0 9 if ($pos == length $str)
1356 8 1 if ($str =~ /\s(file=)(['"].+?['"])/u)
1363 1 0 if ($str =~ /\s(['"].+?['"])/u)
1387 27 112 if (index($item, $tif_prefix) == 0)
1388 27 112 if ($item eq $tifc_tag)
1391 98 41 if ($nested == 1)
1393 6 92 if $item eq $tifc_tag
1402 67 72 if ($tmp[$i])
1404 46 21 if ($i != $num - 1)
1412 67 72 if ($tmp[$i]) { }
1413 46 21 unless ($first)
1421 0 21 if (@conds != @payloads)