package Common::Assert;
use strict;
use warnings;

#
# Assert.pm
#
# Provides a mechanism vaguely analagous to "assert.h" in the
# standard C library.
#
# Essentially, the call evaluates the expression, and will
# call confess (producing a stack trace) unless it evaluates to true.
#
# The second argument is optional - this should contain a string with some
# additional info for the poor sap that has to figure out why this broke.

# Ex:
# assert(defined $args{required_argument});
# assert(defined $args{$foo}, " arg $foo was not defined");
#

use Carp;

use Exporter;
use vars qw(@ISA @EXPORT @EXPORT_OK);
@ISA       = qw(Exporter);
@EXPORT    = qw(assert);
@EXPORT_OK = qw(assert);

sub assert {
    my $expr = shift;
    my $eMsg = shift;
    confess "ASSERTION FAILED : $eMsg" unless ($expr);
}

###
1;    # Play nicely.
###
