logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Test::Exit - Test that some code calls exit() without terminating testing

Author

       Andrew Rodland <arodland@cpan.org>

Description

       Test::Exit provides some simple tools for testing code that might call "exit()", providing you with the
       status code without exiting the test file.

       The only criterion tested is that the supplied code does or does not call "exit()". If the code throws an
       exception, the exception will be propagated and you will have to catch it yourself. "die()"ing is not
       exiting for the purpose of these tests.

       Unlike previous versions of this module, the current version doesn't use exceptions to do its work, so
       even if you call "exit()" inside of an "eval", everything should work.

Functions

exit_code
       Runs the given code. If the code calls "exit()", then "exit_code" will return a number, which is the
       status that "exit()" would have exited with.  If the code never calls "exit()", returns "undef". This is
       the Test::Fatal-like interface. All of the other functions are wrappers for this one, retained for legacy
       purposes.

   exits_ok
       Tests that the supplied code calls "exit()" at some point.

   exits_nonzero
       Tests that the supplied code calls "exit()" with a nonzero value.

   exits_zero
       Tests that the supplied code calls "exit()" with a zero (successful) value.

   never_exits_ok
       Tests that the supplied code completes without calling "exit()".

Name

       Test::Exit - Test that some code calls exit() without terminating testing

Synopsis

           use Test::More tests => 4;
           use Test::Exit;

           is exit_code { exit 75; }, 75, "procmail not found";
           exits_ok { exit 1; } "exiting exits";
           never_exits_ok { print "Hi!"; } "not exiting doesn't exit"l
           exits_zero { exit 0; } "exited with success";
           exits_nonzero { exit 42; } "exited with failure";

Version

       version 0.11

See Also