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.1'; ## no critic (RequireUseStrict, RequireUseWarnings)
4              
5 26     26   246528 use strict;
  26         55  
  26         2157  
6             use warnings
7 26         3763 FATAL => qw( all ),
8 26     26   227 NONFATAL => qw( deprecated exec internal malloc newline once portable redefine recursion uninitialized );
  26         55  
9              
10 26     26   217 use B qw( svref_2object );
  26         50  
  26         3813  
11 26     26   1249 use Const::Fast;
  26         6472  
  26         239  
12 26     26   2346 use Exporter qw( import );
  26         57  
  26         974  
13 26     26   12538 use PadWalker qw( peek_our );
  26         20718  
  26         2156  
14 26     26   1400 use Scalar::Readonly qw( readonly_on );
  26         1960  
  26         1436  
15 26     26   1206 use Test2::Tools::Basic;
  26         170881  
  26         37995  
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 @TEST2_V0_EXPORT => qw{
62             ok pass fail diag note todo skip
63             plan skip_all done_testing bail_out
64             intercept context
65             gen_event
66             def do_def
67             cmp_ok
68             warns warning warnings no_warnings
69             subtest
70             can_ok isa_ok DOES_ok
71             set_encoding
72             imported_ok not_imported_ok
73             ref_ok ref_is ref_is_not
74             mock mocked
75             dies lives try_ok
76             is like isnt unlike
77             match mismatch validator
78             hash array bag object meta meta_check number float rounded within string subset bool check_isa
79             number_lt number_le number_ge number_gt
80             in_set not_in_set check_set
81             item field call call_list call_hash prop check all_items all_keys all_vals all_values
82             etc end filter_items
83             T F D DF E DNE FDNE U L
84             event fail_events
85             exact_ref
86             is_refcount is_oneref refcount
87             };
88              
89             const our %COLORS => ( exported => 'cyan', unexported => 'magenta' );
90              
91             const our %MOST_CONSTANTS_TO_EXPORT => (
92             '$CLASS' => sub { $_[ 0 ] },
93             '$TEMP_DIR' => sub { $_[ 0 ] },
94             '$TEMP_FILE' => sub { $_[ 0 ] },
95             '$TEST_FILE' => sub { $_[ 0 ] },
96             );
97             const our %OPTION_PARSER => (
98             -bail => 1,
99             -builtins => 1,
100             -color => 1,
101             -lib => 1,
102             -method => 1,
103             -target => 1,
104             -tempdir => 1,
105             -tempfile => 1,
106             );
107             const our %REST_CONSTANTS_TO_EXPORT => (
108             '$METHOD' => sub { $_[ 0 ] },
109             '$METHOD_REF' => sub { '\&' . $_[ 1 ] . '::' . svref_2object( $_[ 0 ] )->GV->NAME },
110             );
111              
112             push( our @EXPORT_OK, keys( %{ peek_our( 0 ) } ) );
113              
114             1;