This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[patch@31706]01_module_load_conditional.t fix for VMS
[perl5.git] / lib / Module / Load / Conditional / t / 01_Module_Load_Conditional.t
index f46fd9c..c741678 100644 (file)
@@ -16,10 +16,10 @@ use strict;
 use lib qw[../lib to_load];
 use File::Spec ();
 
-use Test::More tests => 20;
+use Test::More tests => 23;
 
 ### case 1 ###
-use_ok( 'Module::Load::Conditional' ) or diag "Module.pm not found.  Dying", die;
+use_ok( 'Module::Load::Conditional' );
 
 ### stupid stupid warnings ###
 {   $Module::Load::Conditional::VERBOSE =   
@@ -43,8 +43,24 @@ use_ok( 'Module::Load::Conditional' ) or diag "Module.pm not found.  Dying", die
     ok( $rv->{version} == $Module::Load::Conditional::VERSION,  
                             q[  Found proper version] );
 
+    # This test is expecting the file to in UNIX format, so force
+    $rv->{file} = VMS::Filespec::unixify($rv->{file}) if $^O eq 'VMS';
+
+    # break up the specification
+    my @rv_path;
+    if ($^O eq 'VMS') {
+       # Use the UNIX specific method, as the VMS one currently
+       # converts the file spec back to VMS format.
+       @rv_path = File::Spec::Unix->splitpath($rv->{file});
+    } else {
+       @rv_path = File::Spec->splitpath($rv->{file});
+    }
+
+    # First element could be blank for some system types like VMS
+    shift @rv_path if $rv_path[0] eq '';
+
     ok( $INC{'Module/Load/Conditional.pm'} eq
-        File::Spec::Unix->catfile(File::Spec->splitdir($rv->{file}) ),
+        File::Spec::Unix->catfile(@rv_path),
                             q[  Found proper file]
     );
 
@@ -78,7 +94,14 @@ use_ok( 'Module::Load::Conditional' ) or diag "Module.pm not found.  Dying", die
 
 }
 
-### test $FILE_VERSION
+### test finding a version of a module that mentions $VERSION in pod
+{   my $rv = check_install( module => 'InPod' );
+    ok( $rv,                        'Testing $VERSION in POD' );
+    ok( $rv->{version},             "   Version found" );
+    is( $rv->{version}, 2,          "   Version is correct" );
+}
+
+### test $FIND_VERSION
 {   local $Module::Load::Conditional::FIND_VERSION = 0;
     local $Module::Load::Conditional::FIND_VERSION = 0;
     
@@ -126,20 +149,18 @@ use_ok( 'Module::Load::Conditional' ) or diag "Module.pm not found.  Dying", die
 
 
 ### test 'requires' ###
-
 SKIP:{
     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 %list = map { $_ => 1 } requires('Carp');
+    
     my $flag;
     $flag++ unless delete $list{'Exporter'};
 
     ok( !$flag, q[Detecting requirements] );
 }
 
-
-
 ### test using the %INC lookup for check_install
 {   local $Module::Load::Conditional::CHECK_INC_HASH = 1;
     local $Module::Load::Conditional::CHECK_INC_HASH = 1;
@@ -147,6 +168,7 @@ SKIP:{
     {   package A::B::C::D; 
         $A::B::C::D::VERSION = $$; 
         $INC{'A/B/C/D.pm'}   = $$.$$;
+       $INC{'[.A.B.C]D.pm'} = $$.$$ if $^O eq 'VMS';
     }
     
     my $href = check_install( module => 'A::B::C::D', version => 0 );
@@ -159,4 +181,3 @@ SKIP:{
                                 '   can_load successful' );
 }
 
-