1Test::Stream::Plugin::EUxsceerptCioonnt(r3i)buted Perl DToecsutm:e:nSttarteiaomn::Plugin::Exception(3)
2
3
4
6 Test::Stream::Plugin::Exception - Simple tools to help test exceptions.
7
9 This distribution is deprecated in favor of Test2, Test2::Suite, and
10 Test2::Workflow.
11
12 See Test::Stream::Manual::ToTest2 for a conversion guide.
13
15 # Loads Exception, we also need 'Core', so load that as well.
16 use Test::Stream qw/Core Exception/;
17
18 ok(lives { ... }, "codeblock did not die");
19
20 like(dies { die 'xxx' }, qr/xxx/, "codeblock threw expected exception");
21
23 $bool = lives { ... }
24 If the codeblock does not throw any exception this will return
25 true. If the codeblock does throw an exception this will return
26 false, after printing the exception as a warning.
27
28 ok(lives { ... }, "codeblock did not die");
29
30 $error = dies { ... }
31 This will return undef if the codeblock does not throw an
32 exception, otherwise it returns the exception. Note, if your
33 exception is an empty string or 0 it is your responsibility to
34 check that the error is defined instead of using a simple boolean
35 check.
36
37 ok( defined dies { die 0 }, "died" );
38
39 like(dies { die 'xxx' }, qr/xxx/, "codeblock threw expected exception");
40
42 The source code repository for Test::Stream can be found at
43 http://github.com/Test-More/Test-Stream/.
44
46 Chad Granum <exodist@cpan.org>
47
49 Chad Granum <exodist@cpan.org>
50
52 Copyright 2015 Chad Granum <exodist7@gmail.com>.
53
54 This program is free software; you can redistribute it and/or modify it
55 under the same terms as Perl itself.
56
57 See http://dev.perl.org/licenses/
58
59
60
61perl v5.36.0 2022-07-22Test::Stream::Plugin::Exception(3)