assertions is a Perl module that specifies the tags used to enable and disable the execution of assertion subroutines.
An assertion subroutine is declared with the :assertion attribute. This subroutine is not normally executed: it's optimized away by perl at compile-time.
The assertions pragma associates to its lexical scope one or several assertion tags. Then, to activate the execution of the assertions subroutines in this scope, these tags must be given to perl via the -A command-line option. For instance, if...
use assertions 'foobar';
is used, assertions on the same lexical scope will only be executed when perl is called as...
perl -A=foobar script.pl
Regular expressions can also be used within the -A switch. For instance...
perl -A='foo.*' script.pl
will activate assertions tagged as foo, foobar, foofoo, etc.
SYNOPSIS
sub assert (&) : assertion { &{$_[0]}() }
use assertions 'foo';
assert { print "asserting 'foo'\n" };
{
use assertions qw( foo bar );
assert { print "asserting 'foo' and 'bar'\n" };
}
{
use assertions qw( bar );
assert { print "asserting only 'bar'\n" };
}
{
use assertions '_ && bar';
assert { print "asserting 'foo' && 'bar'\n" };
}
assert { print "asserting 'foo' again\n" };
Product's homepage
Requirements:
· Perl