xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/lib/Test/Harness/Assert.pm (revision 0:68f95e015346)
1*0Sstevel@tonic-gate# $Id: Assert.pm,v 1.3 2003/09/11 15:57:29 andy Exp $
2*0Sstevel@tonic-gate
3*0Sstevel@tonic-gatepackage Test::Harness::Assert;
4*0Sstevel@tonic-gate
5*0Sstevel@tonic-gateuse strict;
6*0Sstevel@tonic-gaterequire Exporter;
7*0Sstevel@tonic-gateuse vars qw($VERSION @EXPORT @ISA);
8*0Sstevel@tonic-gate
9*0Sstevel@tonic-gate$VERSION = '0.02';
10*0Sstevel@tonic-gate
11*0Sstevel@tonic-gate@ISA = qw(Exporter);
12*0Sstevel@tonic-gate@EXPORT = qw(assert);
13*0Sstevel@tonic-gate
14*0Sstevel@tonic-gate
15*0Sstevel@tonic-gate=head1 NAME
16*0Sstevel@tonic-gate
17*0Sstevel@tonic-gateTest::Harness::Assert - simple assert
18*0Sstevel@tonic-gate
19*0Sstevel@tonic-gate=head1 SYNOPSIS
20*0Sstevel@tonic-gate
21*0Sstevel@tonic-gate  ### FOR INTERNAL USE ONLY ###
22*0Sstevel@tonic-gate
23*0Sstevel@tonic-gate  use Test::Harness::Assert;
24*0Sstevel@tonic-gate
25*0Sstevel@tonic-gate  assert( EXPR, $name );
26*0Sstevel@tonic-gate
27*0Sstevel@tonic-gate=head1 DESCRIPTION
28*0Sstevel@tonic-gate
29*0Sstevel@tonic-gateA simple assert routine since we don't have Carp::Assert handy.
30*0Sstevel@tonic-gate
31*0Sstevel@tonic-gateB<For internal use by Test::Harness ONLY!>
32*0Sstevel@tonic-gate
33*0Sstevel@tonic-gate=head1 FUNCTIONS
34*0Sstevel@tonic-gate
35*0Sstevel@tonic-gate=head2 C<assert()>
36*0Sstevel@tonic-gate
37*0Sstevel@tonic-gate  assert( EXPR, $name );
38*0Sstevel@tonic-gate
39*0Sstevel@tonic-gateIf the expression is false the program aborts.
40*0Sstevel@tonic-gate
41*0Sstevel@tonic-gate=cut
42*0Sstevel@tonic-gate
43*0Sstevel@tonic-gatesub assert ($;$) {
44*0Sstevel@tonic-gate    my($assert, $name) = @_;
45*0Sstevel@tonic-gate
46*0Sstevel@tonic-gate    unless( $assert ) {
47*0Sstevel@tonic-gate        require Carp;
48*0Sstevel@tonic-gate        my $msg = 'Assert failed';
49*0Sstevel@tonic-gate        $msg .= " - '$name'" if defined $name;
50*0Sstevel@tonic-gate        $msg .= '!';
51*0Sstevel@tonic-gate        Carp::croak($msg);
52*0Sstevel@tonic-gate    }
53*0Sstevel@tonic-gate
54*0Sstevel@tonic-gate}
55*0Sstevel@tonic-gate
56*0Sstevel@tonic-gate=head1 AUTHOR
57*0Sstevel@tonic-gate
58*0Sstevel@tonic-gateMichael G Schwern C<< <schwern@pobox.com> >>
59*0Sstevel@tonic-gate
60*0Sstevel@tonic-gate=head1 SEE ALSO
61*0Sstevel@tonic-gate
62*0Sstevel@tonic-gateL<Carp::Assert>
63*0Sstevel@tonic-gate
64*0Sstevel@tonic-gate=cut
65*0Sstevel@tonic-gate
66*0Sstevel@tonic-gate1;
67