|plan $number_of_tests||Specify the number of tests to expect. If $number_of_tests isnt supplied, ASSERTION tries to deduce the number itself by parsing the calling script and counting the number of calls to ASSERT. It also returns the number of tests, should you wish to make use of that figure at some point. In test and test/ok mode a warning will be emitted if the actual number of tests does not match the number planned, similar to Test::More.|
|only(@test_numbers)||Only display the results of these tests|
|ignore(@test_numbers)||Dont display the results of these tests|
|ASSERT($bool, $comment)||The workhorse function. Behaviour depends on how the module was imported. $comment is optional.|
Collate the results from a set of tests.
In a scalar context returns a result string starting with ok or not ok; in a list context returns 1=pass or 0=fail, followed by a description.
is equivalent to
|ASSESS_FILE($file, $verbose, $timeout)||
$verbose is an optional boolean default timeout is 60 seconds (0=never timeout)
In a scalar context returns a result string; in a list context returns 1=pass or 0=fail, followed by a description. The timeout uses alarm(), but has no effect on platforms which do not implement alarm().
|($bool, $desc) = INTERPRET($result_string)||Inteprets a result string. $bool indicates 1=pass/0=fail; $desc is an optional description.|
|$bool = EQUAL($item1, $item2)||Deep comparison of 2 data structures (i.e. references to some kind of structure) or scalars.|
|$bool = EQUALS_FILE($string, $filename)||Compares a string with a canned value in a file.|
|$bool = MATCHES_FILE($string, $regexfilename)||Compares a value with a regex that is read from a file. The regex has the ^ anchor prepended and the $ anchor appended, after being read in from the file. Handy if you have random numbers or dates in your output.|
|$bool = FILES_EQUAL($filename1, $filename2)||Test if 2 files contents are identical|
|$bool = DIED($coderef)||Test if the coderef died|
|COMPILES($filename, $strict, $scalar_reference)||
Test if the perl code in $filename compiles OK, like perl -c.
If $strict is true, tests with the options -Mstrict -w.
In scalar context it returns 1 if the code compiled, 0 otherwise. In list context it returns the same boolean, followed by the output (that is, standard output and standard error <B>combinedB>) of the syntax check.
If $scalar_reference is supplied and is a scalar reference then the standard output and standard error of the syntax check subprocess will be captured <B>separatelyB>. Standard error will be put into this scalar - IO::CaptureOutput is loaded on demand to do this - and standard output will be returned as described above.
|$contents = READ_FILE($filename)||Reads the specified file and returns the contents. Returns undef if file cannot be read.|
|$success = WRITE_FILE($filename, $contents)||Writes the given contents to the specified file. Returns undef if file cannot be written.|
When Test::Assertions is imported with no arguments, ASSERT is aliased to an empty coderef. If this is still too much runtime overhead for you, you can use a constant to optimise out ASSERT statements at compile time. See the section on runtime testing in Test::Assertions::Manual for a discussion of overheads, some examples and some benchmark results.
The following modules are loaded on demand:
Test and Test::Simple Minimal unit testing modules Test::More Richer unit testing toolkit compatible with Test and Test::Simple Carp::Assert Runtime testing toolkit
- Declare ASSERT() with :assertions attribute in versions of perl >= 5.9 so it can be optimised away at runtime. It should be possible to declare the attribute conditionally in a BEGIN block (with eval) for backwards compatibility
Test::Assertions::Manual - A guide to using Test::Assertions
$Revision: 1.54 $ on $Date: 2006/08/07 10:44:42 $ by $Author: simonf $
John Alden with additions from Piers Kent and Simon Flack <cpan _at_ bbc _dot_ co _dot_ uk>
(c) BBC 2005. This program is free software; you can redistribute it and/or modify it under the GNU GPL.
See the file COPYING in this distribution, or http://www.gnu.org/licenses/gpl.txt
|perl v5.20.3||TEST::ASSERTIONS (3)||2006-08-10|