Cheat-Meta
view release on metacpan or search on metacpan
lib/Cheat/Sheet/Test.pod view on Meta::CPAN
my $got = $trap->leaveby; # 'return', 'die', or 'exit'.
my $got = $trap->die; # exception thrown if any
my $got = $trap->exit; # exit code caught if attempted
my $got = $trap->stdout; # STDOUT in one string
my $got = $trap->stderr; # STDERR in one string
my $got = $trap->return; # arrayref of normal return values
my $got = $trap->return($index); # pass $index as method argument
my $got = $trap->return(@indices); # it slices, it dices
my $got = $trap->warn ($index); # warnings as an array
# Test methods (for any ACC)
# e.g.: $trap->return_ok(); $trap->stdout_like();
# $ix or @ixs required if ACC is array, otherwise omit
use Test::More tests => 9; # ~~ Test::More::*
$trap->ACC_ok ( $ix, $name ); # ok()
$trap->ACC_nok ( $ix, $name ); # ! ok()
$trap->ACC_is ( $ix, $want, $name ); # is()
$trap->ACC_isnt ( $ix, $want, $name ); # ! is()
$trap->ACC_like ( $ix, qr/./, $name ); # like()
$trap->ACC_unlike ( $ix, qr/./, $name ); # ! like()
$trap->ACC_isa_ok ( $ix, $class, $name ); # isa()
$trap->ACC_is_deeply( $ix, $want, $name ); # is_deeply()
# Examples of above:
$trap->return_ok( 0, 'got something' ); # even if :scalar, return => []
$trap->return_is( 1, 9, 'returns an array and the second element is 9' );
$trap->stdout_like( qr/hell|damn/, 'tried to print a word to screen');
$trap->die_unlike ( qr/hell|damn/, 'died like a lady'); # fail if !die
$trap->return_isa_ok ( 0, 'Acme::Teddy' 'returned object');
# Convenience methods with better diagnostics than their equivalents...
$trap->did_die; # $trap->leaveby_is('die');
$trap->did_exit; # $trap->leaveby_is('exit');
$trap->did_return; # $trap->leaveby_is('return');
$trap->quiet; # ok( !$trap->stdout && !$trap-stderr);
## Test::Trap
=head1 SEE ALSO
=over
=item * L<Cheat::Meta>
=item * L<perlcheat>
=back
=head1 FUNCTIONS/METHODS
None. This module contains only POD. Don't try to load it.
=head1 INTERFACE
Open the cheat (the *.perl file) in your editor.
Copy out whatever you like.
If you look at the *.pod file, you'll see POD verbatim paragraphs.
Your choice.
You can also get the same content in your pager with:
perldoc Cheat::Sheet::Test
=head1 BUGS AND LIMITATIONS
No cheat sheet will teach you anything. It's only a reminder. You B<must>
consult each module's own full documentation I<at least> before using it.
I hope.
This module does not contain magic to squirt code into your module.
Copy and paste.
No boilerplate code will work right away. Edit it to your needs.
=head1 THANKS
=over
=item *
To about 8500 authors who have uploaded about 85,000 modules to the CPAN.
=back
=head1 AUTHOR
Xiong Changnian C<< <xiong@cpan.org> >>
=head1 LICENSE
Copyright (C) 2010 Xiong Changnian C<< <xiong@cpan.org> >>
This library and its contents are released under Artistic License 2.0:
L<http://www.opensource.org/licenses/artistic-license-2.0.php>
=cut
( run in 0.737 second using v1.01-cache-2.11-cpan-0b5f733616e )