Subject: | Reading constant code references invalidates statement coverage |
Reading a constant coderef seems to invalidate the statement coverage
figures. It looks like one statement is skipped from the top of the
module for each read ("$x = Wut::A") added to the test. If A is just a
plain scalar, the problem goes away, as well as the "Devel::Cover:
ignoring extra statement" warnings.
Test distribution attached. I can reproduce it with 5.8.8 and 5.10.0.
$ cat lib/Wut.pm
package Wut;
use constant A => sub { 0 };
1;
$ cat t/zlork.t
#!perl -T
use Wut;
my $x = Wut::A;
$x = Wut::A;
$x = Wut::A;
$x = Wut::A;
$ cover -test
Deleting database /home/vince/perl/bugs/coverconstants/cover_db
cover: running make test OPTIMIZE=-O0\ -fprofile-arcs\ -ftest-coverage
OTHERLDFLAGS=-fprofile-arcs\ -ftest-coverage
cp lib/Wut.pm blib/lib/Wut.pm
PERL_DL_NONLAZY=1 /usr/bin/perl5.8.8 "-MExtUtils::Command::MM" "-e"
"test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/zlork.... No subtests run
Test Summary Report
-------------------
t/zlork (Wstat: 0 Tests: 0 Failed: 0)
Parse errors: No plan found in TAP output
Files=1, Tests=0, 4 wallclock secs ( 0.05 usr 0.00 sys + 3.67 cusr
0.05 csys = 3.77 CPU)
Result: FAIL
Failed 1/1 test programs. 0/0 subtests failed.
make: *** [test_dynamic] Error 255
Reading database from /home/vince/perl/bugs/coverconstants/cover_db
Devel::Cover: ignoring extra statement
Devel::Cover: ignoring extra statement
---------------------------- ------ ------ ------ ------ ------ ------
------
File stmt bran cond sub pod time
total
---------------------------- ------ ------ ------ ------ ------ ------
------
blib/lib/Wut.pm 0.0 n/a n/a 100.0 n/a 100.0
20.0
Total 0.0 n/a n/a 100.0 n/a 100.0
20.0
---------------------------- ------ ------ ------ ------ ------ ------
------
Writing HTML output to
/home/vince/perl/bugs/coverconstants/cover_db/coverage.html ...
done.
Subject: | coverconstants.tar.bz2 |
Message body not shown because it is not plain text.