.\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "Test::Exception::LessClever 3pm" .TH Test::Exception::LessClever 3pm "2016-12-04" "perl v5.24.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Test::Exception::LessClever \- (DEPRECATED) Test::Exception simplified .SH "DEPRECATION NOTICE" .IX Header "DEPRECATION NOTICE" *** This module is deprecated: please do not use it! *** .PP An alternative to Test::Exception that is much simpler. This alternative does not use fancy stack tricks to hide itself. The idea here is to keep it simple. This also solves the Test::Exception bug where some dies will be hidden when a \s-1DESTROY\s0 method calls eval. If a \s-1DESTROY\s0 method masks $@ a warning will be generated as well. .SH "WHY REWRITE TEST-EXCEPTION" .IX Header "WHY REWRITE TEST-EXCEPTION" Here is an \s-1IRC\s0 log. .PP .Vb 6 \& wtf? Bizarre copy of HASH in sassign at /usr/lib64/perl5/5.10.1/Carp/Heavy.pm line 104 \& hmm, it doesn\*(Aqt happen when I step through the debugger, that sure is helpful yessir \& 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 \& 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! \& 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 \& less clever would be more useful .Ve .SH "SYNOPSIS" .IX Header "SYNOPSIS" Pretty much a clone of Test::Exception Refer to those docs for more details. .PP .Vb 2 \& use Test::More; \& use Test::Exception; \& \& dies_ok { die( \*(Aqxxx\*(Aq )} "Should die"; \& lives_ok { 1 } "Should live"; \& throws_ok { die( \*(Aqxxx\*(Aq )} qr/xxx/, "Throws \*(Aqxxx\*(Aq"; \& lives_and { ok( 1, "We did not die" )} "Ooops we died"; \& \& done_testing; .Ve .SH "EXPORTABLE FUNCTIONS" .IX Header "EXPORTABLE FUNCTIONS" .ie n .IP "$status = live_or_die( sub { ... }, $name )" 4 .el .IP "\f(CW$status\fR = live_or_die( sub { ... }, \f(CW$name\fR )" 4 .IX Item "$status = live_or_die( sub { ... }, $name )" .PD 0 .ie n .IP "($status, $msg) = live_or_die( sub { ... }, $name )" 4 .el .IP "($status, \f(CW$msg\fR) = live_or_die( sub { ... }, \f(CW$name\fR )" 4 .IX Item "($status, $msg) = live_or_die( sub { ... }, $name )" .PD Check if the code lives or dies. In scalar context returns true or false. In array context returns the same true or false with the error message. If the return is true the error message will be something along the lines of 'did not die' but this may change in the future. .Sp Will generate a warning if the test dies, $@ is empty \s-1AND\s0 called in array context. This usually occurs when an objects \s-1DESTROY\s0 method calls eval and masks $@. .Sp *NOT \s-1EXPORTED BY\s0 DEFAULT* .ie n .IP "lives_ok( sub { ... }, $name )" 4 .el .IP "lives_ok( sub { ... }, \f(CW$name\fR )" 4 .IX Item "lives_ok( sub { ... }, $name )" Test passes if the sub does not die, false if it does. .ie n .IP "dies_ok( sub { ... }, $name )" 4 .el .IP "dies_ok( sub { ... }, \f(CW$name\fR )" 4 .IX Item "dies_ok( sub { ... }, $name )" Test passes if the sub dies, false if it does not. .ie n .IP "throws_ok( sub { ... }, qr/message/, $name )" 4 .el .IP "throws_ok( sub { ... }, qr/message/, \f(CW$name\fR )" 4 .IX Item "throws_ok( sub { ... }, qr/message/, $name )" Check that the sub dies, and that it throws an error that matches the regex. .Sp Test fails is the sub does not die, or if the message does not match the regex. .ie n .IP "lives_and( sub {...}, $name )" 4 .el .IP "lives_and( sub {...}, \f(CW$name\fR )" 4 .IX Item "lives_and( sub {...}, $name )" Fails with \f(CW$name\fR if the sub dies, otherwise is passive. This is useful for running a test that could die. If it dies there is a failure, if it lives it is responsible for itself. .SH "SEE ALSO" .IX Header "SEE ALSO" .IP "\(bu" 4 Test::Fatal .IP "\(bu" 4 Test::Exception .SH "AUTHORS" .IX Header "AUTHORS" Chad Granum exodist7@gmail.com .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright (C) 2010 Chad Granum .PP Test-Exception-LessClever is free software; Standard perl licence. .PP Test-Exception-LessClever is distributed in the hope that it will be useful, but \s-1WITHOUT ANY WARRANTY\s0; without even the implied warranty of \s-1MERCHANTABILITY\s0 or \s-1FITNESS FOR A PARTICULAR PURPOSE. \s0 See the license for more details.