NAME

Devel::Assert - assertions for Perl >= 5.14

SYNOPSIS

use Devel::Assert; # release mode, won't perform checks

assert(3 > 2); 

use Devel::Assert 'on';

assert(3 > 2); # oops, check your math

FEATURES

  • assert() call and all it's arguments are replaced with no-ops at compile time

  • not a source filter

DESCRIPTION

This module provides you with a C-like assert() function - it completely disappears when you don't want it. That's useful to force functions' contracts during development without sacrificing production performance.

That's just like tests, but inside your code.

sub get_url {
    my ($self, $url, $cb) = @_;

    assert length $url;
    assert(ref($cb) eq 'CODE');

    ...
}

USAGE

use Devel::Assert; # import 'assert' function, but doesn't enable it
use Devel::Assert 'on'; # import 'assert' function and enable it

use Devel::Assert 'global'; # import 'assert' function and enable it in all later 'use Devel::Assert' imports
use Devel::Assert::Global; # the same, can be used as perl -MDevel::Assert::Global your_program.pl

use Devel::Assert 'off'; # import 'assert' function, but doesn't enable it, even when in 'global' mode

CHANGES FROM 0.04

This version significantly differs from 0.0x series. Main reason for that is to get rid of the Devel::Declare dependency and pass all parsing work to Perl itself instead of creating own statement parser. Not all features are available in this release yet.

SEE ALSO

assertions - uses code attributes

Carp::Assert - requires annoying 'if DEBUG' suffix.

PerlX::Assert - based on Devel::Declare

AUTHOR

Sergey Aleynikov <randir@cpan.org>

COPYRIGHT

Copyright (C) 2009, 2015 Sergey Aleynikov

LICENSE

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