Test::Trap

Test::Trap is a Perl module with trap exit codes, exceptions, output, etc.
Download

Test::Trap Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Eirik Berg Hanssen
  • Publisher web site:
  • http://search.cpan.org/~ebhanssen/Test-Trap-v0.0.23/lib/Test/Trap/Builder.pm

Test::Trap Tags


Test::Trap Description

Test::Trap is a Perl module with trap exit codes, exceptions, output, etc. Test::Trap is a Perl module with trap exit codes, exceptions, output, etc.SYNOPSIS use Test::More; use Test::Trap qw( trap $trap ); my @r = trap { some_code(@some_parameters) }; is ( $trap->exit, 1, 'Expecting &some_code to exit with 1' ); is ( $trap->stdout, '', 'Expecting no STDOUT' ); like ( $trap->stderr, qr/^Bad parameters; exitingb/, 'Expecting warnings.' );Primarily (but not exclusively) for use in test scripts: A block eval on steroids, configurable and extensible, but by default trapping (Perl) STDOUT, STDERR, warnings, exceptions, would-be exit codes, and return values from boxed blocks of test code.The values collected by the latest trap can then be queried or tested through a a special result object.EXPORTA function and a scalar may be exported by any name. The function (by default named trap) is an analogue to block eval(), and the scalar (by default named $trap) is the corresponding analogue to $@.Optionally, you may specify the default layers for the exported trap. Layers may be specified by name, with a colon sigil. Multiple layers may be given in a list, or just stringed together like :flow:stderr:warn.(For the advanced user, you may also specify anonymous layer implementations -- i.e. an appropriate subroutine.)See below for a list of the built-in layers, all of which are enabled by default. Note, finally, that the ordering of the layers matter: The :raw layer is always on the bottom (anything underneath it is ignored), and any other "flow control" layers used should be right down there with it.FUNCTIONtrap BLOCKThis function may be exported by any name, but defaults to trap.Traps exceptions like block eval, but (by default) also traps exits and exit codes, returns and return values, context, and (Perl) STDOUT, STDERR, and warnings, All information trapped can be queried by way of the status object, which is by default exported as $trap, but can be exported by any name. Requirements: · Perl


Test::Trap Related Software