Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Perl Modules

    Test::Trap 0.2.2

    Download button

    No screenshots available
    Downloads: 384  Tell us about an update
    User Rating:
    Rated by:
    Good (3.6/5)
    15 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Eirik Berg Hanssen | More programs
    Perl Artistic License / FREE
    March 4th, 2012, 01:30 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    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.

    EXPORT

    A 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.

    FUNCTION

    trap BLOCK

    This 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.

    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    trap exit codes | trap exceptions | Perl module | Test::Trap | trap | exit

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM