I have the following logic:
sub test {
my ($x, $y) = @_;
die unless defined $x || defined $y;
# uncoverable condition false
return $x // $y;
}
test( 1, 2 );
test( 1, undef );
test( undef, 2 );
test( undef, undef );
The return
statement will never be covered for the condition where $x
and $y
are both undefined. So the coverage report points out that condition as uncovered:
% | coverage | condition
------------------------------
67 | A | B | dec | $x // $y
|-------------|
===> | 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | X | 1 |
Is there a way for me to mark that condition as uncoverable
? Adding uncoverable condition false
above the line fixes the coverage summary, but when I look at the details the condition coverage is still at 67%.
Does Devel::Cover handle the //
operator?
On another note, if I change the die
line to the equivalent:
die "died" if !defined $x && !defined $y;
that line also becomes 67% covered.
% | coverage | condition
------------------------------
67 | A | B | dec | defined $x or defined $y
|-------------|
| 0 | 0 | 0 |
===> | 0 | 1 | 1 |
| 1 | X | 1 |
Could that be a bug?