Branch Coverage

blib/lib/Nice/Try.pm
Criterion Covered Total %
branch 306 558 54.8


line true false branch
45 32 0 unless exists $hash->{'debug'}
46 32 0 unless exists $hash->{'no_filter'}
47 32 0 unless exists $hash->{'debug_code'}
48 32 0 unless exists $hash->{'debug_dump'}
49 32 0 unless exists $hash->{'dont_want'}
55 0 32 if ($class->can("TIESCALAR") or $class->can("TIEHASH") or $class->can("TIEARRAY"))
60 0 32 overload::Overloaded($class) ? :
84 3 3 defined $n ? :
100 0 49 if ($self->{'no_filter'})
104 0 0 if $self->{'debug'} >= 3
110 0 3033 if ($status < 0)
112 0 0 if $self->{'debug'} >= 3
119 17 32 unless $line
120 32 0 unless ($status < 0)
125 28 4 if (index($code, 'try') != -1) { }
127 0 28 if $self->{'debug'} >= 4
128 0 28 if $self->{'debug'} >= 5
132 0 28 if $self->{'debug_dump'}
135 13 15 index($code, '__DATA__') != -1 || index($code, '__END__') != -1 ? :
28 0 if ($doc = $self->_parse($doc, {'has_data', index($code, '__DATA__') != -1 || index($code, '__END__') != -1 ? 1 : 0})) { }
154 0 4 if $self->{'debug'} >= 4
158 0 32 if (length $last_line)
163 0 32 unless ($status <= 0)
167 0 0 if $self->{'debug'} >= 4
168 0 0 if $status < 0
173 0 32 if ($self->{'debug_file'})
175 0 0 if (open my $fh, ">$self->{'debug_file'}")
189 0 2 unless defined $code and length $code
190 2 0 unless (ref $self)
192 0 0 !(@_ % 2) ? :
0 0 ref $_[0] eq 'HASH' ? :
2 0 !(@_ && defined $_[0]) ? :
208 0 2 if $self->{'debug'} >= 4
210 0 2 if $self->{'debug_dump'}
211 2 0 if ($doc = $self->_parse($doc))
223 0 0 if ($self->{'debug'} >= 4)
225 0 0 if $self->{'debug'} >= 4
226 0 0 if $self->{'debug'} >= 4
228 0 0 unless $elem->children
232 0 0 if ($e->can("children") and $e->children)
242 0 0 if (@_)
244 0 0 ref $_ eq 'CODE' ? :
247 0 0 if warnings::enabled()
256 78 0 $_[0] =~ /^\d+$/ ? :
257 78 0 if $self->{'debug'} < $level
263 0 0 ref $_ eq 'CODE' ? :
272 0 0 $_[0] =~ /^\d+$/ ? :
273 0 0 if $self->{'debug'} < $level
282 0 0 if ref $_
285 0 0 ref $_ eq 'CODE' ? :
297 0 300 unless (builtin::blessed($elem) and $elem->isa("PPI::Node"))
310 132 28861 $this->class eq 'PPI::Statement' && substr($this->content, 0, 3) eq 'try' ? :
312 0 304 unless defined $ref
313 0 34 if $ref and ref $ref and $self->{'debug'} >= 4
314 270 34 unless $ref and scalar @$ref
323 0 34 if $self->{'debug'} >= 3
326 0 132 if $self->{'debug'} >= 3
327 0 132 if $self->{'debug'} >= 3
332 0 132 unless scalar @block_children
342 2 1713 if ($sib->class eq "PPI::Token::Word" and $sib->content eq "try")
346 2 0 if ($next and $next->class eq "PPI::Structure::Block")
349 0 2 if $self->{'debug'} >= 3
351 0 2 if $self->{'debug'} >= 3
359 0 132 if $self->{'debug'} >= 3
361 0 132 if $self->{'debug'} >= 3
363 2 130 if (scalar @$tmp_ref > 1) { }
369 0 4 if $self->{'debug'} >= 3
372 0 4 if $self->{'debug'} >= 4
378 8 49 if ($o->class eq 'PPI::Structure::Block' and $last_control) { }
11 38 elsif ($o->class eq 'PPI::Token::Word') { }
387 4 3 if ($ct eq "try" or $ct eq "catch" or $ct eq "finally")
404 4 21 if $o->class eq "PPI::Structure::Block" and builtin::refaddr($o) eq builtin::refaddr($last->{'block'})
407 0 4 if $self->{'debug'} >= 3
410 0 4 if $self->{'debug'} >= 3
418 4 0 if (builtin::blessed($new_block->{'children'}[$i]) and $new_block->{'children'}[$i]->isa("PPI::Statement"))
432 0 0 defined $last_obj ? :
0 0 defined $last_obj ? :
0 4 if $self->{'debug'} >= 3
435 2 2 if ($last_obj->class eq 'PPI::Token::Whitespace') { }
0 2 elsif ($last_obj->class eq 'PPI::Token::Comment') { }
449 0 4 if (not defined $rc) { }
0 4 elsif (not $rc) { }
456 0 0 if ($last_obj->isa('PPI::Structure') or $last_obj->isa('PPI::Token')) { }
0 0 elsif ($last_obj->isa('PPI::Statement')) { }
470 4 0 if (scalar @$insignificants)
472 0 4 if $self->{'debug'} >= 4
475 0 21 if $self->{'debug'} >= 4
485 0 21 if ($@) { }
0 21 elsif (not defined $rc) { }
0 21 elsif (not $rc) { }
487 0 0 if (ref $o) { }
489 0 0 if $self->{'debug'}
493 0 0 if $self->{'debug'}
498 0 0 if $self->{'debug'}
502 0 0 if $self->{'debug'}
505 0 21 unless $o->parent
510 0 4 if length $err
522 0 34 if $self->{'debug'} >= 3
524 1 33 if ($has_additional_blocks) { }
526 0 1 if $self->{'debug'} >= 3
532 0 0 if (ref $rv and scalar @$rv)
545 266 34 unless $ref and scalar @$ref
547 0 34 if $self->{'debug'} >= 3
551 0 134 if $self->{'debug'} >= 5
566 5 129 unless scalar @block_children
578 335 1297 if (not scalar @$try_block_ref) { }
143 1154 elsif ($sib->class eq 'PPI::Token::Word' and $sib->content eq 'catch') { }
501 653 elsif ($inside_catch) { }
13 640 elsif ($sib->class eq 'PPI::Token::Word' and $sib->content eq 'finally') { }
27 613 elsif ($inside_finally) { }
211 402 elsif ($sib->class eq 'PPI::Token::Whitespace' and $sib->content =~ /[\015\012]+/) { }
580 127 208 if ($sib->class eq 'PPI::Structure::Block' and substr("$sib", 0, 1) eq '{' and substr("$sib", -1, 1) eq '}') { }
79 129 elsif ($sib->class eq 'PPI::Token::Whitespace' and $sib->content =~ /[\015\012]+/) { }
587 127 0 if (scalar @$buff)
610 139 4 if (scalar @$buff)
620 109 392 if ($sib->class eq 'PPI::Structure::List') { }
143 249 elsif ($sib->class eq 'PPI::Structure::Block') { }
98 151 elsif ($sib->class eq 'PPI::Token::Whitespace' and $sib->content =~ /[\015\012]+/) { }
628 24 119 if (scalar @$catch_def) { }
655 13 0 if (scalar @$buff)
665 0 27 if ($sib->class eq 'PPI::Structure::List') { }
13 14 elsif ($sib->class eq 'PPI::Structure::Block') { }
1 13 elsif ($sib->class eq 'PPI::Token::Whitespace' and $sib->content =~ /[\015\012]+/) { }
672 0 13 if (scalar @$fin_block_ref) { }
7 6 elsif (scalar @$catch_def) { }
719 119 10 scalar @$catch_def > 0 ? :
724 13 116 if (scalar @$fin_block_ref)
735 13 0 unless $self->{'debug_code'}
737 1 12 if ($fin_def->{'open_curly_nl'}) { }
745 0 13 if ($fin_def->{'close_curly_nl'}) { }
757 127 2 if (scalar @$try_block_ref) { }
762 3 124 if (my $emb = $self->_parse($try_def->{'block'}))
791 127 0 unless ($self->{'is_tied'} or $self->{'dont_want'} or $self->{'is_overloaded'})
899 127 0 if ($] >= "5.036")
974 127 0 unless $self->{'debug_code'}
976 79 48 if ($try_def->{'open_curly_nl'}) { }
984 115 12 if ($try_def->{'close_curly_nl'}) { }
994 8 119 if (not $has_catch_clause) { }
1017 127 0 if ($] >= "5.036")
1023 127 0 unless $self->{'debug_code'}
1025 119 8 if (scalar @$catch_def) { }
1034 1 142 if (my $emb = $self->_parse($cdef->{'block'}))
1041 109 34 if ($cdef->{'var'}) { }
1045 0 109 if $self->{'debug'} >= 3
1050 15 94 if ($str =~ /^(\S+)[[:blank:]\h\v]+(\$\S+)$/) { }
4 90 elsif ($str =~ /^(\S+)[[:blank:]\h\v]+(\$\S+)[[:blank:]\h\v]+where[[:blank:]\h\v]+\{(.*?)\}$/) { }
1 89 elsif ($str =~ /^(\$\S+)[[:blank:]\h\v]+where[[:blank:]\h\v]+\{(.*?)\}$/) { }
9 80 elsif ($str =~ /^(\$\S+)[[:blank:]\h\v]+isa[[:blank:]\h\v]+(\S+)(?:[[:blank:]\h\v]+where[[:blank:]\h\v]+\{(.*?)\})?$/) { }
2 78 elsif ($str =~ /^(?\$\S+)[[:blank:]\h\v]+isa[[:blank:]\h\v]*\([[:blank:]\h\v]*(?["'])?(?[^[:blank:]\h\v\'\"\)]+)\k{quote}[[:blank:]\h\v]*\)(?:[[:blank:]\h\v]+where[[:blank:]\h\v]+\{(?.*?)\})?$/) { }
1080 143 0 if ($cdef->{'block'}) { }
1090 119 24 if ($i == 0) { }
11 13 elsif ($i == $total_catch - 1) { }
1099 2 9 $cdef->{'class'} ? :
0 11 $total_catch == 1 ? :
1186 109 34 if ($cdef->{'var'}) { }
1189 12 97 if ($cdef->{'class'} and $cdef->{'where'}) { }
18 79 elsif ($cdef->{'class'}) { }
1 78 elsif ($cdef->{'where'}) { }
1230 0 78 if (++$else > 1)
1233 0 0 if warnings::enabled()
1237 69 9 if $cond eq "if" or $cond eq "elsif"
1251 34 0 if $cond eq "if" or $cond eq "elsif"
1260 143 0 unless $self->{'debug_code'}
1262 98 45 if ($cdef->{'open_curly_nl'}) { }
1270 27 116 if ($cdef->{'close_curly_nl'}) { }
1283 78 41 if ($else) { }
1299 119 0 unless $self->{'debug_code'}
1321 8 0 unless $self->{'debug_code'}
1326 127 0 scalar @$catch_repl ? :
1327 127 0 if $catch_res
1332 7 120 if ($has_catch_clause and length $fin_block)
1344 127 0 unless $self->{'debug_code'}
1357 0 127 if (scalar keys %main::warnings:: and exists $warnings::Bits{'args_array_with_signatures'})
1437 127 0 unless $self->{'debug_code'}
1465 127 0 unless $self->{'debug_code'}
1472 0 127 unless ($rc = $element_before_try->insert_after($token))
1477 0 0 defined $rc ? :
0 127 if $self->{'debug'} >= 3
1482 0 1438 unless $e->delete
1488 13 21 if ($opts->{'has_data'})
1493 13 7707 $this->class eq 'PPI::Statement::Data' || $this->class eq 'PPI::Statement::End' ? :
1495 0 13 if not defined $ref and warnings::enabled()
1503 0 13 if $self->{'debug'} >= 5
1508 12 27 $this->class eq 'PPI::Token::Data' || $this->class eq 'PPI::Token::End' ? :
1510 1 12 if not $tokens or defined $tokens and ref $tokens and not scalar @$tokens
1514 12 0 if ($token_name_ref and ref $token_name_ref eq 'ARRAY' and scalar @$token_name_ref) { }
1520 0 0 if warnings::enabled()
1531 4 8 if ($raw_data_str =~ /\S+/)
1537 2 2 if ($token_name eq '__DATA__') { }
1545 2 5 if $token->class eq "PPI::Token::End"
1577 10 2 if ($this->class eq "PPI::Statement::End")
1585 0 12 if (not defined $rv) { }
0 12 elsif (not $rv) { }
1587 0 0 if warnings::enabled()
1592 0 0 if warnings::enabled()
1617 11 1558 unless $elem->children
1622 5 7739 if ($class eq "PPI::Token::Word" and $content =~ /^(?:CORE\::)?(?:GLOBAL\::)?caller$/)
1627 1286 6458 if ($e->can("elements") and $e->elements)
1640 6 450 unless $elem->children
1643 321 53 if (index($ct, "last") == -1 and index($ct, "next") == -1 and index($ct, "redo") == -1 and index($ct, "goto") == -1 and index($ct, "return") == -1)
1649 0 321 if $self->{'debug'} >= 4
1652 0 129 if $self->{'debug'} >= 5
1656 0 0 $e->can('elements') ? :
0 1270 if $self->{'debug'} >= 6
1659 0 1270 if ($class eq 'PPI::Structure::For' or $class eq 'PPI::Statement::Compound' and defined $e->first_element->content and $e->first_element->content =~ /^(for|foreach|while)$/) { }
0 1270 elsif ($class eq 'PPI::Token::Word' and $content =~ /^(?:CORE\::)?(?:GLOBAL\::)?(next|last|redo)$/) { }
86 1184 elsif ($class eq 'PPI::Statement::Break') { }
3 1181 elsif ($class eq 'PPI::Token::Word' and ($e->content // '') eq 'return' and $e->sprevious_sibling and $e->sprevious_sibling->class eq 'PPI::Token::Operator') { }
1668 0 0 if $self->{'debug'} >= 5
1675 0 0 if $self->{'debug'} >= 5
1678 0 0 if $self->{'debug'} >= 5
1683 0 86 if $self->{'debug'} >= 5
1684 86 0 scalar @$words ? :
1685 22 64 scalar @$words > 1 ? :
1686 0 86 if $self->{'debug'} >= 5
1687 0 86 if $self->{'debug'} >= 5 and scalar @$words > 1
1690 51 0 if (scalar @$words == 1 || scalar @$words > 1 && $word2 =~ /^(for|foreach|given|if|unless|until|while)$/ || $word1 eq 'return' and $word1 eq 'next' || $word1 eq 'last' || $word1 eq 'redo' || $word1 eq 'return')
1705 41 33 $word1 eq 'return' ? :
1708 10 64 if (scalar @$words > 1) { }
1717 0 74 if $self->{'debug'} >= 5
1722 0 74 if $self->{'debug'} >= 5
1724 0 74 if $self->{'debug'} >= 5
1744 2 1 if ($e->snext_sibling and $e->snext_sibling->class eq 'PPI::Structure::List') { }
1 0 elsif ($e->snext_sibling and $e->snext_sibling->isa('PPI::Token::Quote')) { }
0 0 elsif ($e->snext_sibling and $e->snext_sibling->class eq 'PPI::Token::Structure' and $e->snext_sibling->content eq ';') { }
1773 0 0 if $next_elem->content eq ";"
1783 0 3 if $self->{'debug'} >= 5
1789 186 998 if ($e->can("elements") and $e->elements)
1802 0 426 unless $] >= "5.016"
1803 424 2 if (index("$elem", "__SUB__") == -1)
1805 0 424 if $self->{'debug'} >= 5
1809 0 2 unless $elem->children
1810 0 2 if $self->{'debug'} >= 5
1818 0 2 unless defined $e
1820 0 2 unless $parent
1824 0 4 if $self->{'debug'} >= 5
1825 2 2 if ($parent->class eq "PPI::Structure::Block")
1831 2 4 if ($prev->content eq "sub")
1836 1 3 if ($prev->class eq "PPI::Token::Word")
1838 0 1 if (defined $sub_name)
1840 0 0 if warnings::enabled()
1852 2 0 if ($def) { }
1855 0 2 if $self->{'debug'} >= 5
1871 0 2 if $self->{'debug'} >= 5
1876 2 0 if (scalar @children) { }
1882 0 0 $rv ? :
0 0 defined $rv ? :
0 4 if $self->{'debug'} >= 5
1891 0 0 ref $rv eq 'PPI::Element' ? :
0 0 defined $rv ? :
0 0 if $self->{'debug'} >= 5
1894 0 2 if $self->{'debug'} >= 5
1898 0 0 if $self->{'debug'} >= 5
1907 0 67 if $self->{'debug'} >= 5
1908 4 63 if ($e->content eq '__SUB__') { }
8 55 elsif ($e->can('elements') and scalar $e->elements and index("$e", '__SUB__') != -1) { }
1910 0 4 if $self->{'debug'} >= 5
1926 0 2 if $self->{'debug'} >= 5
1947 7386 0 unless ($Token->isa("PPI::Token::HereDoc"))
1951 7386 0 unless ($heredoc ne "" and $content =~ /\n/)
1958 0 0 if ($content eq "\n") { }
1981 0 0 if ($Token->{'_damaged'})
1994 0 0 if ($tokens[$last_index]{'content'} =~ /^[^\n]*\n$/)
2002 0 0 if $tokens[$_]
2004 0 0 unless (defined $last_line)
2018 0 0 if $tokens[$_]->isa("PPI::Token::HereDoc")
2019 0 0 unless (defined $any_after)
2026 0 0 unless ($last_line and not $any_after)
2028 0 0 unless (defined $Token->{'_terminator_line'})
2034 0 0 unless ($Token->{'_terminator_line'} =~ /\n$/)
2041 0 0 if (defined $Token->{'_terminator_line'})
2048 0 392 if ($heredoc ne "")
2051 0 0 unless ($output =~ /\n$/)
2070 0 31 "$]" < 5.013002 ? :
2083 0 14 defined $catch_err ? :
2085 0 14 if defined $catch_err
2093 1 13 unless (eval { do { $@ = $err; &$code(@$args); 1 } })
2094 1 0 defined $@ ? :
2133 81 0 ref $_[0] ? :