VERSION
This document describes Test::Carp version 0.2SYNOPSIS
use Test::More tests => 42;
use Test::Carp;
ok($x eq $y, "X does equal Y");
does_carp(\&function);
does_croak(\&function, 1, 2, 3);
does_carp_that_matches(\&function, qr/whoopsy/);
does_croak_that_matches(\&function, 1, 2, 3, qr/a likely story/);
DESCRIPTION
Call given code (with given arguments) and tests whether the given Carp function (or their imported versions) are called (with a given value) or not.INTERFACE
All functions are put in the caller's name space during import(). If you'd rather use their full name space and not clutter up the current package with functions just:
require Test::Carp;
or
use Test::Carp ();
instead of
use Test::Carp;
being ok() w/ ok()
Internally, Test::Carp uses Test::More::ok() (require()ing in Test::More if needed) when it needs to use an ok() function.If you want to specify a different one for it to use simply supply a coderef in the use statement.
use Test::Carp \&Test::Foo::ok;
The function should take the same args as Test::More::ok() and probably behave the same as well.
carp()/cluck() functions
- does_carp()
-
Test whether the given code ref, when executed, calls carp().
Test fails if carp() is not called. There are 2 forms:
Without arguments to codreref:
does_carp(sub {...});
With arge to coderef:
does_carp(sub {...},"first arg to coderef", "second arg to coderef", ...);
- does_carp_that_matches()
-
Test whether the given code ref, when executed, calls carp() with a specific message.
The test fails if carp() is not called with the given message.
The last argument should be a string or Regexp ref (i.e. qr//) to match the message against.
There are 2 forms:
Without arguments passed to codreref:
does_carp(sub {...}, $match_me)
With arguments passed to coderef:
does_carp(sub {...},"first arg to coderef", "second arg to coderef", ..., $match_me);
- does_cluck
- Like does_carp() but for cluck()
- does_cluck_that_matches
- Like does_carp_that_matches() but for cluck()
croak()/confess() functions
These functions stop running at the point it calls the [croak|cluck]() just like in normal code.- does_croak()
- Like does_carp() but for croak()
- does_croak_that_matches()
- Like does_carp_that_matches() but for croak()
- does_confess()
- Like does_carp() but for confess()
- does_confess_that_matches()
- Like does_carp_that_matches() but for confess()
DIAGNOSTICS
Throws no warnings or errors of it's own.CONFIGURATION AND ENVIRONMENT
Test::Carp requires no configuration files or environment variables.DEPENDENCIES
Test::More for ok() unless you define a different ok() for it to use.It uses Carp in order to ensure carp and corak are defined before it does what it does.
INCOMPATIBILITIES
None reported.BUGS AND LIMITATIONS
No bugs have been reported.Please report any bugs or feature requests to "[email protected]", or through the web interface at <http://rt.cpan.org>.
TODO
Corresponding does_not_* functions. (v0.2)TODOs in 02.functions.t (v0.2)
Maybe count and overall call info type functions, depending on demand ?
Determine [what needs done/if it should be done/etc] to make the test syntax not require a codref ?
Add mostly-internal Carp functions like (short|long)mess[_heavy](), etc ?
AUTHOR
Daniel Muey "<http://drmuey.com/cpan_contact.pl>"LICENCE AND COPYRIGHT
Copyright (c) 2010, Daniel Muey "<http://drmuey.com/cpan_contact.pl>". All rights reserved.This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
DISCLAIMER OF WARRANTY
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.