summaryrefslogtreecommitdiffstats
path: root/gnu/usr.bin/perl/cpan/Module-Load-Conditional/t/01_Module_Load_Conditional.t
diff options
context:
space:
mode:
authorafresh1 <afresh1@openbsd.org>2014-03-24 14:58:42 +0000
committerafresh1 <afresh1@openbsd.org>2014-03-24 14:58:42 +0000
commit91f110e064cd7c194e59e019b83bb7496c1c84d4 (patch)
tree3e8e577405dba7e94b43cbf21c22f21aaa5ab949 /gnu/usr.bin/perl/cpan/Module-Load-Conditional/t/01_Module_Load_Conditional.t
parentdo not call purge_task every 10 secs, it is only needed once at startup and (diff)
downloadwireguard-openbsd-91f110e064cd7c194e59e019b83bb7496c1c84d4.tar.xz
wireguard-openbsd-91f110e064cd7c194e59e019b83bb7496c1c84d4.zip
Import perl-5.18.2
OK espie@ sthen@ deraadt@
Diffstat (limited to 'gnu/usr.bin/perl/cpan/Module-Load-Conditional/t/01_Module_Load_Conditional.t')
-rwxr-xr-xgnu/usr.bin/perl/cpan/Module-Load-Conditional/t/01_Module_Load_Conditional.t97
1 files changed, 68 insertions, 29 deletions
diff --git a/gnu/usr.bin/perl/cpan/Module-Load-Conditional/t/01_Module_Load_Conditional.t b/gnu/usr.bin/perl/cpan/Module-Load-Conditional/t/01_Module_Load_Conditional.t
index 7a51266e6bb..99fa1fe72db 100755
--- a/gnu/usr.bin/perl/cpan/Module-Load-Conditional/t/01_Module_Load_Conditional.t
+++ b/gnu/usr.bin/perl/cpan/Module-Load-Conditional/t/01_Module_Load_Conditional.t
@@ -1,15 +1,15 @@
### Module::Load::Conditional test suite ###
### this should no longer be needed
-# BEGIN {
+# BEGIN {
# if( $ENV{PERL_CORE} ) {
-# chdir '../lib/Module/Load/Conditional'
+# chdir '../lib/Module/Load/Conditional'
# if -d '../lib/Module/Load/Conditional';
# unshift @INC, '../../../..';
-#
+#
# ### fix perl location too
# $^X = '../../../../../t/' . $^X;
# }
-# }
+# }
BEGIN { use FindBin; }
BEGIN { chdir 't' if -d 't' }
@@ -26,7 +26,7 @@ use lib File::Spec->catdir($FindBin::Bin, q[to_load] );
use_ok( 'Module::Load::Conditional' );
### stupid stupid warnings ###
-{ $Module::Load::Conditional::VERBOSE =
+{ $Module::Load::Conditional::VERBOSE =
$Module::Load::Conditional::VERBOSE = 0;
*can_load = *Module::Load::Conditional::can_load
@@ -44,10 +44,10 @@ use_ok( 'Module::Load::Conditional' );
);
ok( $rv->{uptodate}, q[Verify self] );
- is( $rv->{version}, $Module::Load::Conditional::VERSION,
+ is( $rv->{version}, $Module::Load::Conditional::VERSION,
q[ Found proper version] );
ok( $rv->{dir}, q[ Found directory information] );
-
+
{ my $dir = File::Spec->canonpath( $rv->{dir} );
### special rules apply on VMS, as always...
@@ -56,8 +56,8 @@ use_ok( 'Module::Load::Conditional' );
$dir = VMS::Filespec::pathify($dir);
### Remove the trailing VMS specific directory delimiter
$dir =~ s/\]//;
- }
-
+ }
+
### quote for Win32 paths, use | to avoid slash confusion
my $dir_re = qr|^\Q$dir\E|i;
like( File::Spec->canonpath( $rv->{file} ), $dir_re,
@@ -70,7 +70,7 @@ use_ok( 'Module::Load::Conditional' );
### Use the UNIX specific method, as the VMS one currently
### converts the file spec back to VMS format.
my $class = ON_VMS ? 'File::Spec::Unix' : 'File::Spec';
-
+
my($vol, $path, $file) = $class->splitpath( $rv->{'file'} );
my @path = ($vol, $class->splitdir( $path ), $file );
@@ -78,7 +78,7 @@ use_ok( 'Module::Load::Conditional' );
### First element could be blank for some system types like VMS
shift @path if $vol eq '';
- ### and return it
+ ### and return it
@path;
};
my $inc_path = $INC{'Module/Load/Conditional.pm'};
@@ -90,8 +90,8 @@ use_ok( 'Module::Load::Conditional' );
File::Spec::Unix->catfile(@rv_path),
q[ Found proper file]
);
-
-
+
+
}
@@ -132,33 +132,72 @@ use_ok( 'Module::Load::Conditional' );
is( $rv->{version}, 2, " Version is correct" );
}
+### test that no package statement means $VERSION is $main::VERSION
+{
+ my $rv = check_install( module => 'NotMain' );
+ ok( $rv, 'Testing $VERSION without package' );
+ is( $rv->{version}, undef, " No version info returned" );
+}
+
+### test that the right $VERSION is picked when there are several packages
+{
+ my $rv = check_install( module => 'NotX' );
+ ok( $rv, 'Testing $VERSION with many packages' );
+ ok( $rv->{version}, " Version found" );
+ is( $rv->{version}, 3, " Version is correct" );
+}
+
### test beta/developer release versions
{ my $test_ver = $Module::Load::Conditional::VERSION;
-
+
### strip beta tags
$test_ver =~ s/_\d+//g;
$test_ver .= '_99';
-
- my $rv = check_install(
- module => 'Module::Load::Conditional',
+
+ my $rv = check_install(
+ module => 'Module::Load::Conditional',
version => $test_ver,
);
ok( $rv, "Checking beta versions" );
ok( !$rv->{'uptodate'}, " Beta version is higher" );
-
-}
+
+}
### test $FIND_VERSION
-{ local $Module::Load::Conditional::FIND_VERSION = 0;
+{
local $Module::Load::Conditional::FIND_VERSION = 0;
-
+
my $rv = check_install( module => 'Module::Load::Conditional' );
ok( $rv, 'Testing $FIND_VERSION' );
is( $rv->{version}, undef, " No version info returned" );
ok( $rv->{uptodate}, " Module marked as uptodate" );
-}
+}
+
+### test that check_install() picks up the first match
+{
+ my ($dir_a, $dir_b) = map File::Spec->catdir($FindBin::Bin, 'test_lib', $_),
+ qw[a b];
+ my $x_pm = File::Spec->catfile($dir_a, 'X.pm');
+ $x_pm = VMS::Filespec::unixify($x_pm) if ON_VMS;
+
+ local @INC = ($dir_a, $dir_b);
+
+ my $rv = check_install( module => 'X' );
+
+ ok( $rv, 'Testing the file picked by check_install ($FIND_VERSION == 1)' );
+ is( $rv->{file}, $x_pm, " First file was picked" );
+ is( $rv->{version}, '0.01', " Correct version for first file" );
+
+ local $Module::Load::Conditional::FIND_VERSION = 0;
+
+ $rv = check_install( module => 'X' );
+
+ ok( $rv, 'Testing the file picked by check_install ($FIND_VERSION == 0)' );
+ is( $rv->{file}, $x_pm, " First file was also picked" );
+ is( $rv->{version}, undef, " But its VERSION was not required" );
+}
### test 'can_load' ###
@@ -198,11 +237,11 @@ use_ok( 'Module::Load::Conditional' );
### test 'requires' ###
SKIP:{
- skip "Depends on \$^X, which doesn't work well when testing the Perl core",
+ skip "Depends on \$^X, which doesn't work well when testing the Perl core",
1 if $ENV{PERL_CORE};
my %list = map { $_ => 1 } requires('Carp');
-
+
my $flag;
$flag++ unless delete $list{'Exporter'};
@@ -212,15 +251,15 @@ SKIP:{
### test using the %INC lookup for check_install
{ local $Module::Load::Conditional::CHECK_INC_HASH = 1;
local $Module::Load::Conditional::CHECK_INC_HASH = 1;
-
- { package A::B::C::D;
- $A::B::C::D::VERSION = $$;
+
+ { package A::B::C::D;
+ $A::B::C::D::VERSION = $$;
$INC{'A/B/C/D.pm'} = $$.$$;
-
+
### XXX this is no longer needed with M::Load 0.11_01
#$INC{'[.A.B.C]D.pm'} = $$.$$ if $^O eq 'VMS';
}
-
+
my $href = check_install( module => 'A::B::C::D', version => 0 );
ok( $href, 'Found package in %INC' );