X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FGitalist.git;a=blobdiff_plain;f=local-lib5%2Fman%2Fman3%2FTest%3A%3ASimple.3pm;fp=local-lib5%2Fman%2Fman3%2FTest%3A%3ASimple.3pm;h=06d32709204eccddcc2e973a351802e85d21263b;hp=0000000000000000000000000000000000000000;hb=3fea05b9fbf95091f4522528b9980a33e0235603;hpb=af746827daa7a8feccee889e1d12ebc74cc9201e diff --git a/local-lib5/man/man3/Test::Simple.3pm b/local-lib5/man/man3/Test::Simple.3pm new file mode 100644 index 0000000..06d3270 --- /dev/null +++ b/local-lib5/man/man3/Test::Simple.3pm @@ -0,0 +1,320 @@ +.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.3 +.\" +.\" Standard preamble: +.\" ======================================================================== +.de Sh \" Subsection heading +.br +.if t .Sp +.ne 5 +.PP +\fB\\$1\fR +.PP +.. +.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. | will give a +.\" real vertical bar. \*(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-|\(bv\*(Tr +.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" '' +'br\} +.\" +.\" If the F register is turned on, we'll generate index entries on stderr for +.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index +.\" entries marked with X<> in POD. Of course, you'll have to process the +.\" output yourself in some meaningful fashion. +.if \nF \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" +.. +. nr % 0 +. rr F +.\} +.\" +.\" For nroff, turn off justification. Always turn off hyphenation; it makes +.\" way too many mistakes in technical documents. +.hy 0 +.if n .na +.\" +.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). +.\" Fear. Run. Save yourself. No user-serviceable parts. +. \" fudge factors for nroff and troff +.if n \{\ +. ds #H 0 +. ds #V .8m +. ds #F .3m +. ds #[ \f1 +. ds #] \fP +.\} +.if t \{\ +. ds #H ((1u-(\\\\n(.fu%2u))*.13m) +. ds #V .6m +. ds #F 0 +. ds #[ \& +. ds #] \& +.\} +. \" simple accents for nroff and troff +.if n \{\ +. ds ' \& +. ds ` \& +. ds ^ \& +. ds , \& +. ds ~ ~ +. ds / +.\} +.if t \{\ +. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" +. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' +. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' +. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' +. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' +. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' +.\} +. \" troff and (daisy-wheel) nroff accents +.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' +.ds 8 \h'\*(#H'\(*b\h'-\*(#H' +.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] +.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' +.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' +.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] +.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] +.ds ae a\h'-(\w'a'u*4/10)'e +.ds Ae A\h'-(\w'A'u*4/10)'E +. \" corrections for vroff +.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' +.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' +. \" for low resolution devices (crt and lpr) +.if \n(.H>23 .if \n(.V>19 \ +\{\ +. ds : e +. ds 8 ss +. ds o a +. ds d- d\h'-1'\(ga +. ds D- D\h'-1'\(hy +. ds th \o'bp' +. ds Th \o'LP' +. ds ae ae +. ds Ae AE +.\} +.rm #[ #] #H #V #F C +.\" ======================================================================== +.\" +.IX Title "Test::Simple 3" +.TH Test::Simple 3 "2009-09-02" "perl v5.8.7" "User Contributed Perl Documentation" +.SH "NAME" +Test::Simple \- Basic utilities for writing tests. +.SH "SYNOPSIS" +.IX Header "SYNOPSIS" +.Vb 1 +\& use Test::Simple tests => 1; +.Ve +.PP +.Vb 1 +\& ok( $foo eq $bar, 'foo is bar' ); +.Ve +.SH "DESCRIPTION" +.IX Header "DESCRIPTION" +** If you are unfamiliar with testing \fBread Test::Tutorial\fR first! ** +.PP +This is an extremely simple, extremely basic module for writing tests +suitable for \s-1CPAN\s0 modules and other pursuits. If you wish to do more +complicated testing, use the Test::More module (a drop-in replacement +for this one). +.PP +The basic unit of Perl testing is the ok. For each thing you want to +test your program will print out an \*(L"ok\*(R" or \*(L"not ok\*(R" to indicate pass +or fail. You do this with the \fIok()\fR function (see below). +.PP +The only other constraint is you must pre-declare how many tests you +plan to run. This is in case something goes horribly wrong during the +test and your test program aborts, or skips a test or whatever. You +do this like so: +.PP +.Vb 1 +\& use Test::Simple tests => 23; +.Ve +.PP +You must have a plan. +.IP "\fBok\fR" 4 +.IX Item "ok" +.Vb 2 +\& ok( $foo eq $bar, $name ); +\& ok( $foo eq $bar ); +.Ve +.Sp +\&\fIok()\fR is given an expression (in this case \f(CW\*(C`$foo eq $bar\*(C'\fR). If it's +true, the test passed. If it's false, it didn't. That's about it. +.Sp +\&\fIok()\fR prints out either \*(L"ok\*(R" or \*(L"not ok\*(R" along with a test number (it +keeps track of that for you). +.Sp +.Vb 2 +\& # This produces "ok 1 \- Hell not yet frozen over" (or not ok) +\& ok( get_temperature($hell) > 0, 'Hell not yet frozen over' ); +.Ve +.Sp +If you provide a \f(CW$name\fR, that will be printed along with the \*(L"ok/not +ok\*(R" to make it easier to find your test when if fails (just search for +the name). It also makes it easier for the next guy to understand +what your test is for. It's highly recommended you use test names. +.Sp +All tests are run in scalar context. So this: +.Sp +.Vb 1 +\& ok( @stuff, 'I have some stuff' ); +.Ve +.Sp +will do what you mean (fail if stuff is empty) +.PP +Test::Simple will start by printing number of tests run in the form +\&\*(L"1..M\*(R" (so \*(L"1..5\*(R" means you're going to run 5 tests). This strange +format lets Test::Harness know how many tests you plan on running in +case something goes horribly wrong. +.PP +If all your tests passed, Test::Simple will exit with zero (which is +normal). If anything failed it will exit with how many failed. If +you run less (or more) tests than you planned, the missing (or extras) +will be considered failures. If no tests were ever run Test::Simple +will throw a warning and exit with 255. If the test died, even after +having successfully completed all its tests, it will still be +considered a failure and will exit with 255. +.PP +So the exit codes are... +.PP +.Vb 3 +\& 0 all tests successful +\& 255 test died or all passed but wrong # of tests run +\& any other number how many failed (including missing or extras) +.Ve +.PP +If you fail more than 254 tests, it will be reported as 254. +.PP +This module is by no means trying to be a complete testing system. +It's just to get you started. Once you're off the ground its +recommended you look at Test::More. +.SH "EXAMPLE" +.IX Header "EXAMPLE" +Here's an example of a simple .t file for the fictional Film module. +.PP +.Vb 1 +\& use Test::Simple tests => 5; +.Ve +.PP +.Vb 1 +\& use Film; # What you're testing. +.Ve +.PP +.Vb 6 +\& my $btaste = Film\->new({ Title => 'Bad Taste', +\& Director => 'Peter Jackson', +\& Rating => 'R', +\& NumExplodingSheep => 1 +\& }); +\& ok( defined($btaste) && ref $btaste eq 'Film, 'new() works' ); +.Ve +.PP +.Vb 4 +\& ok( $btaste\->Title eq 'Bad Taste', 'Title() get' ); +\& ok( $btaste\->Director eq 'Peter Jackson', 'Director() get' ); +\& ok( $btaste\->Rating eq 'R', 'Rating() get' ); +\& ok( $btaste\->NumExplodingSheep == 1, 'NumExplodingSheep() get' ); +.Ve +.PP +It will produce output like this: +.PP +.Vb 9 +\& 1..5 +\& ok 1 \- new() works +\& ok 2 \- Title() get +\& ok 3 \- Director() get +\& not ok 4 \- Rating() get +\& # Failed test 'Rating() get' +\& # in t/film.t at line 14. +\& ok 5 \- NumExplodingSheep() get +\& # Looks like you failed 1 tests of 5 +.Ve +.PP +Indicating the \fIFilm::Rating()\fR method is broken. +.SH "CAVEATS" +.IX Header "CAVEATS" +Test::Simple will only report a maximum of 254 failures in its exit +code. If this is a problem, you probably have a huge test script. +Split it into multiple files. (Otherwise blame the Unix folks for +using an unsigned short integer as the exit status). +.PP +Because \s-1VMS\s0's exit codes are much, much different than the rest of the +universe, and perl does horrible mangling to them that gets in my way, +it works like this on \s-1VMS\s0. +.PP +.Vb 2 +\& 0 SS$_NORMAL all tests successful +\& 4 SS$_ABORT something went wrong +.Ve +.PP +Unfortunately, I can't differentiate any further. +.SH "NOTES" +.IX Header "NOTES" +Test::Simple is \fBexplicitly\fR tested all the way back to perl 5.6.0. +.PP +Test::Simple is thread-safe in perl 5.8.1 and up. +.SH "HISTORY" +.IX Header "HISTORY" +This module was conceived while talking with Tony Bowden in his +kitchen one night about the problems I was having writing some really +complicated feature into the new Testing module. He observed that the +main problem is not dealing with these edge cases but that people hate +to write tests \fBat all\fR. What was needed was a dead simple module +that took all the hard work out of testing and was really, really easy +to learn. Paul Johnson simultaneously had this idea (unfortunately, +he wasn't in Tony's kitchen). This is it. +.SH "SEE ALSO" +.IX Header "SEE ALSO" +.IP "Test::More" 4 +.IX Item "Test::More" +More testing functions! Once you outgrow Test::Simple, look at +Test::More. Test::Simple is 100% forward compatible with Test::More +(i.e. you can just use Test::More instead of Test::Simple in your +programs and things will still work). +.PP +Look in Test::More's \s-1SEE\s0 \s-1ALSO\s0 for more testing modules. +.SH "AUTHORS" +.IX Header "AUTHORS" +Idea by Tony Bowden and Paul Johnson, code by Michael G Schwern +, wardrobe by Calvin Klein. +.SH "COPYRIGHT" +.IX Header "COPYRIGHT" +Copyright 2001\-2008 by Michael G Schwern . +.PP +This program is free software; you can redistribute it and/or +modify it under the same terms as Perl itself. +.PP +See \fIhttp://www.perl.com/perl/misc/Artistic.html\fR