1 | #!./perl |
---|
2 | |
---|
3 | BEGIN { unshift(@INC,'../lib') if -d '../lib'; } |
---|
4 | |
---|
5 | use VMS::Filespec; |
---|
6 | |
---|
7 | foreach (<DATA>) { |
---|
8 | chomp; |
---|
9 | s/\s*#.*//; |
---|
10 | next if /^\s*$/; |
---|
11 | push(@tests,$_); |
---|
12 | } |
---|
13 | print '1..',scalar(@tests)+6,"\n"; |
---|
14 | |
---|
15 | foreach $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 | |
---|
28 | $defwarn = <<'EOW'; |
---|
29 | # Note: This failure may have occurred because your default device |
---|
30 | # was set using a non-concealed logical name. If this is the case, |
---|
31 | # you will need to determine by inspection that the two resultant |
---|
32 | # file specifications shwn above are in fact equivalent. |
---|
33 | EOW |
---|
34 | |
---|
35 | if (rmsexpand('[]') eq "\U$ENV{DEFAULT}") { print 'ok ',++$idx,"\n"; } |
---|
36 | else { |
---|
37 | print 'not ok ', ++$idx, ": rmsexpand('[]') = |", rmsexpand('[]'), |
---|
38 | "|, \$ENV{DEFAULT} = |\U$ENV{DEFAULT}|\n$defwarn"; |
---|
39 | } |
---|
40 | if (rmsexpand('from.here') eq "\L$ENV{DEFAULT}from.here") { |
---|
41 | print 'ok ', ++$idx, "\n"; |
---|
42 | } |
---|
43 | else { |
---|
44 | print 'not ok ', ++$idx, ": rmsexpand('from.here') = |", |
---|
45 | rmsexpand('from.here'), |
---|
46 | "|, \$ENV{DEFAULT}from.here = |\L$ENV{DEFAULT}from.here|\n$defwarn"; |
---|
47 | } |
---|
48 | if (rmsexpand('from') eq "\L$ENV{DEFAULT}from") { |
---|
49 | print 'ok ', ++$idx, "\n"; |
---|
50 | } |
---|
51 | else { |
---|
52 | print 'not ok ', ++$idx, ": rmsexpand('from') = |", |
---|
53 | rmsexpand('from'), |
---|
54 | "|, \$ENV{DEFAULT}from = |\L$ENV{DEFAULT}from|\n$defwarn"; |
---|
55 | } |
---|
56 | if (rmsexpand('from.here','cant:[get.there];2') eq |
---|
57 | 'cant:[get.there]from.here;2') { print 'ok ',++$idx,"\n"; } |
---|
58 | else { |
---|
59 | print 'not ok ', ++$idx, ': expected |cant:[get.there]from.here;2|, got |', |
---|
60 | rmsexpand('from.here','cant:[get.there];2'),"|\n"; |
---|
61 | } |
---|
62 | |
---|
63 | # Make sure we're using redirected mkdir, which strips trailing '/', since |
---|
64 | # the CRTL's mkdir can't handle this. |
---|
65 | print +(mkdir('testdir/',0777) ? 'ok ' : 'not ok '),++$idx,"\n"; |
---|
66 | print +(rmdir('testdir/') ? 'ok ' : 'not ok '),++$idx,"\n"; |
---|
67 | |
---|
68 | __DATA__ |
---|
69 | |
---|
70 | # Basic VMS to Unix filespecs |
---|
71 | some:[where.over]the.rainbow unixify /some/where/over/the.rainbow |
---|
72 | [.some.where.over]the.rainbow unixify some/where/over/the.rainbow |
---|
73 | [-.some.where.over]the.rainbow unixify ../some/where/over/the.rainbow |
---|
74 | [.some.--.where.over]the.rainbow unixify some/../../where/over/the.rainbow |
---|
75 | [.some...where.over]the.rainbow unixify some/.../where/over/the.rainbow |
---|
76 | [...some.where.over]the.rainbow unixify .../some/where/over/the.rainbow |
---|
77 | [.some.where.over...]the.rainbow unixify some/where/over/.../the.rainbow |
---|
78 | [.some.where.over...] unixify some/where/over/.../ |
---|
79 | [.some.where.over.-] unixify some/where/over/../ |
---|
80 | [] unixify ./ |
---|
81 | [-] unixify ../ |
---|
82 | [--] unixify ../../ |
---|
83 | [...] unixify .../ |
---|
84 | |
---|
85 | # and back again |
---|
86 | /some/where/over/the.rainbow vmsify some:[where.over]the.rainbow |
---|
87 | some/where/over/the.rainbow vmsify [.some.where.over]the.rainbow |
---|
88 | ../some/where/over/the.rainbow vmsify [-.some.where.over]the.rainbow |
---|
89 | some/../../where/over/the.rainbow vmsify [-.where.over]the.rainbow |
---|
90 | .../some/where/over/the.rainbow vmsify [...some.where.over]the.rainbow |
---|
91 | some/.../where/over/the.rainbow vmsify [.some...where.over]the.rainbow |
---|
92 | /some/.../where/over/the.rainbow vmsify some:[...where.over]the.rainbow |
---|
93 | some/where/... vmsify [.some.where...] |
---|
94 | /where/... vmsify where:[...] |
---|
95 | . vmsify [] |
---|
96 | .. vmsify [-] |
---|
97 | ../.. vmsify [--] |
---|
98 | .../ vmsify [...] |
---|
99 | / vmsify sys$disk:[000000] |
---|
100 | |
---|
101 | # Fileifying directory specs |
---|
102 | down:[the.garden.path] fileify down:[the.garden]path.dir;1 |
---|
103 | [.down.the.garden.path] fileify [.down.the.garden]path.dir;1 |
---|
104 | /down/the/garden/path fileify /down/the/garden/path.dir;1 |
---|
105 | /down/the/garden/path/ fileify /down/the/garden/path.dir;1 |
---|
106 | down/the/garden/path fileify down/the/garden/path.dir;1 |
---|
107 | down:[the.garden]path fileify down:[the.garden]path.dir;1 |
---|
108 | down:[the.garden]path. fileify # N.B. trailing . ==> null type |
---|
109 | down:[the]garden.path fileify |
---|
110 | /down/the/garden/path. fileify # N.B. trailing . ==> null type |
---|
111 | /down/the/garden.path fileify |
---|
112 | |
---|
113 | # and pathifying them |
---|
114 | down:[the.garden]path.dir;1 pathify down:[the.garden.path] |
---|
115 | [.down.the.garden]path.dir pathify [.down.the.garden.path] |
---|
116 | /down/the/garden/path.dir pathify /down/the/garden/path/ |
---|
117 | down/the/garden/path.dir pathify down/the/garden/path/ |
---|
118 | down:[the.garden]path pathify down:[the.garden.path] |
---|
119 | down:[the.garden]path. pathify # N.B. trailing . ==> null type |
---|
120 | down:[the]garden.path pathify |
---|
121 | /down/the/garden/path. pathify # N.B. trailing . ==> null type |
---|
122 | /down/the/garden.path pathify |
---|
123 | down:[the.garden]path.dir;2 pathify #N.B. ;2 |
---|
124 | path pathify path/ |
---|
125 | /down/the/garden/. pathify /down/the/garden/./ |
---|
126 | /down/the/garden/.. pathify /down/the/garden/../ |
---|
127 | /down/the/garden/... pathify /down/the/garden/.../ |
---|
128 | path.notdir pathify |
---|
129 | |
---|
130 | # Both VMS/Unix and file/path conversions |
---|
131 | down:[the.garden]path.dir;1 unixpath /down/the/garden/path/ |
---|
132 | /down/the/garden/path vmspath down:[the.garden.path] |
---|
133 | down:[the.garden.path] unixpath /down/the/garden/path/ |
---|
134 | down:[the.garden.path...] unixpath /down/the/garden/path/.../ |
---|
135 | /down/the/garden/path.dir vmspath down:[the.garden.path] |
---|
136 | [.down.the.garden]path.dir unixpath down/the/garden/path/ |
---|
137 | down/the/garden/path vmspath [.down.the.garden.path] |
---|
138 | path vmspath [.path] |
---|
139 | / vmspath sys$disk:[000000] |
---|
140 | |
---|
141 | # Redundant characters in Unix paths |
---|
142 | //some/where//over/../the.rainbow vmsify some:[where]the.rainbow |
---|
143 | /some/where//over/./the.rainbow vmsify some:[where.over]the.rainbow |
---|
144 | ..//../ vmspath [--] |
---|
145 | ./././ vmspath [] |
---|
146 | ./../. vmsify [-] |
---|
147 | |
---|