Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Honored monks,
This very question has been discussed 2 years ago in this node: How to test a module that exits? A interesting and related discussion on the perl.qa was titled Should TAP capture exit codes? If the module were to die instead of exit, I would use Test::Exception to catch a die like this:
$ cat test_exit.pl use strict; use warnings; sub killer { die "hasta la vista baby"; } sub exiter { exit(42); } 1; __END__
$ cat test_exit.t use warnings; use strict; use Test::More tests => 2; use Test::Exception; ok(require('test_exit.pl'), 'loaded'); throws_ok( sub { killer () }, qr/hasta la vista baby/, q{Expected kill +er to die}); __END__
$ prove test_exit.t test_exit....ok All tests successful. Files=1, Tests=2, 0 wallclock secs ( 0.04 cusr + 0.01 csys = 0.05 C +PU)
Now I wonder what kind of tricks I can use to test exit in the same way as die?
Update: Test::Trap is a brilliant solution. Thanks Sidhekin.
--
print map{chr}unpack(q{A3}x24,q{074117115116032097110111116104101114032080101114108032104097099107101114})

In reply to How to test exit? by andreas1234567

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2024-04-19 10:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found