Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^3: Testing failures: How to override print to make it fail?

by dragonchild (Archbishop)
on May 05, 2005 at 13:35 UTC ( #454358=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Testing failures: How to override print to make it fail?
in thread Testing failures: How to override print to make it fail?

print() is generally considered one of those functions that "Just Works". adding "or die" to print is kinda ... dumb.

Of course, if you absolutely had to test print's success or failure, you could

use Fatal qw( print );

As for Devel::Cover ... I shoot for 90%+ coverage. There are several good conversations on D::C and why attempting to achieve 100% is ... well ... dumb. :-)


  • In general, if you think something isn't in Perl, try it out, because it usually is. :-)
  • "What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?"


Comment on Re^3: Testing failures: How to override print to make it fail?
Download Code
Re^4: Testing failures: How to override print to make it fail?
by adrianh (Chancellor) on May 05, 2005 at 13:40 UTC
    adding "or die" to print is kinda ... dumb.

    That entirely depends on the application being developed. I've come across several apps where not checking for the result of print has caused some nasty and expensive intermittent bugs.

    (Which is why I wish that print, open, read, etc. threw exceptions by default if called in a void context... Fixed in Perl 6 I think?)

    Update: and

    use Fatal qw( print );

    won't work since print is one of those subroutines that Perl can't override cleanly.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (11)
As of 2014-09-30 11:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (364 votes), past polls