File Coverage

inc/My/Module/Test.pm
Criterion Covered Total %
statement 30 30 100.0
branch n/a
condition n/a
subroutine 10 10 100.0
pod 1 2 50.0
total 41 42 97.6


line stmt bran cond sub pod time code
1             package My::Module::Test;
2              
3 6     6   114 use 5.008001;
  6         14  
4              
5 6     6   19 use strict;
  6         6  
  6         82  
6 6     6   18 use warnings;
  6         6  
  6         258  
7              
8 6     6   22 use Carp qw{ croak };
  6         31  
  6         314  
9 6     6   22 use Exporter qw{ import };
  6         6  
  6         154  
10 6     6   20 use Test2::V0;
  6         14  
  6         46  
11 6     6   5759 use Test2::Util qw{ pkg_to_file };
  6         9  
  6         619  
12              
13             our $VERSION = '0.010';
14              
15             our @EXPORT_OK = qw{
16             build_skip_reason
17             cant_locate
18             CHECK_MISSING_INFO
19             $LOAD_ERROR_TEMPLATE
20             };
21              
22             # NOTE that if there are no diagnostics, info() returns undef, not an
23             # empty array. I find this nowhere documented, so I am checking for
24             # both.
25 6     6   69 use constant CHECK_MISSING_INFO => in_set( undef, array{ end; } );
  6         34  
  6         37  
  6         657  
26              
27             {
28             # We jump through these hoops because we do not want to have the
29             # test routines assume that the module under test can be loaded.
30              
31             my $code = eval {
32             require Test2::Tools::LoadModule;
33             Test2::Tools::LoadModule->can( '__build_load_eval' );
34             };
35              
36             sub build_skip_reason {
37 7     7 0 2660 my @arg = @_;
38 7         19 return sprintf 'Unable to %s', $code->( @arg );
39             }
40             }
41              
42             our $LOAD_ERROR_TEMPLATE = '%s';
43              
44             sub cant_locate {
45 4     4 1 975 my ( $module ) = @_;
46 4         14 my $fn = pkg_to_file( $module );
47 4         47 my $msg = sprintf $LOAD_ERROR_TEMPLATE, "Can't locate $fn in \@INC";
48 4         98 return match qr/ \A \Q$msg\E \b /smx;
49             }
50              
51             1;
52              
53             __END__