source: trunk/third/perl/vms/ext/filespec.t @ 10724

Revision 10724, 5.1 KB checked in by ghudson, 27 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r10723, which included commits to RCS files with non-trunk default branches.
  • Property svn:executable set to *
Line 
1#!./perl
2
3BEGIN { unshift(@INC,'../lib') if -d '../lib'; }
4
5use VMS::Filespec;
6
7foreach (<DATA>) {
8  chomp;
9  s/\s*#.*//;
10  next if /^\s*$/;
11  push(@tests,$_);
12}
13print '1..',scalar(@tests)+3,"\n";
14
15foreach $test (@tests) {
16  ($arg,$func,$expect) = split(/\t+/,$test);
17  $idx++;
18  $rslt = eval "$func('$arg')";
19  if ($@) { print "not ok $idx  : eval error: $@\n"; next; }
20  else {
21    if ($rslt ne $expect) {
22      print "not ok $idx  : $func('$arg') expected |$expect|, got |$rslt|\n";
23    }
24    else { print "ok $idx\n"; }
25  }
26}
27
28if (rmsexpand('[]') eq "\U$ENV{DEFAULT}") { print 'ok ',++$idx,"\n"; }
29else {
30  print 'not ok ', ++$idx, ": rmsexpand('[]') = |", rmsexpand('[]'),
31        "|, \$ENV{DEFAULT} = |\U$ENV{DEFAULT}|\n";
32  print "# Note: This failure may have occurred because your default device\n";
33  print "# was set using a non-concealed logical name.  If this is the case,\n";
34  print "# you will need to determine by inspection that the two resultant\n";
35  print "# file specifications shwn above are in fact equivalent.\n";
36}
37if (rmsexpand('from.here') eq "\L$ENV{DEFAULT}from.here") {
38   print 'ok ', ++$idx, "\n";
39}
40else {
41  print 'not ok ', ++$idx, ": rmsexpand('from.here') = |",
42        rmsexpand('from.here'),
43        "|, \$ENV{DEFAULT}from.here = |\L$ENV{DEFAULT}from.here|\n";
44  print "# Note: This failure may have occurred because your default device\n";
45  print "# was set using a non-concealed logical name.  If this is the case,\n";
46  print "# you will need to determine by inspection that the two resultant\n";
47  print "# file specifications shwn above are in fact equivalent.\n";
48}
49if (rmsexpand('from.here','cant:[get.there];2') eq
50    'cant:[get.there]from.here;2')                 { print 'ok ',++$idx,"\n"; }
51else {
52  print 'not ok ', ++$idx, ': expected |cant:[get.there]from.here;2|, got |',
53        rmsexpand('from.here','cant:[get.there];2'),"|\n";
54}
55
56__DATA__
57
58# Basic VMS to Unix filespecs
59some:[where.over]the.rainbow    unixify /some/where/over/the.rainbow
60[.some.where.over]the.rainbow   unixify some/where/over/the.rainbow
61[-.some.where.over]the.rainbow  unixify ../some/where/over/the.rainbow
62[.some.--.where.over]the.rainbow        unixify some/../../where/over/the.rainbow
63[.some...where.over]the.rainbow unixify some/.../where/over/the.rainbow
64[...some.where.over]the.rainbow unixify .../some/where/over/the.rainbow
65[.some.where.over...]the.rainbow        unixify some/where/over/.../the.rainbow
66[.some.where.over...]   unixify some/where/over/.../
67[.some.where.over.-]    unixify some/where/over/../
68[]      unixify         ./
69[-]     unixify         ../
70[--]    unixify         ../../
71[...]   unixify         .../
72
73# and back again
74/some/where/over/the.rainbow    vmsify  some:[where.over]the.rainbow
75some/where/over/the.rainbow     vmsify  [.some.where.over]the.rainbow
76../some/where/over/the.rainbow  vmsify  [-.some.where.over]the.rainbow
77some/../../where/over/the.rainbow       vmsify  [-.where.over]the.rainbow
78.../some/where/over/the.rainbow vmsify  [...some.where.over]the.rainbow
79some/.../where/over/the.rainbow vmsify  [.some...where.over]the.rainbow
80/some/.../where/over/the.rainbow        vmsify  some:[...where.over]the.rainbow
81some/where/...  vmsify  [.some.where...]
82/where/...      vmsify  where:[...]
83.       vmsify  []
84..      vmsify  [-]
85../..   vmsify  [--]
86.../    vmsify  [...]
87
88# Fileifying directory specs
89down:[the.garden.path]  fileify down:[the.garden]path.dir;1
90[.down.the.garden.path] fileify [.down.the.garden]path.dir;1
91/down/the/garden/path   fileify /down/the/garden/path.dir;1
92/down/the/garden/path/  fileify /down/the/garden/path.dir;1
93down/the/garden/path    fileify down/the/garden/path.dir;1
94down:[the.garden]path   fileify down:[the.garden]path.dir;1
95down:[the.garden]path.  fileify # N.B. trailing . ==> null type
96down:[the]garden.path   fileify
97/down/the/garden/path.  fileify # N.B. trailing . ==> null type
98/down/the/garden.path   fileify
99
100# and pathifying them
101down:[the.garden]path.dir;1     pathify down:[the.garden.path]
102[.down.the.garden]path.dir      pathify [.down.the.garden.path]
103/down/the/garden/path.dir       pathify /down/the/garden/path/
104down/the/garden/path.dir        pathify down/the/garden/path/
105down:[the.garden]path   pathify down:[the.garden.path]
106down:[the.garden]path.  pathify # N.B. trailing . ==> null type
107down:[the]garden.path   pathify
108/down/the/garden/path.  pathify # N.B. trailing . ==> null type
109/down/the/garden.path   pathify
110down:[the.garden]path.dir;2     pathify #N.B. ;2
111path    pathify path/
112/down/the/garden/.      pathify /down/the/garden/./
113/down/the/garden/..     pathify /down/the/garden/../
114/down/the/garden/...    pathify /down/the/garden/.../
115path.notdir     pathify
116
117# Both VMS/Unix and file/path conversions
118down:[the.garden]path.dir;1     unixpath        /down/the/garden/path/
119/down/the/garden/path   vmspath down:[the.garden.path]
120down:[the.garden.path]  unixpath        /down/the/garden/path/
121down:[the.garden.path...]       unixpath        /down/the/garden/path/.../
122/down/the/garden/path.dir       vmspath down:[the.garden.path]
123[.down.the.garden]path.dir      unixpath        down/the/garden/path/
124down/the/garden/path    vmspath [.down.the.garden.path]
125path    vmspath [.path]
126
127# Redundant characters in Unix paths
128//some/where//over/../the.rainbow       vmsify  some:[where]the.rainbow
129/some/where//over/./the.rainbow vmsify  some:[where.over]the.rainbow
130..//../ vmspath [--]
131./././  vmspath []
132./../.  vmsify  [-]
133
Note: See TracBrowser for help on using the repository browser.