Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re^6: Cleaning up unused subroutines

by Somni (Friar)
on Oct 26, 2007 at 13:03 UTC ( #647376=note: print w/replies, xml ) Need Help??

in reply to Re^5: Cleaning up unused subroutines
in thread Cleaning up unused subroutines

And how do you test that your test suite is comprehensive?

With code coverage checks, such as Devel::Cover.

Replies are listed 'Best First'.
Re^7: Cleaning up unused subroutines
by BrowserUk (Patriarch) on Oct 26, 2007 at 15:07 UTC
      Coverage checks are intended to determine how much of your code is exercised by your test suite. The basic presumption is that your test suite should call everything. If something is missed it's an indication that your test suite either needs more tests, or you have functions you aren't using.

      This differs from checking for unused functions by a chunk of code. A chunk of code, be it a script or a module, is not necessarily supposed to call every function possible on any given execution.

        So, what you are saying is that the advice to "build a comprehensive test suite" and then use a manual, step-by-step "rename a sub at random and run the test suite to see what happens" advice will, after all the laborious and manually intensive effort involved, miss the very same example that your pointed out that my fast and mostly automated method would miss:

        C:\test>type #! perl -slw use strict; foo() if @ARGV; C:\test>perl -MDevel::Cover Devel::Cover 0.61: Collecting coverage data for branch, condition, pod +, statement, subroutine and time. Selecting packages matching: Ignoring packages matching: /Devel/Cover[./] Ignoring packages in: . c:/Perl/lib c:/Perl/site/lib Devel::Cover: Can't find file "blib\lib\" (blib\lib\Storabl (autosplit into blib\lib\auto\Storable\ ignored. Devel::Cover: Writing coverage database to C:/test/cover_db/runs/11934 +13458.532.60512 ---------------------------- ------ ------ ------ ------ ------ ------ + ------ File stmt bran cond sub pod time + total ---------------------------- ------ ------ ------ ------ ------ ------ + ------ 100.0 50.0 n/a 100.0 n/a 100.0 + 85.7 Total 100.0 50.0 n/a 100.0 n/a 100.0 + 85.7 ---------------------------- ------ ------ ------ ------ ------ ------ + ------

        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://647376]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2023-12-06 18:14 GMT
Find Nodes?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?

    Results (31 votes). Check out past polls.