pjcj / Devel--Cover

Code coverage metrics for Perl
http://www.pjcj.net/perl.html
93 stars 89 forks source link

overridden function in module is not covered (affects method modifiers and friends) #308

Open wchristian opened 2 years ago

wchristian commented 2 years ago

In the following example, sub _do is not recognized at all.

$ cat Moop.pm
package Moop;
sub _stop { 10 }
sub _do { 5 }
my $old = \&_do;
*_do = sub {  $old->() . _stop };
1;

$ cover -delete && perl -I. -MDevel::Cover -MMoop -E 'say Moop->_do' && cover
[...]
510
[...]
------- ------ ------ ------ ------ ------ ------ ------
File      stmt   bran   cond    sub    pod   time  total
------- ------ ------ ------ ------ ------ ------ ------
Moop.pm  100.0    n/a    n/a  100.0    n/a  100.0  100.0
Total    100.0    n/a    n/a  100.0    n/a  100.0  100.0
------- ------ ------ ------ ------ ------ ------ ------

image

wchristian commented 2 years ago

Oh yeah, just in case it's not clear. If you convert Moop to a script and run it directly instead of use()ing it, _do is recognized.