File Coverage

blib/lib/Test/Expander/Constants.pm
Criterion Covered Total %
statement 24 24 100.0
branch n/a
condition n/a
subroutine 8 8 100.0
pod n/a
total 32 32 100.0


line stmt bran cond sub pod time code
1             package Test::Expander::Constants;
2              
3             our $VERSION = '2.1.5'; ## no critic (RequireUseStrict, RequireUseWarnings)
4              
5 17     17   1223 use strict;
  17         66  
  17         720  
6             use warnings
7 17         991 FATAL => qw( all ),
8 17     17   116 NONFATAL => qw( deprecated exec internal malloc newline portable recursion );
  17         36  
9              
10 17     17   116 use B qw( svref_2object );
  17         38  
  17         970  
11 17     17   1034 use Const::Fast;
  17         5314  
  17         201  
12 17     17   1350 use Exporter qw( import );
  17         53  
  17         724  
13 17     17   7666 use PadWalker qw( peek_our );
  17         11707  
  17         1062  
14 17     17   991 use Scalar::Readonly qw( readonly_on );
  17         1121  
  17         815  
15 17     17   1135 use Test2::Tools::Basic;
  17         152418  
  17         17423  
16              
17             readonly_on( $VERSION );
18              
19             const our $DIE => sub { die( sprintf( $_[ 0 ], @_[ 1 .. $#_ ] ) ) };
20              
21             const our $EXCEPTION_PREFIX => 'BEGIN failed--compilation aborted at ';
22              
23             const our $FALSE => 0;
24              
25             const our $FMT_INVALID_DIRECTORY => "Invalid directory name / expression '%s' supplied with option '-lib'%s\n";
26             const our $FMT_INVALID_ENV_ENTRY => "Erroneous line %d of '%s' containing '%s': %s\n";
27             const our $FMT_INVALID_VALUE => "Option '%s' passed along with invalid value '%s'\n";
28             const our $FMT_KEEP_ENV_VAR => "Keep environment variable '%s' containing '%s' because it is not reassigned in file '%s'";
29             const our $FMT_NEW_FAILED => '%s->new died.%s';
30             const our $FMT_NEW_SUCCEEDED => "An object of class '%s' isa '%s'";
31             const our $FMT_REPLACEMENT => $EXCEPTION_PREFIX . '%s line %s.';
32             const our $FMT_REQUIRE_DESCRIPTION => 'require %s;%s';
33             const our $FMT_REQUIRE_IMPLEMENTATION => 'package %s; require %s';
34             const our $FMT_SEARCH_PATTERN => $EXCEPTION_PREFIX . '.*$';
35             const our $FMT_SET_ENV_VAR => "Set environment variable '%s' to '%s' from file '%s'";
36             const our $FMT_SET_TO => "Set %s to '%s'";
37             const our $FMT_SKIP_ENV_VAR => "Skip environment variable '%s' because its value from file '%s' is undefined";
38             const our $FMT_UNKNOWN_OPTION => "Unknown option '%s' => '%s' supplied.\n";
39             const our $FMT_USE_DESCRIPTION => 'use %s;%s';
40             const our $FMT_USE_IMPLEMENTATION => 'package %s; use %s%s; 1';
41              
42             const our $MSG_ERROR_WAS => ' Error was: ';
43             const our $MSG_UNEXPECTED_EXCEPTION => 'Unexpectedly caught exception: ';
44              
45             const our $NOTE => sub { my ( $format, @args ) = @_; note( sprintf( $format, @args ) ) };
46              
47             const our $REGEX_ANY_EXTENSION => qr/ \. [^.]+ $/x;
48             const our $REGEX_CLASS_HIERARCHY_LEVEL => qr/^( \w+ ) (?: :: ( .+ ) )?/x;
49             const our $REGEX_TOP_DIR_IN_PATH => qr{^ ( [^/]+ ) }x;
50             const our $REGEX_VERSION_NUMBER => qr/^ \d+ (?: \. \d+ )* $/x;
51              
52             const our $TRUE => 1;
53              
54             const our %MOST_CONSTANTS_TO_EXPORT => (
55             '$CLASS' => sub { $_[ 0 ] },
56             '$TEMP_DIR' => sub { $_[ 0 ] },
57             '$TEMP_FILE' => sub { $_[ 0 ] },
58             '$TEST_FILE' => sub { $_[ 0 ] },
59             );
60             const our %REST_CONSTANTS_TO_EXPORT => (
61             '$METHOD' => sub { $_[ 0 ] },
62             '$METHOD_REF' => sub { '\&' . $_[ 1 ] . '::' . svref_2object( $_[ 0 ] )->GV->NAME },
63             );
64              
65             push( our @EXPORT_OK, keys( %{ peek_our( 0 ) } ) );
66              
67             1;