Branch Coverage

lib/Template/Sluz.pm
Criterion Covered Total %
branch 229 284 80.6


line true false branch
36 2 0 if (ref $v eq "ARRAY")
40 0 0 if (ref $v eq "HASH")
44 0 0 if (defined $v)
84 2 30 if (@_ == 1 and ref $_[0] eq 'HASH') { }
29 1 elsif (@_ % 2 == 0) { }
102 1 2 unless ($self->{'perl_file'})
107 0 3 unless ($tpl_file)
112 1 2 if (defined $parent) { }
117 2 1 if ($parent_tpl)
153 2 0 if (@_)
166 0 167 unless (defined $needle and defined $haystack)
169 135 32 if (exists $haystack->{$needle})
178 0 55 unless (defined $arr)
179 10 45 if (ref $arr eq 'ARRAY') { }
45 0 elsif (ref $arr eq 'HASH') { }
180 0 10 unless ($elem =~ /^\d+$/u and $elem < @$arr)
183 11 34 unless (exists $arr->{$elem})
197 5 60 if (length $str and substr($str, 0, 1) eq $char)
212 0 14 if ($pos < 0)
216 9 5 if ($open_count == 1)
225 0 13 if ($pos < 0)
230 5 8 if ($open_count == $close_count)
242 160 0 if defined $_
249 34 119 if ($str eq "{else}")
250 25 94 if ($str eq "{/if}")
251 54 40 if ($str =~ /^\{(?:if|elseif)\s+(.+?)\}$/u)
290 13 0 if ($self->{'perl_file_dir'})
294 0 13 if ($tpl_file eq "INLINE_TEMPLATE")
296 0 0 if (defined $c)
300 0 13 if ($tf and not -r $tf)
304 13 0 if ($tf)
306 0 13 unless open my $fh, "<", $tf
319 0 0 unless open my $fh, "<", $file
323 0 0 if ($idx < 0)
340 44 213 if ($z < 0)
347 247 221 unless ($is_open or $is_closed)
349 133 114 if ($next_open < 0)
351 16 231 if ($next_close < 0)
352 11 236 if ($next_open < $next_close) { }
363 230 221 if ($is_open)
365 35 195 if ($i > 0) { }
371 230 0 if ($i + 1 < $slen) { }
377 2 228 if ($chk =~ /\s[\{\}]\s/u)
378 14 216 if ($next_c eq "*")
381 33 418 if ($is_open and $has_len) { }
221 197 elsif ($is_closed) { }
388 81 140 if ($block =~ /^\{(if|foreach|literal)\b/u)
392 182 1385 if (substr($str, $j, 1) eq "}")
396 79 103 if ($oc == $cc)
404 221 0 if (length $block)
409 14 437 if ($is_comment)
411 0 14 unless (defined $end)
420 69 188 if ($start < $slen)
434 4 319 if ($prev_is_if)
436 2 2 if ($blocks[$i - 1][0] =~ m[^\{foreach .+?\}(.*)\{/foreach\}$]su)
437 1 1 substr($1, -1) eq "\n" ? :
439 3 1 if ($should_strip)
456 0 374 unless (length $block)
457 265 109 if (substr($block, 0, 1) eq '{') { }
476 147 118 if (substr($str, 0, 2) eq "{\$" and $str =~ m[^\{\$([\w|.'";\t :,!\@#%^&*?_/\\\-]+)\}$]u)
481 51 67 if (substr($str, 0, 4) eq "{if " and substr($str, -5) eq "{/if}")
486 30 37 if (substr($str, 0, 9) eq "{foreach " and $str =~ m[^\{foreach (\$\w[\w.]*) as \$(\w+)(?: => \$(\w+))?\}(.+)\{/foreach\}$]su)
491 9 28 if (substr($str, 0, 9) eq "{include ")
496 5 23 if (substr($str, 0, 9) eq "{literal}" and $str =~ m[^\{literal\}(.+)\{/literal\}$]su)
501 19 4 if ($str =~ /^\{(.+)}$/su)
506 3 1 if (substr($str, -1) ne "}")
523 28 119 if ($str =~ /(.+?)\|(.*)/u)
531 4 24 if ($is_nothing and $is_default) { }
3 21 elsif (not $is_nothing and $is_default) { }
535 4 0 if (defined $ret)
540 4 17 if ($is_nothing)
554 15 3 if (length $param_str)
571 0 18 unless ($callable)
576 11 7 if (defined &{"main::$func";}) { }
5 2 elsif (defined &{$func;}) { }
585 0 18 if ($@)
595 2 117 if (ref $ret eq "ARRAY")
596 0 117 if (ref $ret eq "HASH")
597 111 6 if (defined $ret)
608 32 19 if ($is_simple) { }
624 45 20 if ($res)
647 2 28 if (not defined $src) { }
1 52 elsif (ref $src ne 'ARRAY' and ref $src ne 'HASH') { }
661 28 2 if (ref $src eq 'ARRAY') { }
2 0 elsif (ref $src eq 'HASH') { }
664 3 64 if ($need_first)
665 1 2 $idx == 0 ? :
667 3 64 if ($need_last)
668 1 2 $idx == $last ? :
670 3 64 if ($need_index)
673 16 51 if (defined $oval) { }
687 0 6 if ($need_first)
688 0 0 $idx == 0 ? :
690 0 6 if ($need_last)
691 0 0 $idx == $last ? :
693 0 6 if ($need_index)
696 3 3 if (defined $oval) { }
718 9 0 if ($self->{'perl_file_dir'})
725 8 1 if ($key eq "file")
728 1 0 if (defined $res) { }
735 0 9 unless (-f $inc_tpl and -r $inc_tpl)
742 0 9 unless open my $fh, "<", $inc_tpl
760 5 14 unless ($str =~ /["\d\$\(]/u)
769 12 2 if (defined $ret and !ref($ret) || ref $ret eq '') { }
775 2 12 if ($err or not $valid)
790 24 95 if (index($str, "\$") == -1)
809 3 5 if ($p =~ /^\d+$/u) { }
821 15 124 if ($str =~ /^-?\d+(?:\.\d+)?$/u)
823 1 123 unless (length $str)
827 10 113 if ($first eq "'" and $last eq "'")
829 10 0 if (index($tmp, "'") == -1)
832 14 99 if ($first eq "\"" and $last eq "\"")
834 11 3 if (index($tmp, "\$") == -1 and index($tmp, "\"") == -1)
837 69 33 if ($str =~ /^\$__S->\{sluz_pfx_(\w+)\}$/u)
838 58 11 if (exists $self->{'tpl_vars'}{$1})
841 4 40 if ($str =~ /^!\$__S->\{sluz_pfx_(\w+)\}$/u)
842 3 1 if (exists $self->{'tpl_vars'}{$1})
845 3 0 if ($str =~ /^(\w+)$/u and exists $self->{'tpl_vars'}{$1})
849 0 0 if ($str =~ /^!(\w+)$/u and exists $self->{'tpl_vars'}{$1})
863 98 41 if (defined $opt)
872 30 11 unless (defined $sub)
875 1 29 if ($@)
883 40 1 if ($sub)
886 39 1 unless ($@)
894 1 1 if ($@)
899 1 1 if ($@)
922 0 10 if ($self->{'inc_tpl_file'})
925 0 10 if ($pos < 0 or not defined $str)
931 0 4 if (substr($str, $i, 1) eq "\n")
935 1 3 if ($pos == $i)
938 0 9 if ($pos == length $str)
946 8 1 if ($str =~ /\s(file=)(['"].+?['"])/u)
953 1 0 if ($str =~ /\s(['"].+?['"])/u)
973 25 104 if ($item =~ /^\{if/u)
974 25 104 if ($item eq "{/if}")
977 90 39 if ($nested == 1)
979 6 84 if $item eq "{/if}"
988 63 66 if ($tmp[$i])
990 44 19 if ($i != $num - 1)
998 63 66 if ($tmp[$i]) { }
999 44 19 unless ($first)
1007 0 19 if (@conds != @payloads)