This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
more case tolerance for vms/ext/filespec.t
[perl5.git] / vms / ext / filespec.t
index 6201a42..6c099d9 100644 (file)
@@ -3,6 +3,7 @@
 BEGIN { unshift(@INC,'../lib') if -d '../lib'; }
 
 use VMS::Filespec;
+use File::Spec;
 
 foreach (<DATA>) {
   chomp;
@@ -10,124 +11,121 @@ foreach (<DATA>) {
   next if /^\s*$/;
   push(@tests,$_);
 }
-print '1..',scalar(@tests)+3,"\n";
+
+require './test.pl';
+plan(tests => scalar(2*@tests)+6);
 
 foreach $test (@tests) {
-  ($arg,$func,$expect) = split(/\t+/,$test);
-  $idx++;
+  ($arg,$func,$expect) = split(/\s+/,$test);
+
+  $expect = undef if $expect eq 'undef';
   $rslt = eval "$func('$arg')";
-  if ($@) { print "not ok $idx  : eval error: $@\n"; next; }
-  else {
-    if ($rslt ne $expect) {
-      print "not ok $idx  : $func('$arg') expected |$expect|, got |$rslt|\n";
-    }
-    else { print "ok $idx\n"; }
-  }
+  is($@, '', "eval ${func}('$arg')");
+  is(lc($rslt), lc($expect), "${func}('$arg'): '$rslt'");
 }
 
-if (rmsexpand('[]') eq "\U$ENV{DEFAULT}") { print 'ok ',++$idx,"\n"; }
-else {
-  print 'not ok ', ++$idx, ": rmsexpand('[]') = |", rmsexpand('[]'),
-        "|, \$ENV{DEFAULT} = |\U$ENV{DEFAULT}|\n";
-  print "# Note: This failure may have occurred because your default device\n";
-  print "# was set using a non-concealed logical name.  If this is the case,\n";
-  print "# you will need to determine by inspection that the two resultant\n";
-  print "# file specifications shwn above are in fact equivalent.\n";
-}
-if (rmsexpand('from.here') eq "\L$ENV{DEFAULT}from.here") {
-   print 'ok ', ++$idx, "\n";
-}
-else {
-  print 'not ok ', ++$idx, ": rmsexpand('from.here') = |",
-        rmsexpand('from.here'),
-        "|, \$ENV{DEFAULT}from.here = |\L$ENV{DEFAULT}from.here|\n";
-  print "# Note: This failure may have occurred because your default device\n";
-  print "# was set using a non-concealed logical name.  If this is the case,\n";
-  print "# you will need to determine by inspection that the two resultant\n";
-  print "# file specifications shwn above are in fact equivalent.\n";
-}
-if (rmsexpand('from.here','cant:[get.there];2') eq
-    'cant:[get.there]from.here;2')                 { print 'ok ',++$idx,"\n"; }
-else {
-  print 'not ok ', ++$idx, ': expected |cant:[get.there]from.here;2|, got |',
-        rmsexpand('from.here','cant:[get.there];2'),"|\n";
-}
+$defwarn = <<'EOW';
+# Note: This failure may have occurred because your default device
+# was set using a non-concealed logical name.  If this is the case,
+# you will need to determine by inspection that the two resultant
+# file specifications shown above are in fact equivalent.
+EOW
+
+is(uc(rmsexpand('[]')),   "\U$ENV{DEFAULT}", 'rmsexpand()') || print $defwarn;
+is(lc(rmsexpand('from.here')),"\L$ENV{DEFAULT}from.here") || print $defwarn;
+is(lc(rmsexpand('from')),     "\L$ENV{DEFAULT}from")      || print $defwarn;
+
+is(lc(rmsexpand('from.here','cant:[get.there];2')),
+   'cant:[get.there]from.here;2')                     || print $defwarn;
+
+
+# Make sure we're using redirected mkdir, which strips trailing '/', since
+# the CRTL's mkdir can't handle this.
+ok(mkdir('testdir/',0777),      'using redirected mkdir()');
+ok(rmdir('testdir/'),           '    rmdir()');
 
 __DATA__
 
+# lots of underscores used to minimize collision with existing logical names
+
 # Basic VMS to Unix filespecs
-some:[where.over]the.rainbow   unixify /some/where/over/the.rainbow
-[.some.where.over]the.rainbow  unixify some/where/over/the.rainbow
-[-.some.where.over]the.rainbow unixify ../some/where/over/the.rainbow
-[.some.--.where.over]the.rainbow       unixify some/../../where/over/the.rainbow
-[.some...where.over]the.rainbow        unixify some/.../where/over/the.rainbow
-[...some.where.over]the.rainbow        unixify .../some/where/over/the.rainbow
-[.some.where.over...]the.rainbow       unixify some/where/over/.../the.rainbow
-[.some.where.over...]  unixify some/where/over/.../
-[.some.where.over.-]   unixify some/where/over/../
+__some_:[__where_.__over_]__the_.__rainbow_    unixify /__some_/__where_/__over_/__the_.__rainbow_
+[.__some_.__where_.__over_]__the_.__rainbow_   unixify __some_/__where_/__over_/__the_.__rainbow_
+[-.__some_.__where_.__over_]__the_.__rainbow_  unixify ../__some_/__where_/__over_/__the_.__rainbow_
+[.__some_.--.__where_.__over_]__the_.__rainbow_        unixify __some_/../../__where_/__over_/__the_.__rainbow_
+[.__some_...__where_.__over_]__the_.__rainbow_ unixify __some_/.../__where_/__over_/__the_.__rainbow_
+[...__some_.__where_.__over_]__the_.__rainbow_ unixify .../__some_/__where_/__over_/__the_.__rainbow_
+[.__some_.__where_.__over_...]__the_.__rainbow_        unixify __some_/__where_/__over_/.../__the_.__rainbow_
+[.__some_.__where_.__over_...] unixify __some_/__where_/__over_/.../
+[.__some_.__where_.__over_.-]  unixify __some_/__where_/__over_/../
 []     unixify         ./
 [-]    unixify         ../
 [--]   unixify         ../../
 [...]  unixify         .../
 
 # and back again
-/some/where/over/the.rainbow   vmsify  some:[where.over]the.rainbow
-some/where/over/the.rainbow    vmsify  [.some.where.over]the.rainbow
-../some/where/over/the.rainbow vmsify  [-.some.where.over]the.rainbow
-some/../../where/over/the.rainbow      vmsify  [-.where.over]the.rainbow
-.../some/where/over/the.rainbow        vmsify  [...some.where.over]the.rainbow
-some/.../where/over/the.rainbow        vmsify  [.some...where.over]the.rainbow
-/some/.../where/over/the.rainbow       vmsify  some:[...where.over]the.rainbow
-some/where/... vmsify  [.some.where...]
-/where/...     vmsify  where:[...]
+/__some_/__where_/__over_/__the_.__rainbow_    vmsify  __some_:[__where_.__over_]__the_.__rainbow_
+__some_/__where_/__over_/__the_.__rainbow_     vmsify  [.__some_.__where_.__over_]__the_.__rainbow_
+../__some_/__where_/__over_/__the_.__rainbow_  vmsify  [-.__some_.__where_.__over_]__the_.__rainbow_
+__some_/../../__where_/__over_/__the_.__rainbow_       vmsify  [-.__where_.__over_]__the_.__rainbow_
+.../__some_/__where_/__over_/__the_.__rainbow_ vmsify  [...__some_.__where_.__over_]__the_.__rainbow_
+__some_/.../__where_/__over_/__the_.__rainbow_ vmsify  [.__some_...__where_.__over_]__the_.__rainbow_
+/__some_/.../__where_/__over_/__the_.__rainbow_        vmsify  __some_:[...__where_.__over_]__the_.__rainbow_
+__some_/__where_/...   vmsify  [.__some_.__where_...]
+/__where_/...  vmsify  __where_:[...]
 .      vmsify  []
 ..     vmsify  [-]
 ../..  vmsify  [--]
 .../   vmsify  [...]
+/      vmsify  sys$disk:[000000]
 
 # Fileifying directory specs
-down:[the.garden.path] fileify down:[the.garden]path.dir;1
-[.down.the.garden.path]        fileify [.down.the.garden]path.dir;1
-/down/the/garden/path  fileify /down/the/garden/path.dir;1
-/down/the/garden/path/ fileify /down/the/garden/path.dir;1
-down/the/garden/path   fileify down/the/garden/path.dir;1
-down:[the.garden]path  fileify down:[the.garden]path.dir;1
-down:[the.garden]path. fileify # N.B. trailing . ==> null type
-down:[the]garden.path  fileify 
-/down/the/garden/path. fileify # N.B. trailing . ==> null type
-/down/the/garden.path  fileify 
+__down_:[__the_.__garden_.__path_]     fileify __down_:[__the_.__garden_]__path_.dir;1
+[.__down_.__the_.__garden_.__path_]    fileify [.__down_.__the_.__garden_]__path_.dir;1
+/__down_/__the_/__garden_/__path_      fileify /__down_/__the_/__garden_/__path_.dir;1
+/__down_/__the_/__garden_/__path_/     fileify /__down_/__the_/__garden_/__path_.dir;1
+__down_/__the_/__garden_/__path_       fileify __down_/__the_/__garden_/__path_.dir;1
+__down_:[__the_.__garden_]__path_      fileify __down_:[__the_.__garden_]__path_.dir;1
+__down_:[__the_.__garden_]__path_.     fileify # N.B. trailing . ==> null type
+__down_:[__the_]__garden_.__path_      fileify undef
+/__down_/__the_/__garden_/__path_.     fileify # N.B. trailing . ==> null type
+/__down_/__the_/__garden_.__path_      fileify undef
 
 # and pathifying them
-down:[the.garden]path.dir;1    pathify down:[the.garden.path]
-[.down.the.garden]path.dir     pathify [.down.the.garden.path]
-/down/the/garden/path.dir      pathify /down/the/garden/path/
-down/the/garden/path.dir       pathify down/the/garden/path/
-down:[the.garden]path  pathify down:[the.garden.path]
-down:[the.garden]path. pathify # N.B. trailing . ==> null type
-down:[the]garden.path  pathify 
-/down/the/garden/path. pathify # N.B. trailing . ==> null type
-/down/the/garden.path  pathify 
-down:[the.garden]path.dir;2    pathify #N.B. ;2
-path   pathify path/
-/down/the/garden/.     pathify /down/the/garden/./
-/down/the/garden/..    pathify /down/the/garden/../
-/down/the/garden/...   pathify /down/the/garden/.../
-path.notdir    pathify 
+__down_:[__the_.__garden_]__path_.dir;1        pathify __down_:[__the_.__garden_.__path_]
+[.__down_.__the_.__garden_]__path_.dir pathify [.__down_.__the_.__garden_.__path_]
+/__down_/__the_/__garden_/__path_.dir  pathify /__down_/__the_/__garden_/__path_/
+__down_/__the_/__garden_/__path_.dir   pathify __down_/__the_/__garden_/__path_/
+__down_:[__the_.__garden_]__path_      pathify __down_:[__the_.__garden_.__path_]
+__down_:[__the_.__garden_]__path_.     pathify # N.B. trailing . ==> null type
+__down_:[__the_]__garden_.__path_      pathify undef
+/__down_/__the_/__garden_/__path_.     pathify # N.B. trailing . ==> null type
+/__down_/__the_/__garden_.__path_      pathify undef
+__down_:[__the_.__garden_]__path_.dir;2        pathify #N.B. ;2
+__path_        pathify __path_/
+/__down_/__the_/__garden_/.    pathify /__down_/__the_/__garden_/./
+/__down_/__the_/__garden_/..   pathify /__down_/__the_/__garden_/../
+/__down_/__the_/__garden_/...  pathify /__down_/__the_/__garden_/.../
+__path_.notdir pathify undef
 
 # Both VMS/Unix and file/path conversions
-down:[the.garden]path.dir;1    unixpath        /down/the/garden/path/
-/down/the/garden/path  vmspath down:[the.garden.path]
-down:[the.garden.path] unixpath        /down/the/garden/path/
-down:[the.garden.path...]      unixpath        /down/the/garden/path/.../
-/down/the/garden/path.dir      vmspath down:[the.garden.path]
-[.down.the.garden]path.dir     unixpath        down/the/garden/path/
-down/the/garden/path   vmspath [.down.the.garden.path]
-path   vmspath [.path]
+__down_:[__the_.__garden_]__path_.dir;1        unixpath        /__down_/__the_/__garden_/__path_/
+/__down_/__the_/__garden_/__path_      vmspath __down_:[__the_.__garden_.__path_]
+__down_:[__the_.__garden_.__path_]     unixpath        /__down_/__the_/__garden_/__path_/
+__down_:[__the_.__garden_.__path_...]  unixpath        /__down_/__the_/__garden_/__path_/.../
+/__down_/__the_/__garden_/__path_.dir  vmspath __down_:[__the_.__garden_.__path_]
+[.__down_.__the_.__garden_]__path_.dir unixpath        __down_/__the_/__garden_/__path_/
+__down_/__the_/__garden_/__path_       vmspath [.__down_.__the_.__garden_.__path_]
+__path_        vmspath [.__path_]
+/      vmspath sys$disk:[000000]
 
 # Redundant characters in Unix paths
-//some/where//over/../the.rainbow      vmsify  some:[where]the.rainbow
-/some/where//over/./the.rainbow        vmsify  some:[where.over]the.rainbow
+//__some_/__where_//__over_/../__the_.__rainbow_       vmsify  __some_:[__where_]__the_.__rainbow_
+/__some_/__where_//__over_/./__the_.__rainbow_ vmsify  __some_:[__where_.__over_]__the_.__rainbow_
 ..//../        vmspath [--]
 ./././ vmspath []
 ./../. vmsify  [-]
 
+# Our override of File::Spec->canonpath can do some strange things
+__dev:[__dir.000000]__foo     File::Spec->canonpath   __dev:[__dir.000000]__foo
+__dev:[__dir.][000000]__foo   File::Spec->canonpath   __dev:[__dir]__foo