On 6 Jan 2008, at 11:10, Michael G Schwern wrote:
[snip]
But it gets down even further. All tests are not equal. Good tests are not about making perlcritic happy or achieving 100% test coverage or satisfying
some conviction about testing first.
[snip]

Absolute 100% agreement from me. I've seen many projects produce mountains of friable, pointless test suites by taking a lump of code and then trying to get 100% test coverage out of the other end.

Good tests catch bugs.

I don't see this test catching a real bug.  Do you?

Actually, I've had some nasty bugs in the past with prints failing with dodgy NFS mounts. Caused some important data to go away. Not my code fortunately :-)

[1] If you REALLY want to check the return value of print and do something
useful with it, don't scatter "or die" all over the place.  Hide the
complexity behind another layer of abstraction.

        sub _print {
                print @_ or die "...";
        }

        sub _print_fh {
                my $fh = shift;
                print {$fh} @_;
        }

And this is pretty much exactly the solution I used. Once and only once and all that :-)

Adrian

Reply via email to