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.6.0'; ## no critic (RequireUseStrict, RequireUseWarnings)
4              
5 26     26   14756 use strict;
  26         51  
  26         1585  
6             use warnings
7 26         3720 FATAL => qw( all ),
8 26     26   153 NONFATAL => qw( deprecated exec internal malloc newline once portable redefine recursion uninitialized );
  26         47  
9              
10 26     26   199 use B qw( svref_2object );
  26         86  
  26         3892  
11 26     26   1385 use Const::Fast;
  26         7039  
  26         239  
12 26     26   2305 use Exporter qw( import );
  26         71  
  26         1107  
13 26     26   12580 use PadWalker qw( peek_our );
  26         20753  
  26         2037  
14 26     26   1189 use Scalar::Readonly qw( readonly_on );
  26         1562  
  26         1433  
15 26     26   1219 use Test2::Tools::Basic;
  26         215535  
  26         35466  
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_COLOR => "Color '%s' requested for %s variables is not supported\n";
26             const our $FMT_INVALID_DIRECTORY => "Invalid directory name / expression '%s' supplied with option '-lib'%s\n";
27             const our $FMT_INVALID_ENV_ENTRY => "Erroneous line %d of '%s' containing '%s': %s\n";
28             const our $FMT_INVALID_VALUE => "Option '%s' passed along with invalid value '%s'\n";
29             const our $FMT_INVALID_SUBTEST_NUMBER => "\nInvalid subtest number: '%s'\n";
30             const our $FMT_KEEP_ENV_VAR => "Keep environment variable '%s' containing '%s' because it is not reassigned in file '%s'";
31             const our $FMT_MISSING_TDT => "Cannot read '%s' for table driven testing: %s\n";
32             const our $FMT_NEW_FAILED => '%s->new died.%s';
33             const our $FMT_NEW_SUCCEEDED => "An object of class '%s' isa '%s'";
34             const our $FMT_REPLACEMENT => $EXCEPTION_PREFIX . '%s line %s.';
35             const our $FMT_REQUIRE_DESCRIPTION => 'require %s;%s';
36             const our $FMT_REQUIRE_IMPLEMENTATION => 'package %s; require %s';
37             const our $FMT_SEARCH_PATTERN => $EXCEPTION_PREFIX . '.*$';
38             const our $FMT_SET_ENV_VAR => "Set environment variable '%s' to '%s' from file '%s'";
39             const our $FMT_SET_TO => "Set %s to '%s'";
40             const our $FMT_SKIP_ENV_VAR => "Skip environment variable '%s' because its value from file '%s' is undefined";
41             const our $FMT_UNKNOWN_OPTION => "Unknown option '%s' => '%s' supplied.\n";
42             const our $FMT_UNSET_VAR => "Read-only variable '%s' is not set and not imported";
43             const our $FMT_USE_DESCRIPTION => 'use %s;%s';
44             const our $FMT_USE_IMPLEMENTATION => 'package %s; use %s%s; 1';
45              
46             const our $MSG_BAIL_OUT => 'Test failed.';
47             const our $MSG_ERROR_WAS => ' Error was: ';
48             const our $MSG_NO_TABLE_HEADER => "No header of test table detected!\n";
49             const our $MSG_UNEXPECTED_EXCEPTION => 'Unexpectedly caught exception: ';
50              
51             const our $NOTE => sub { my ( $format, @args ) = @_; note( sprintf( $format, @args ) ) };
52              
53             const our $REGEX_ANY_EXTENSION => qr/ \. [^.]+ $/x;
54             const our $REGEX_CLASS_HIERARCHY_LEVEL => qr/^( \w+ ) (?: :: ( .+ ) )?/x;
55             const our $REGEX_TABLE_SEPARATOR => qr/\s*\|\s*/;
56             const our $REGEX_TOP_DIR_IN_PATH => qr{^ ( [^/]+ ) }x;
57             const our $REGEX_VERSION_NUMBER => qr/^ \d+ (?: \. \d+ )* $/x;
58              
59             const our $TRUE => 1;
60              
61             const our %COLORS => ( exported => 'cyan', unexported => 'magenta' );
62              
63             const our %MOST_CONSTANTS_TO_EXPORT => (
64             '$CLASS' => sub { $_[ 0 ] },
65             '$TEMP_DIR' => sub { $_[ 0 ] },
66             '$TEMP_FILE' => sub { $_[ 0 ] },
67             '$TEST_FILE' => sub { $_[ 0 ] },
68             );
69             const our %OPTION_PARSER => (
70             -bail => 1,
71             -builtins => 1,
72             -color => 1,
73             -lib => 1,
74             -method => 1,
75             -target => 1,
76             -tempdir => 1,
77             -tempfile => 1,
78             );
79             const our %REST_CONSTANTS_TO_EXPORT => (
80             '$METHOD' => sub { $_[ 0 ] },
81             '$METHOD_REF' => sub { '\&' . $_[ 1 ] . '::' . svref_2object( $_[ 0 ] )->GV->NAME },
82             );
83              
84             push( our @EXPORT_OK, keys( %{ peek_our( 0 ) } ) );
85              
86             1;