Perl: the Markov chain saw | |
PerlMonks |
mystery: Devel::Cover showing missing statement coverage on a line that is being runby pryrt (Abbot) |
on May 12, 2023 at 17:45 UTC ( [id://11152141]=perlquestion: print w/replies, xml ) | Need Help?? |
pryrt has asked for the wisdom of the Perl Monks concerning the following question:
Given the SSCCE below, Devel::Cover v1.40 shows missing "statement" coverage for a line of code that is being run:
and running with
why does it say only 90.9% coverage?
The coverage report shows the following table:
... but I cannot see why line 6 has two rows in the table, or why it says that the second row for that line was never run; there's only one statement, as far as I can tell. Removing the = 1 or changing the order of the declarations doesn't change the fact that the first row in that block claims to never run. If I change to do { ... }; instead of just a block, then line 6 cleans up and only shows one row in the table, but now the line 4 do { shows it was run 0 times:
If I convert the block to a sub init { ... } and then call it with init(), then the sub init { line shows as uncovered statement, just like the do { version. I can work around it by getting rid of the block, so eliminating the coverage-flag isn't a problem (but I want the block in my real code to encapsulate the my variables to be private just for my get function, so I'm not going to do that). Or I can cheat with # uncoverable statement count:2. But my curiosity has been piqued as to why I should need a workaround at all.
Back to
Seekers of Perl Wisdom
|
|