Debian Codegraph @

README

raw
1 NAME
2 Test::Exception::LessClever - (DEPRECATED) Test::Exception simplified
3
4 DEPRECATION NOTICE
5 *** This module is deprecated: please do not use it! ***
6
7 An alternative to Test::Exception that is much simpler. This alternative
8 does not use fancy stack tricks to hide itself. The idea here is to keep
9 it simple. This also solves the Test::Exception bug where some dies will
10 be hidden when a DESTROY method calls eval. If a DESTROY method masks $@
11 a warning will be generated as well.
12
13 WHY REWRITE TEST-EXCEPTION
14 Here is an IRC log.
15
16 <Exodist> wtf? Bizarre copy of HASH in sassign at /usr/lib64/perl5/5.10.1/Carp/Heavy.pm line 104
17 <Exodist> hmm, it doesn't happen when I step through the debugger, that sure is helpful yessir
18 <Exodist> hmm, throws_ok or dies_ok { stuff that croaks in a package used by the one being tested }, at least in this case causes that error. If I change it to eval {}; ok( $@ ); like( $@, qr// ); it works fine
19 <Exodist> Ah-Ha, earlier when I mentioned I stopped using throws_ok because of something I could not remember, this was it, I stumbled on it again!
20 <confound> probably because throws_ok tries to do clever things to fiddle with the call stack to make it appear as though its guts are not being called
21 <confound> less clever would be more useful
22
23 SYNOPSIS
24 Pretty much a clone of Test::Exception Refer to those docs for more
25 details.
26
27 use Test::More;
28 use Test::Exception;
29
30 dies_ok { die( 'xxx' )} "Should die";
31 lives_ok { 1 } "Should live";
32 throws_ok { die( 'xxx' )} qr/xxx/, "Throws 'xxx'";
33 lives_and { ok( 1, "We did not die" )} "Ooops we died";
34
35 done_testing;
36
37 EXPORTABLE FUNCTIONS
38 $status = live_or_die( sub { ... }, $name )
39 ($status, $msg) = live_or_die( sub { ... }, $name )
40 Check if the code lives or dies. In scalar context returns true or
41 false. In array context returns the same true or false with the
42 error message. If the return is true the error message will be
43 something along the lines of 'did not die' but this may change in
44 the future.
45
46 Will generate a warning if the test dies, $@ is empty AND called in
47 array context. This usually occurs when an objects DESTROY method
48 calls eval and masks $@.
49
50 *NOT EXPORTED BY DEFAULT*
51
52 lives_ok( sub { ... }, $name )
53 Test passes if the sub does not die, false if it does.
54
55 dies_ok( sub { ... }, $name )
56 Test passes if the sub dies, false if it does not.
57
58 throws_ok( sub { ... }, qr/message/, $name )
59 Check that the sub dies, and that it throws an error that matches
60 the regex.
61
62 Test fails is the sub does not die, or if the message does not match
63 the regex.
64
65 lives_and( sub {...}, $name )
66 Fails with $name if the sub dies, otherwise is passive. This is
67 useful for running a test that could die. If it dies there is a
68 failure, if it lives it is responsible for itself.
69
70 SEE ALSO
71 * Test::Fatal
72
73 * Test::Exception
74
75 AUTHORS
76 Chad Granum [email protected]
77
78 COPYRIGHT
79 Copyright (C) 2010 Chad Granum
80
81 Test-Exception-LessClever is free software; Standard perl licence.
82
83 Test-Exception-LessClever is distributed in the hope that it will be
84 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
85 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for
86 more details.
87