| 1 | package Test::Run::Assert; | ||||||||||
| 2 | |||||||||||
| 3 | 15 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 15 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 15 | require Exporter; | |||||||||
| 7 | 15 | ▶ | use vars qw($VERSION @EXPORT @ISA); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 15 | $VERSION = '0.0306'; | |||||||||
| 10 | |||||||||||
| 11 | 15 | @ISA = qw(Exporter); | |||||||||
| 12 | 15 | @EXPORT = qw(assert); | |||||||||
| 13 | |||||||||||
| 14 | =head1 NAME | ||||||||||
| 15 | |||||||||||
| 16 | Test::Run::Assert - A Simple Assert Function. | ||||||||||
| 17 | |||||||||||
| 18 | =head1 SYNPOSIS | ||||||||||
| 19 | |||||||||||
| 20 | B<This module is only for internal use>. | ||||||||||
| 21 | |||||||||||
| 22 | use Test::Run::Assert; | ||||||||||
| 23 | |||||||||||
| 24 | assert ( EXPR , $name ); | ||||||||||
| 25 | |||||||||||
| 26 | =head1 EXPORTS | ||||||||||
| 27 | |||||||||||
| 28 | =head2 assert($condition, $name) | ||||||||||
| 29 | |||||||||||
| 30 | If condition is false - croak with the description $name. | ||||||||||
| 31 | |||||||||||
| 32 | =cut | ||||||||||
| 33 | |||||||||||
| 34 | sub assert($;$) | ||||||||||
| 35 | 16 | ▶ | { | ||||||||
|
Subroutine
assert: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 36 | 16 | my ($condition, $name) = @_; | |||||||||
| 37 | |||||||||||
| 38 | 16 | ▶ | if (! $condition) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | { | ||||||||||
| 40 | 1 | require Carp; | |||||||||
| 41 | |||||||||||
| 42 | 1 | my $msg = | |||||||||
| 43 | sprintf("Assert failed - '%s'!", $name) | ||||||||||
| 44 | ; | ||||||||||
| 45 | |||||||||||
| 46 | 1 | Carp::croak($msg); | |||||||||
| 47 | } | ||||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | =head1 AUTHOR | ||||||||||
| 51 | |||||||||||
| 52 | Originally written by: | ||||||||||
| 53 | |||||||||||
| 54 | Michael G Schwern C<< <schwern@pobox.com> >> | ||||||||||
| 55 | |||||||||||
| 56 | Rewritten as MIT-X11 Licensed code by: | ||||||||||
| 57 | |||||||||||
| 58 | Shlomi Fish L<http://www.shlomifish.org/> | ||||||||||
| 59 | |||||||||||
| 60 | =head1 COPYRIGHT | ||||||||||
| 61 | |||||||||||
| 62 | Copyright by Shlomi Fish, 2008. | ||||||||||
| 63 | |||||||||||
| 64 | =head1 LICENSE | ||||||||||
| 65 | |||||||||||
| 66 | This file is licensed under the MIT X11 License: | ||||||||||
| 67 | |||||||||||
| 68 | L<http://www.opensource.org/licenses/mit-license.php> | ||||||||||
| 69 | |||||||||||
| 70 | =cut | ||||||||||
| 71 | |||||||||||
| 72 | 15 | 1; | |||||||||
| 73 | |||||||||||