timbunce / devel-nytprof

Devel::NYTProf is a powerful feature-rich source code profiler for Perl. (Mostly in maintenance mode, so PRs are much more likely to be acted upon than Issues.)
http://blog.timbunce.org/tag/nytprof/
67 stars 51 forks source link

Devel::NYTProf::FileInfo->is_eval not exercised in 'true' case #161

Open jkeenan opened 3 years ago

jkeenan commented 3 years ago

In a pending pull request I extend the coverage which the test suite provides to lib/Devel/NYTProf/FileInfo.pm. As of this pull request, when I run cover (first with trace unset and then with NYTPROF_TEST="trace=5", I get this coverage:

File                                   stmt   bran   cond    sub  total
blib/lib/Devel/NYTProf/FileInfo.pm     94.4   71.8   65.0  100.0   87.6

While all subroutines are exercised, the statement, branch and condition results are much less satisfactory than I would hope. Analysis shows that there is nothing in the existing test suite which exercises the case where Devel::NYTProf::FileInfo->is_eval() returns a true value.

blib/lib/Devel/NYTProf/FileInfo.pm

line  err   stmt   bran   cond    sub   code
1                                       package Devel::NYTProf::FileInfo;    # fid_fileinfo
51    ***     48     50            48   sub is_eval   { shift->[NYTP_FIDi_EVAL_FI()] ? 1 : 0 }

Branches
--------

line  err      %   true  false   branch
----- --- ------ ------ ------   ------
51    ***     50      0     48   +(shift())->[8] ? :

The consequence of this is that there are statements in the following subroutines which are not exercised:

is_file
sibling_evals

So far I have not been able to construct any case for t/13-fileinfo.t where the FileInfo object is a "string eval" -- notwithstanding the fact that there are instances in the test suite where string evals are indeed exercised, e.g.:

t/test22-strevala.t
59:eval($code)->();
60:eval($code)->(); eval($code)->();
61:eval q{
62:    eval($code)->(); eval($code)->();

Does anyone know how to construct a test case in which FileInfo->is_eval returns true?

Thank you very much. Jim Keenan