Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Devel-Cover CPAN distribution.

Report information
The Basics
Id: 78801
Status: open
Priority: 0/
Queue: Devel-Cover

People
Owner: Nobody in particular
Requestors: mhasch-cpanbugs [...] cozap.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in:
  • 0.92
  • 0.93
  • 1.17
  • 1.18
Fixed in:
  • 1.29
  • 1.33



Subject: condition coverage gets messed up by de Morgan rule
The perl parser apparently simplifies some conditions using de Morgan's rule. In such cases, Devel::Cover fails to count all combinations of subconditions correctly. In my example, there is a statement: return 1 if !$a and !$b; The condition here is shown in condition coverage reports as ``$a or $b'', which suggests that de Morgan's rule has been applied. The case $a false and $b true, however, will wrongly be counted as $a false and $b false in this context, leading to wrong accusations of insufficient coverage. The problem goes away when the statement is written as: return 1 unless $a or $b; I checked this with Devel-Cover-0.92 and 0.93. -Martin
Subject: Foo.pm
package Foo; sub Foobar { my ($a, $b) = @_; return 1 if !$a && !$b; return 2; } 1;
Subject: Foo.t
use strict; use warnings; use Foo; use Test::More tests => 4; is(Foo::Foobar(1, 1), 2); is(Foo::Foobar(1, 0), 2); is(Foo::Foobar(0, 1), 2); is(Foo::Foobar(0, 0), 1);
While condition coverage seems to be correct for this case with recent versions of Devel::Cover, there still is a related problem with branch coverage. With perl v5.30.1 and Devel-Cover-1.33, Bar.pm and Bar.t as attached, cover reports only 50% branch coverage. This is obviously wrong as both return statements are reached by the test suite. Replacing ``if (!$a && !$b)'' by the equivalent code snippet ``unless ($a || $b)'' leads to correct coverage reports: 100% branch coverage and 67% condition coverage. -Martin
Subject: Bar.pm
package Bar; sub Foobar { my ($a, $b) = @_; if (!$a && !$b) { return 1; } return 2; } 1;
Subject: Bar.t
use strict; use warnings; use Bar; use Test::More tests => 2; is(Bar::Foobar(1, 1), 2); is(Bar::Foobar(0, 0), 1);