GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  TEST2::TOOLS::EXCEPTION (3)

.ds Aq ’

NAME

Test2::Tools::Exception - Test2 based tools for checking exceptions

CONTENTS

DESCRIPTION

This is the Test2 implementation of code used to test exceptions. This is similar to Test::Fatal, but it intentionally does much less.

SYNOPSIS



    use Test2::Tools::Exception qw/dies lives/;

    like(
        dies { die xxx },
        qr/xxx/,
        "Got exception"
    );

    ok(lives { ... }, "did not die") or note($@);



EXPORTS

All subs are exported by default.
$e = dies { ... } This will trap any exception the codeblock throws. If no exception is thrown the sub will return undef. If an exception is thrown it will be returned. This function preserves $@, it will not be altered from its value before the sub is called.
$bool = lives { ... } This will trap any exception thrown in the codeblock. It will return true when there is no exception, and false when there is. $@ is preserved from before the sub is called when there is no exception. When an exception is trapped $@ will have the exception so that you can look at it.

DIFFERENCES FROM TEST::FATAL

Test::Fatal sets $Test::Builder::Level such that failing tests inside the exception block will report to the line where exception() is called. I disagree with this behavior, I think the actual line of the failing test is more important. Ultimately though Test::Fatal cannot be changed, people probably already depend on that behavior.

SOURCE

The source code repository for Test2-Suite can be found at http://github.com/Test-More/Test2-Suite/.

MAINTAINERS

Chad Granum <exodist@cpan.org>

AUTHORS

Chad Granum <exodist@cpan.org>

COPYRIGHT

Copyright 2015 Chad Granum <exodist7@gmail.com>.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See http://dev.perl.org/licenses/

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 TEST2::TOOLS::EXCEPTION (3) 2016-03-20

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.