File Coverage

blib/lib/WWW/Postini/Assert.pm
Criterion Covered Total %
statement 21 21 100.0
branch 4 6 66.6
condition 3 6 50.0
subroutine 6 6 100.0
pod 1 1 100.0
total 35 40 87.5


line stmt bran cond sub pod time code
1             package WWW::Postini::Assert;
2            
3 1     1   11 use strict;
  1         3  
  1         32  
4 1     1   5 use warnings;
  1         1  
  1         30  
5            
6 1     1   578 use WWW::Postini::Exception::AssertionFailure;
  1         3  
  1         29  
7 1     1   5 use Exporter;
  1         1  
  1         38  
8            
9 1     1   5 use vars qw( @ISA @EXPORT $VERSION );
  1         2  
  1         177  
10            
11             @ISA = qw( Exporter );
12             @EXPORT = qw( assert );
13             $VERSION = '0.01';
14            
15             sub assert {
16            
17 515     515 1 645 my $value = shift;
18 515 50       1091 my $description = shift if defined $_[0];
19            
20 515 100 66     2029 unless (defined $value && $value) {
21            
22 1 50 33     10 my $description = sprintf 'Assertion%sfailed',
23             defined $description && length $description ? " '$description' " : ' '
24             ;
25 1         15 throw WWW::Postini::Exception::AssertionFailure($description);
26            
27             }
28            
29 514         982 1;
30            
31             }
32            
33             1;
34            
35             __END__