Test-Expander

 view release on metacpan or  search on metacpan

lib/Test/Expander/Constants.pm  view on Meta::CPAN

package Test::Expander::Constants;

our $VERSION = '2.7.1';                                     ## no critic (RequireUseStrict, RequireUseWarnings)

use strict;
use warnings
  FATAL    => qw( all ),
  NONFATAL => qw( deprecated exec internal malloc newline once portable redefine recursion uninitialized );

use B                qw( svref_2object );
use Const::Fast;
use Exporter         qw( import );
use PadWalker        qw( peek_our );
use Scalar::Readonly qw( readonly_on );
use Test2::Tools::Basic;

readonly_on( $VERSION );

const our $COMMENT                     => '#';

const our $DIE                         => sub { die( sprintf( $_[ 0 ], @_[ 1 .. $#_ ] ) ) };

const our $EXCEPTION_PREFIX            => 'BEGIN failed--compilation aborted at ';

const our $FALSE                       => 0;

const our $FMT_INVALID_COLOR           => "Color '%s' requested for %s variables is not supported\n";
const our $FMT_INVALID_DIRECTORY       => "Invalid directory name / expression '%s' supplied with option '-lib'%s\n";
const our $FMT_INVALID_ENV_ENTRY       => "Erroneous line %d of '%s' containing '%s': %s\n";
const our $FMT_INVALID_VALUE           => "Option '%s' passed along with invalid value '%s'\n";
const our $FMT_INVALID_SUBTEST_NUMBER  => "\nInvalid subtest number: '%s'\n";
const our $FMT_KEEP_ENV_VAR            => "Keep environment variable '%s' containing '%s' because it is not reassigned in file '%s'";
const our $FMT_MISSING_TDT             => "Cannot read '%s' for table driven testing: %s\n";
const our $FMT_NEW_FAILED              => '%s->new died.%s';
const our $FMT_NEW_SUCCEEDED           => "An object of class '%s' isa '%s'";
const our $FMT_REPLACEMENT             => $EXCEPTION_PREFIX . '%s line %s.';
const our $FMT_REQUIRE_DESCRIPTION     => 'require %s;%s';
const our $FMT_REQUIRE_IMPLEMENTATION  => 'package %s; require %s';
const our $FMT_SEARCH_PATTERN          => $EXCEPTION_PREFIX . '.*$';
const our $FMT_SET_ENV_VAR             => "Set environment variable '%s' to '%s' from file '%s'";
const our $FMT_SET_TO                  => "Set %s to '%s'";
const our $FMT_SKIP_ENV_VAR            => "Skip environment variable '%s' because its value from file '%s' is undefined";
const our $FMT_UNKNOWN_OPTION          => "Unknown option '%s' => '%s' supplied.\n";
const our $FMT_UNSET_VAR               => "Read-only variable '%s' is not set and not imported";
const our $FMT_USE_DESCRIPTION         => 'use %s;%s';
const our $FMT_USE_IMPLEMENTATION      => 'package %s; use %s%s; 1';

const our $MSG_BAIL_OUT                => 'Test failed.';
const our $MSG_ERROR_WAS               => ' Error was: ';
const our $MSG_NO_TABLE_HEADER         => "No header of test table detected!\n";
const our $MSG_UNEXPECTED_EXCEPTION    => 'Unexpectedly caught exception: ';

const our $NOTE                        => sub { my ( $format, @args ) = @_; note( sprintf( $format, @args ) ) };

const our $REGEX_ANY_EXTENSION         => qr/ \. [^.]+ $/x;
const our $REGEX_CLASS_HIERARCHY_LEVEL => qr/^( \w+ ) (?: :: ( .+ ) )?/x;
const our $REGEX_TABLE_SEPARATOR       => qr/\s*\|\s*/;
const our $REGEX_TOP_DIR_IN_PATH       => qr{^ ( [^/]+ ) }x;
const our $REGEX_VERSION_NUMBER        => qr/^ \d+ (?: \. \d+ )* $/x;

const our $TRUE                        => 1;

const our @TEST2_V0_EXPORT             => qw{
  ok pass fail diag note todo skip
  plan skip_all done_testing bail_out
  intercept context
  gen_event
  def do_def
  cmp_ok
  warns warning warnings no_warnings
  subtest
  can_ok isa_ok DOES_ok
  set_encoding



( run in 0.570 second using v1.01-cache-2.11-cpan-39bf76dae61 )