VERSION

SYNOPSIS

DESCRIPTION

Carp::Assert::More is a set of wrappers around the Carp::Assert functions to make the habit of writing assertions even easier.

Everything in here is effectively syntactic sugar. There's no technical reason to use

assert_isa( $foo, 'HTML::Lint' );

instead of

assert( defined $foo );
assert( ref($foo) eq 'HTML::Lint' );

other than readability and simplicity of the code.

My intent here is to make common assertions easy so that we as programmers have no excuse to not use them.

CAVEATS

I haven't specifically done anything to make Carp::Assert::More be backwards compatible with anything besides Perl 5.6.1, much less back to 5.004. Perhaps someone with better testing resources in that area can help me out here.

REFERENCE ASSERTIONS

assert_isa( $this, $type [, $name ] )

Asserts that $this is an object of type $type.

assert_nonempty( $this [, $name ] )

$this must be a ref to either a hash or an array. Asserts that that collection contains at least 1 element. Will assert (with its own message, not $name) unless given a hash or array ref. It is OK if $this has been blessed into objecthood, but the semantics of checking an object to see if it has keys (for a hashref) or returns >0 in scalar context (for an array ref) may not be what you want.