nadim khemir wrote:
> As for the layers of neurosis, the only anxiety is the one created by your 
> own 
> delusions. I see only a test like an other.

If we had infinite time and attention, yes.  But we don't.  And time spent
checking the return value of print and writing a complicated test for if it
fails is time that could be better spent elsewhere.  I discussed this issue of
Opportunity Cost in testing last month.
http://www.nntp.perl.org/group/perl.qa/2007/12/msg9918.html

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.

Good tests catch bugs.

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

Given that the potential for these tests to catch a real bug is very low and
the work you're putting into it is very high that means the cost/benefit ratio
sucks.  Your time would be better spent doing something else.

Furthermore, the infrastructure to deal with it is likely to complicate your
code. [1]  Ironically, this will lead to more bugs thus defeating the whole
point of the exercise in the first place.

[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} @_;
        }


-- 
Eric: "Would you want to maintain a 5000 line Perl program?"
dha:  "Why would you write a 5000 line program?"

Reply via email to