CC: | rrfreimuth2 [...] yahoo.com |
Subject: | Devel::Cover does not detect branch coverage with DBM::Deep |
Devel::Cover does not detect branch coverage when DBM::Deep is used.
See the attached files, which contain short tests that demonstrate the
bug. The two subroutines perform an if( exists )/else on a hashref. In
one case the href is from DBM::Deep, in the other it is a regular
unblessed hash.
Running 'perl test_mod.t' verifies that both branches of both routines
are exercised by the tests. Running 'prove' reports all 4 tests pass.
Running 'cover' and examining the html report show that the 'if'
branches of the routine that uses DBM::Deep have 0% coverage (a logical
impossibility, as one branch will always be exercised) while the 'if' in
the other routine has 100% coverage (both branches are exercised by the
test).
This behavior was observed with Devel::Cover 0.79 on Win XP. I regret I
do not understand the code well enough to submit a patch. I hope the
test cases are helpful. Thanks.
This is perl, v5.10.1 built for MSWin32-x86-multi-thread
(with 2 registered patches, see perl -V for more detail)
Copyright 1987-2009, Larry Wall
Binary build 1007 [291969] provided by ActiveState
http://www.ActiveState.com
Built Jan 26 2010 23:15:11
Subject: | test_mod.t |
use strict;
use warnings;
use Test::More;
use Test::test_mod qw( testdbm testh );
is( testdbm( 1 ), 'dbm: exists', 'key exists in dbm' );
is( testdbm( 2 ), 'dbm: does not exist', 'key does not exist in dbm' );
is( testh( 1 ), 'h: exists', 'key exists in h' );
is( testh( 2 ), 'h: does not exist', 'key does not exist in h' );
done_testing();
Subject: | test_mod.pm |
package Test::test_mod;
use strict;
use warnings;
use DBM::Deep;
our @ISA = ( "Exporter" );
our @EXPORT_OK = qw( testdbm testh );
my $db = DBM::Deep->new( 'temp.db' );
$db->{1} = 1;
my $h = { 1 => 1 };
sub testdbm
{
my ( $p ) = @_;
if( exists $db->{$p} )
{
return 'dbm: exists';
}
else
{
return 'dbm: does not exist';
}
}
sub testh
{
my ( $p ) = @_;
if( exists $h->{$p} )
{
return 'h: exists';
}
else
{
return 'h: does not exist';
}
}
1;