Recently, a question on testing came up, and it made me think a little bit.

I don't officially document my private methods/functions anywhere in POD or otherwise. Most of my private subs are very small, typically three to 20 lines of code, and are significantly more focus-built than the calls they serve, so I typically just put a comment at the top of the definition (comments in my code are extremely sparse otherwise):

sub _attach_build_log { # attach the cpanm logs to the PASS/FAIL logs sub _copy_logs { # copy the log files out of the temp dir sub _dzil_shim { # shim for working on Dist::Zilla modules sub _exec { # perform the actual *brew build commands (called by test())

For testing, it would be an unusual practice for me to have tests dedicated directly at a private sub, but periodically I find it is useful, and if I change internals, I just let test breakage tell me:

... my $run = $des->_run_end(); is $run, undef, "_run_end() is undef when called out of context"; $run = $des->_run_end(1); is $run, 1, "_run_end() sets itself to true properly"; $run = $des->_run_end(0); is $run, 0, "_run_end() sets itself to false properly";

Curious as to what others do to document core private subs (if at all), and if they take any special procedures to test some of their private subs directly, when testing them through the main API isn't feasible/possible.


In reply to (How) Do you document/test your private subroutines? by stevieb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.