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
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |