Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / man / man3 / Test::Simple.3
CommitLineData
86530b38
AT
1.\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.13
2.\"
3.\" Standard preamble:
4.\" ========================================================================
5.de Sh \" Subsection heading
6.br
7.if t .Sp
8.ne 5
9.PP
10\fB\\$1\fR
11.PP
12..
13.de Sp \" Vertical space (when we can't use .PP)
14.if t .sp .5v
15.if n .sp
16..
17.de Vb \" Begin verbatim text
18.ft CW
19.nf
20.ne \\$1
21..
22.de Ve \" End verbatim text
23.ft R
24.fi
25..
26.\" Set up some character translations and predefined strings. \*(-- will
27.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
28.\" double quote, and \*(R" will give a right double quote. | will give a
29.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
30.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
31.\" expand to `' in nroff, nothing in troff, for use with C<>.
32.tr \(*W-|\(bv\*(Tr
33.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
34.ie n \{\
35. ds -- \(*W-
36. ds PI pi
37. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
38. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
39. ds L" ""
40. ds R" ""
41. ds C` ""
42. ds C' ""
43'br\}
44.el\{\
45. ds -- \|\(em\|
46. ds PI \(*p
47. ds L" ``
48. ds R" ''
49'br\}
50.\"
51.\" If the F register is turned on, we'll generate index entries on stderr for
52.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
53.\" entries marked with X<> in POD. Of course, you'll have to process the
54.\" output yourself in some meaningful fashion.
55.if \nF \{\
56. de IX
57. tm Index:\\$1\t\\n%\t"\\$2"
58..
59. nr % 0
60. rr F
61.\}
62.\"
63.\" For nroff, turn off justification. Always turn off hyphenation; it makes
64.\" way too many mistakes in technical documents.
65.hy 0
66.if n .na
67.\"
68.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69.\" Fear. Run. Save yourself. No user-serviceable parts.
70. \" fudge factors for nroff and troff
71.if n \{\
72. ds #H 0
73. ds #V .8m
74. ds #F .3m
75. ds #[ \f1
76. ds #] \fP
77.\}
78.if t \{\
79. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80. ds #V .6m
81. ds #F 0
82. ds #[ \&
83. ds #] \&
84.\}
85. \" simple accents for nroff and troff
86.if n \{\
87. ds ' \&
88. ds ` \&
89. ds ^ \&
90. ds , \&
91. ds ~ ~
92. ds /
93.\}
94.if t \{\
95. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101.\}
102. \" troff and (daisy-wheel) nroff accents
103.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110.ds ae a\h'-(\w'a'u*4/10)'e
111.ds Ae A\h'-(\w'A'u*4/10)'E
112. \" corrections for vroff
113.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115. \" for low resolution devices (crt and lpr)
116.if \n(.H>23 .if \n(.V>19 \
117\{\
118. ds : e
119. ds 8 ss
120. ds o a
121. ds d- d\h'-1'\(ga
122. ds D- D\h'-1'\(hy
123. ds th \o'bp'
124. ds Th \o'LP'
125. ds ae ae
126. ds Ae AE
127.\}
128.rm #[ #] #H #V #F C
129.\" ========================================================================
130.\"
131.IX Title "Test::Simple 3"
132.TH Test::Simple 3 "2002-06-01" "perl v5.8.0" "Perl Programmers Reference Guide"
133.SH "NAME"
134Test::Simple \- Basic utilities for writing tests.
135.SH "SYNOPSIS"
136.IX Header "SYNOPSIS"
137.Vb 1
138\& use Test::Simple tests => 1;
139.Ve
140.PP
141.Vb 1
142\& ok( $foo eq $bar, 'foo is bar' );
143.Ve
144.SH "DESCRIPTION"
145.IX Header "DESCRIPTION"
146** If you are unfamiliar with testing \fBread Test::Tutorial\fR first! **
147.PP
148This is an extremely simple, extremely basic module for writing tests
149suitable for \s-1CPAN\s0 modules and other pursuits. If you wish to do more
150complicated testing, use the Test::More module (a drop-in replacement
151for this one).
152.PP
153The basic unit of Perl testing is the ok. For each thing you want to
154test your program will print out an \*(L"ok\*(R" or \*(L"not ok\*(R" to indicate pass
155or fail. You do this with the \fIok()\fR function (see below).
156.PP
157The only other constraint is you must pre-declare how many tests you
158plan to run. This is in case something goes horribly wrong during the
159test and your test program aborts, or skips a test or whatever. You
160do this like so:
161.PP
162.Vb 1
163\& use Test::Simple tests => 23;
164.Ve
165.PP
166You must have a plan.
167.IP "\fBok\fR" 4
168.IX Item "ok"
169.Vb 2
170\& ok( $foo eq $bar, $name );
171\& ok( $foo eq $bar );
172.Ve
173.Sp
174\&\fIok()\fR is given an expression (in this case \f(CW\*(C`$foo eq $bar\*(C'\fR). If it's
175true, the test passed. If it's false, it didn't. That's about it.
176.Sp
177\&\fIok()\fR prints out either \*(L"ok\*(R" or \*(L"not ok\*(R" along with a test number (it
178keeps track of that for you).
179.Sp
180.Vb 2
181\& # This produces "ok 1 - Hell not yet frozen over" (or not ok)
182\& ok( get_temperature($hell) > 0, 'Hell not yet frozen over' );
183.Ve
184.Sp
185If you provide a \f(CW$name\fR, that will be printed along with the \*(L"ok/not
186ok\*(R" to make it easier to find your test when if fails (just search for
187the name). It also makes it easier for the next guy to understand
188what your test is for. It's highly recommended you use test names.
189.Sp
190All tests are run in scalar context. So this:
191.Sp
192.Vb 1
193\& ok( @stuff, 'I have some stuff' );
194.Ve
195.Sp
196will do what you mean (fail if stuff is empty)
197.PP
198Test::Simple will start by printing number of tests run in the form
199\&\*(L"1..M\*(R" (so \*(L"1..5\*(R" means you're going to run 5 tests). This strange
200format lets Test::Harness know how many tests you plan on running in
201case something goes horribly wrong.
202.PP
203If all your tests passed, Test::Simple will exit with zero (which is
204normal). If anything failed it will exit with how many failed. If
205you run less (or more) tests than you planned, the missing (or extras)
206will be considered failures. If no tests were ever run Test::Simple
207will throw a warning and exit with 255. If the test died, even after
208having successfully completed all its tests, it will still be
209considered a failure and will exit with 255.
210.PP
211So the exit codes are...
212.PP
213.Vb 3
214\& 0 all tests successful
215\& 255 test died
216\& any other number how many failed (including missing or extras)
217.Ve
218.PP
219If you fail more than 254 tests, it will be reported as 254.
220.PP
221This module is by no means trying to be a complete testing system.
222It's just to get you started. Once you're off the ground its
223recommended you look at Test::More.
224.SH "EXAMPLE"
225.IX Header "EXAMPLE"
226Here's an example of a simple .t file for the fictional Film module.
227.PP
228.Vb 1
229\& use Test::Simple tests => 5;
230.Ve
231.PP
232.Vb 1
233\& use Film; # What you're testing.
234.Ve
235.PP
236.Vb 6
237\& my $btaste = Film->new({ Title => 'Bad Taste',
238\& Director => 'Peter Jackson',
239\& Rating => 'R',
240\& NumExplodingSheep => 1
241\& });
242\& ok( defined($btaste) and ref $btaste eq 'Film', 'new() works' );
243.Ve
244.PP
245.Vb 4
246\& ok( $btaste->Title eq 'Bad Taste', 'Title() get' );
247\& ok( $btaste->Director eq 'Peter Jackson', 'Director() get' );
248\& ok( $btaste->Rating eq 'R', 'Rating() get' );
249\& ok( $btaste->NumExplodingSheep == 1, 'NumExplodingSheep() get' );
250.Ve
251.PP
252It will produce output like this:
253.PP
254.Vb 8
255\& 1..5
256\& ok 1 - new() works
257\& ok 2 - Title() get
258\& ok 3 - Director() get
259\& not ok 4 - Rating() get
260\& # Failed test (t/film.t at line 14)
261\& ok 5 - NumExplodingSheep() get
262\& # Looks like you failed 1 tests of 5
263.Ve
264.PP
265Indicating the \fIFilm::Rating()\fR method is broken.
266.SH "CAVEATS"
267.IX Header "CAVEATS"
268Test::Simple will only report a maximum of 254 failures in its exit
269code. If this is a problem, you probably have a huge test script.
270Split it into multiple files. (Otherwise blame the Unix folks for
271using an unsigned short integer as the exit status).
272.PP
273Because \s-1VMS\s0's exit codes are much, much different than the rest of the
274universe, and perl does horrible mangling to them that gets in my way,
275it works like this on \s-1VMS\s0.
276.PP
277.Vb 2
278\& 0 SS$_NORMAL all tests successful
279\& 4 SS$_ABORT something went wrong
280.Ve
281.PP
282Unfortunately, I can't differentiate any further.
283.SH "NOTES"
284.IX Header "NOTES"
285Test::Simple is \fBexplicitly\fR tested all the way back to perl 5.004.
286.PP
287Test::Simple is thread-safe in perl 5.8.0 and up.
288.SH "HISTORY"
289.IX Header "HISTORY"
290This module was conceived while talking with Tony Bowden in his
291kitchen one night about the problems I was having writing some really
292complicated feature into the new Testing module. He observed that the
293main problem is not dealing with these edge cases but that people hate
294to write tests \fBat all\fR. What was needed was a dead simple module
295that took all the hard work out of testing and was really, really easy
296to learn. Paul Johnson simultaneously had this idea (unfortunately,
297he wasn't in Tony's kitchen). This is it.
298.SH "SEE ALSO"
299.IX Header "SEE ALSO"
300.IP "Test::More" 4
301.IX Item "Test::More"
302More testing functions! Once you outgrow Test::Simple, look at
303Test::More. Test::Simple is 100% forward compatible with Test::More
304(i.e. you can just use Test::More instead of Test::Simple in your
305programs and things will still work).
306.IP "Test" 4
307.IX Item "Test"
308The original Perl testing module.
309.IP "Test::Unit" 4
310.IX Item "Test::Unit"
311Elaborate unit testing.
312.IP "Test::Inline, SelfTest" 4
313.IX Item "Test::Inline, SelfTest"
314Embed tests in your code!
315.IP "Test::Harness" 4
316.IX Item "Test::Harness"
317Interprets the output of your test program.
318.SH "AUTHORS"
319.IX Header "AUTHORS"
320Idea by Tony Bowden and Paul Johnson, code by Michael G Schwern
321<schwern@pobox.com>, wardrobe by Calvin Klein.
322.SH "COPYRIGHT"
323.IX Header "COPYRIGHT"
324Copyright 2001 by Michael G Schwern <schwern@pobox.com>.
325.PP
326This program is free software; you can redistribute it and/or
327modify it under the same terms as Perl itself.
328.PP
329See \fIhttp://www.perl.com/perl/misc/Artistic.html\fR