Toby Inkster > Moops > PerlX::Assert

Download:
Moops-0.031.tar.gz

Dependencies

Annotate this POD

Website

CPAN RT

Open  2
Stalled  1
View/Report Bugs
Module Version: 0.031   Source  

NAME ^

PerlX::Assert - yet another assertion keyword

SYNOPSIS ^

   use PerlX::Assert;
   
   assert { 1 >= 10 };

DESCRIPTION ^

PerlX::Assert is a framework for embedding assertions in Perl code. Under normal circumstances, assertions are not checked; they are optimized away at compile time.

However if, at compile time, any of the following environment variables is true, assertions are checked, and if they fail, throw an exception.

That is, assertions will only typically be checked when the test suite is being run on the authors' machine, or being run by CPAN smoke testers.

You can also force assertions to be checked using:

   use PerlX::Assert -check;

Or if using Moops, use the ':assertions' trait to force assertion checking:

   class Whiner :assertions {
      # ...
   }

There are four syntaxes for expressing assertions:

   assert EXPR;
   assert { BLOCK };
   assert "name", EXPR;
   assert "name" { BLOCK };

Assertions can be named, which is probably a good idea because this module (and the rest of Moops) screws up Perl's reporting of line numbers. Names must be a quoted string. (Single or double quotes, or the q or qq quote-like operators.) An assertion is a statement, so must be followed by a semicolon, unless it's the last statement in a block.

PerlX::Assert is currently distributed as part of Moops, but is fairly independent of the rest of it, and may be spun off as a separate release in the future.

BUGS ^

Please report any bugs to http://rt.cpan.org/Dist/Display.html?Queue=Moops.

SEE ALSO ^

Devel::Assert, Carp::Assert.

Moops.

AUTHOR ^

Toby Inkster <tobyink@cpan.org>.

COPYRIGHT AND LICENCE ^

This software is copyright (c) 2013-2014 by Toby Inkster.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

DISCLAIMER OF WARRANTIES ^

THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.

syntax highlighting: