File Coverage

blib/lib/Net/ACME/X/OverloadBase.pm
Criterion Covered Total %
statement 23 23 100.0
branch 2 4 50.0
condition 2 3 66.6
subroutine 6 6 100.0
pod n/a
total 33 36 91.6


line stmt bran cond sub pod time code
1             package Net::ACME::X::OverloadBase;
2              
3 3     3   693 use strict;
  3         3  
  3         53  
4 3     3   10 use warnings;
  3         3  
  3         42  
5              
6 3     3   9 use Carp ();
  3         3  
  3         262  
7              
8             my %_OVERLOADED;
9              
10             sub _check_overload {
11 12     12   15 my ( $class, $str ) = @_;
12              
13             #cf. eval_bug.readme
14 12         11 my $eval_err = $@;
15              
16 3   66 3   10 $_OVERLOADED{$class} ||= eval qq{
  3         3  
  3         35  
  12         486  
17             package $class;
18             use overload (q<""> => __PACKAGE__->can('__spew'));
19             1;
20             };
21              
22             #Should never happen as long as overload.pm is available.
23 12 50       30 die if !$_OVERLOADED{$class};
24              
25 12         11 $@ = $eval_err;
26              
27 12         32 return;
28             }
29              
30             sub __spew {
31 29     30   3913 my ($self) = @_;
32              
33 29         67 my $spew = $self->to_string();
34              
35 29 50       76 if ( substr( $spew, -1 ) ne "\n" ) {
36 29         186 $spew .= Carp::longmess();
37             }
38              
39 29         10812 return $spew;
40             }
41              
42             1;