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.2.0'; ## no critic (RequireUseStrict, RequireUseWarnings)
4              
5 19     19   1263 use strict;
  19         53  
  19         755  
6             use warnings
7 19         1231 FATAL => qw( all ),
8 19     19   129 NONFATAL => qw( deprecated exec internal malloc newline portable recursion );
  19         52  
9              
10 19     19   128 use B qw( svref_2object );
  19         51  
  19         1175  
11 19     19   1018 use Const::Fast;
  19         5432  
  19         208  
12 19     19   1321 use Exporter qw( import );
  19         94  
  19         697  
13 19     19   8183 use PadWalker qw( peek_our );
  19         11751  
  19         1229  
14 19     19   1110 use Scalar::Readonly qw( readonly_on );
  19         1106  
  19         769  
15 19     19   1019 use Test2::Tools::Basic;
  19         150379  
  19         20002  
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_INVALID_SUBTEST_NUMBER => "\nInvalid subtest number: '%s'\n";
29             const our $FMT_KEEP_ENV_VAR => "Keep environment variable '%s' containing '%s' because it is not reassigned in file '%s'";
30             const our $FMT_NEW_FAILED => '%s->new died.%s';
31             const our $FMT_NEW_SUCCEEDED => "An object of class '%s' isa '%s'";
32             const our $FMT_REPLACEMENT => $EXCEPTION_PREFIX . '%s line %s.';
33             const our $FMT_REQUIRE_DESCRIPTION => 'require %s;%s';
34             const our $FMT_REQUIRE_IMPLEMENTATION => 'package %s; require %s';
35             const our $FMT_SEARCH_PATTERN => $EXCEPTION_PREFIX . '.*$';
36             const our $FMT_SET_ENV_VAR => "Set environment variable '%s' to '%s' from file '%s'";
37             const our $FMT_SET_TO => "Set %s to '%s'";
38             const our $FMT_SKIP_ENV_VAR => "Skip environment variable '%s' because its value from file '%s' is undefined";
39             const our $FMT_UNKNOWN_OPTION => "Unknown option '%s' => '%s' supplied.\n";
40             const our $FMT_USE_DESCRIPTION => 'use %s;%s';
41             const our $FMT_USE_IMPLEMENTATION => 'package %s; use %s%s; 1';
42              
43             const our $MSG_ERROR_WAS => ' Error was: ';
44             const our $MSG_UNEXPECTED_EXCEPTION => 'Unexpectedly caught exception: ';
45              
46             const our $NOTE => sub { my ( $format, @args ) = @_; note( sprintf( $format, @args ) ) };
47              
48             const our $REGEX_ANY_EXTENSION => qr/ \. [^.]+ $/x;
49             const our $REGEX_CLASS_HIERARCHY_LEVEL => qr/^( \w+ ) (?: :: ( .+ ) )?/x;
50             const our $REGEX_TOP_DIR_IN_PATH => qr{^ ( [^/]+ ) }x;
51             const our $REGEX_VERSION_NUMBER => qr/^ \d+ (?: \. \d+ )* $/x;
52              
53             const our $TRUE => 1;
54              
55             const our %MOST_CONSTANTS_TO_EXPORT => (
56             '$CLASS' => sub { $_[ 0 ] },
57             '$TEMP_DIR' => sub { $_[ 0 ] },
58             '$TEMP_FILE' => sub { $_[ 0 ] },
59             '$TEST_FILE' => sub { $_[ 0 ] },
60             );
61             const our %REST_CONSTANTS_TO_EXPORT => (
62             '$METHOD' => sub { $_[ 0 ] },
63             '$METHOD_REF' => sub { '\&' . $_[ 1 ] . '::' . svref_2object( $_[ 0 ] )->GV->NAME },
64             );
65              
66             push( our @EXPORT_OK, keys( %{ peek_our( 0 ) } ) );
67              
68             1;