Test2-Tools-LoadModule
view release on metacpan or search on metacpan
inc/Test2/Plugin/INC_Jail.pm view on Meta::CPAN
unshift @INC, sub {
my $lvl = 0;
while ( my $pkg = caller $lvl ) {
if ( $test_class eq $pkg ) {
foreach my $dir ( @test_inc ) {
my $fh;
open $fh, '<', "$dir/$_[1]"
and return $] ge '5.020' ? ( \'', $fh ) : $fh;
}
croak "Can't locate $_[1] in \@INC";
}
# The reason we have to iterate if the package is our
# original caller is that the module under test might be
# loading the requested module on behalf of said caller by
# doing a stringy eval in the caller's name space.
$caller eq $pkg
or return;
lib/Test2/Tools/LoadModule.pm view on Meta::CPAN
package Test2::Tools::LoadModule;
use 5.008001;
use strict;
use warnings;
# OK, the following is probably paranoia. But if Perl 7 decides to
# change this particular default I'm ready. Unless they eliminate $].
no if $] ge '5.020', feature => qw{ signatures };
use Carp;
use Exporter 5.567; # Comes with Perl 5.8.1.
# use File::Find ();
# use File::Spec ();
# use Getopt::Long 2.34; # Comes with Perl 5.8.1.
use Test2::API 1.302096 ();
use Test2::API::Context 1.302096 (); # for pass_and_release().
use Test2::Util 1.302096 ();
lib/Test2/Tools/LoadModule.pm view on Meta::CPAN
use constant DEFAULT_LOAD_ERROR => '%s';
use constant ERR_IMPORT_BAD =>
'Import list must be an array reference, or undef';
use constant ERR_MODULE_UNDEF => 'Module name must be defined';
use constant ERR_OPTION_BAD => 'Bad option';
use constant ERR_SKIP_NUM_BAD =>
'Number of skipped tests must be an unsigned integer';
use constant ERR_VERSION_BAD => q/Version '%s' is invalid/;
use constant HINTS_AVAILABLE => $] ge '5.010';
# The following cribbed shamelessly from version::regex 0.9924,
# after being munged to suit by tools/version_regex 0.000_010.
# This technical debt is incurred to avoid having to require a version
# of the version module large enough to export the is_lax() subroutine.
use constant LAX_VERSION => qr/(?x: (?x:
v (?-x:[0-9]+) (?-x: (?-x:\.[0-9]+)+ (?-x:_[0-9]+)? )?
|
(?-x:[0-9]+)? (?-x:\.[0-9]+){2,} (?-x:_[0-9]+)?
) | (?x: (?-x:[0-9]+) (?-x: (?-x:\.[0-9]+) | \. )? (?-x:_[0-9]+)?
t/hint_hash.t view on Meta::CPAN
use strict;
use warnings;
use Test2::V0 -target => 'Test2::Tools::LoadModule';
use Test2::Tools::LoadModule qw{ :private };
BEGIN {
# We do this in a BEGIN block to prevent the compiler from seeing
# our 'use ...' statements unless we can actually run the tests.
$] lt '5.010'
and plan skip_all => "The hints mechanism does not work under Perl $]";
}
is __get_hint_hash( 0 ), {
load_error => DEFAULT_LOAD_ERROR,
}, 'Default hint hash';
{
my $load_error_error;
BEGIN { $load_error_error = 'Error: %s'; }
xt/author/version_re.t view on Meta::CPAN
use 5.008001;
use strict;
use warnings;
use Test2::V0 -target => 'Test2::Tools::LoadModule';
use Test2::Tools::LoadModule;
BEGIN {
$] ge '5.013006'
or plan skip_all => 'This test requires at least Perl 5.13.6.';
}
# Produced by tools/version_regex -dump
my $VAR1 = qr/ undef | (?^x:
v (?^:[0-9]+) (?: (?^:\.[0-9]+)+ (?^:_[0-9]+)? )?
|
(?^:[0-9]+)? (?^:\.[0-9]+){2,} (?^:_[0-9]+)?
) | (?^x: (?^:[0-9]+) (?: (?^:\.[0-9]+) | \. )? (?^:_[0-9]+)?
|
( run in 0.268 second using v1.01-cache-2.11-cpan-cc502c75498 )