File Coverage

blib/lib/Repl/Spec/Type/NumberType.pm
Criterion Covered Total %
statement 21 23 91.3
branch 1 2 50.0
condition 1 3 33.3
subroutine 5 7 71.4
pod 0 3 0.0
total 28 38 73.6


line stmt bran cond sub pod time code
1             package Repl::Spec::Type::NumberType;
2            
3 1     1   6 use strict;
  1         1  
  1         39  
4 1     1   6 use warnings;
  1         2  
  1         29  
5 1     1   6 use Carp;
  1         1  
  1         264  
6            
7             # No arguments required.
8             sub new
9             {
10 1     1 0 3 my $invocant = shift;
11 1   33     5 my $class = ref($invocant) || $invocant;
12            
13 1         2 my $self= {};
14 1         50 return bless $self, $class;
15             }
16            
17             sub guard
18             {
19 102     102 0 110 my $self = shift;
20 102         102 my $arg = shift;
21            
22 102         116 my $test = $arg;
23 102         100 eval {
24 102     0   486 local $SIG{__WARN__} = sub {die $_[0]}; # Turn warnings into exceptions.
  0         0  
25 102         377 $test += 0;
26             };
27 102 50       215 croak sprintf("Expected type number but received '%s'.", $arg) if $@;
28 102         292 return $arg;
29             }
30            
31             sub name
32             {
33 0     0 0   return 'number';
34             }
35            
36             1;