1Test::Carp(3)         User Contributed Perl Documentation        Test::Carp(3)
2
3
4

NAME

6       Test::Carp - test your code for calls to Carp functions
7

VERSION

9       This document describes Test::Carp version 0.2
10

SYNOPSIS

12           use Test::More tests => 42;
13           use Test::Carp;
14
15           ok($x eq $y, "X does equal Y");
16           does_carp(\&function);
17           does_croak(\&function, 1, 2, 3);
18           does_carp_that_matches(\&function, qr/whoopsy/);
19           does_croak_that_matches(\&function, 1, 2, 3, qr/a likely story/);
20

DESCRIPTION

22       Call given code (with given arguments) and tests whether the given Carp
23       function (or their imported versions) are called (with a given value)
24       or not.
25

INTERFACE

27       All functions are put in the caller's name space during import(). If
28       you'd rather use their full name space and not clutter up the current
29       package with functions just:
30
31         require Test::Carp;
32
33       or
34
35         use Test::Carp ();
36
37       instead of
38
39         use Test::Carp;
40
41   being ok() w/ ok()
42       Internally, Test::Carp uses Test::More::ok() (require()ing in
43       Test::More if needed) when it needs to use an ok() function.
44
45       If you want to specify a different one for it to use simply supply a
46       coderef in the use statement.
47
48          use Test::Carp \&Test::Foo::ok;
49
50       The function should take the same args as Test::More::ok() and probably
51       behave the same as well.
52
53   carp()/cluck() functions
54       does_carp()
55           Test whether the given code ref, when executed, calls carp().
56
57           Test fails if carp() is not called. There are 2 forms:
58
59           Without arguments to codreref:
60
61              does_carp(sub {...});
62
63           With arge to coderef:
64
65              does_carp(sub {...},"first arg to coderef", "second arg to coderef", ...);
66
67       does_carp_that_matches()
68           Test whether the given code ref, when executed, calls carp() with a
69           specific message.
70
71           The test fails if carp() is not called with the given message.
72
73           The last argument should be a string or Regexp ref (i.e. qr//) to
74           match the message against.
75
76           There are 2 forms:
77
78           Without arguments passed to codreref:
79
80              does_carp(sub {...}, $match_me)
81
82           With arguments passed to coderef:
83
84              does_carp(sub {...},"first arg to coderef", "second arg to coderef", ..., $match_me);
85
86       does_cluck
87           Like does_carp() but for cluck()
88
89       does_cluck_that_matches
90           Like does_carp_that_matches() but for cluck()
91
92   croak()/confess() functions
93       These functions stop running at the point it calls the [croak|cluck]()
94       just like in normal code.
95
96       does_croak()
97           Like does_carp() but for croak()
98
99       does_croak_that_matches()
100           Like does_carp_that_matches() but for croak()
101
102       does_confess()
103           Like does_carp() but for confess()
104
105       does_confess_that_matches()
106           Like does_carp_that_matches() but for confess()
107

DIAGNOSTICS

109       Throws no warnings or errors of it's own.
110

CONFIGURATION AND ENVIRONMENT

112       Test::Carp requires no configuration files or environment variables.
113

DEPENDENCIES

115       Test::More for ok() unless you define a different ok() for it to use.
116
117       It uses Carp in order to ensure carp and corak are defined before it
118       does what it does.
119

INCOMPATIBILITIES

121       None reported.
122

BUGS AND LIMITATIONS

124       No bugs have been reported.
125
126       Please report any bugs or feature requests to
127       "bug-test-carp@rt.cpan.org", or through the web interface at
128       <http://rt.cpan.org>.
129

TODO

131       Corresponding does_not_* functions. (v0.2)
132
133       TODOs in 02.functions.t (v0.2)
134
135       Maybe count and overall call info type functions, depending on demand ?
136
137       Determine [what needs done/if it should be done/etc] to make the test
138       syntax not require a codref ?
139
140       Add mostly-internal Carp functions like (short|long)mess[_heavy](), etc
141       ?
142

AUTHOR

144       Daniel Muey  "<http://drmuey.com/cpan_contact.pl>"
145
147       Copyright (c) 2010, Daniel Muey "<http://drmuey.com/cpan_contact.pl>".
148       All rights reserved.
149
150       This module is free software; you can redistribute it and/or modify it
151       under the same terms as Perl itself. See perlartistic.
152

DISCLAIMER OF WARRANTY

154       BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
155       FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT
156       WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER
157       PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND,
158       EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
159       WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
160       ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH
161       YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
162       NECESSARY SERVICING, REPAIR, OR CORRECTION.
163
164       IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
165       WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
166       REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE
167       TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR
168       CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
169       SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
170       RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
171       FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
172       SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
173       DAMAGES.
174
175
176
177perl v5.30.1                      2020-01-30                     Test::Carp(3)
Impressum