File Coverage

blib/lib/Devel/Assert.pm
Criterion Covered Total %
statement 18 19 94.7
branch 8 8 100.0
condition 1 3 33.3
subroutine 4 5 80.0
pod 0 2 0.0
total 31 37 83.7


line stmt bran cond sub pod time code
1             package Devel::Assert;
2 5     5   39985 use strict;
  5         10  
  5         663  
3              
4             our $VERSION = '1.01';
5              
6             our $__ASSERT_GLOBAL = 0;
7              
8             require XSLoader;
9             XSLoader::load('Devel::Assert', $VERSION);
10              
11             sub import {
12 11     11   1942 my ($class, $arg) = @_;
13 11         30 my $caller = caller;
14              
15 11 100       149 $__ASSERT_GLOBAL = 1 if $arg eq 'global';
16              
17 11 100 33     73 my $ref = $arg eq 'off' || !$__ASSERT_GLOBAL && $arg ne 'on' ? \&assert_off : \&assert_on;
18             {
19 5     5   28 no strict 'refs';
  5         7  
  5         573  
  11         15  
20 11 100       13 *{"${caller}::assert"} = $ref if !defined *{"${caller}::assert"}{CODE};
  9         2780  
  11         2883  
21             }
22             }
23              
24             sub assert_on {
25 17 100   17 0 8236 unless ($_[0]) {
26 10         70 require Carp;
27 10         79 $Carp::Internal{'Devel::Assert'}++;
28 10         155 Carp::confess("Assertion failed");
29             }
30             }
31              
32 0     0 0   sub assert_off {}
33              
34             1;
35