Commit | Line | Data |
acbb349e |
1 | #!./perl |
2 | |
aa689395 |
3 | BEGIN { unshift(@INC,'../lib') if -d '../lib'; } |
4 | |
acbb349e |
5 | use VMS::Filespec; |
6 | |
7 | foreach (<DATA>) { |
8 | chomp; |
9 | s/\s*#.*//; |
10 | next if /^\s*$/; |
11 | push(@tests,$_); |
12 | } |
740ce14c |
13 | print '1..',scalar(@tests)+3,"\n"; |
acbb349e |
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 | print +(rmsexpand('[]') eq "\U$ENV{DEFAULT}" ? 'ok ' : 'not ok '),++$idx,"\n"; |
740ce14c |
29 | print +(rmsexpand('from.here') eq "\L$ENV{DEFAULT}from.here" ? |
30 | 'ok ' : 'not ok '),++$idx,"\n"; |
31 | print +(rmsexpand('from.here','cant:[get.there];2') eq |
32 | 'cant:[get.there]from.here;2' ? 'ok ' : 'not ok '),++$idx,"\n"; |
acbb349e |
33 | |
34 | __DATA__ |
35 | |
36 | # Basic VMS to Unix filespecs |
37 | some:[where.over]the.rainbow unixify /some/where/over/the.rainbow |
38 | [.some.where.over]the.rainbow unixify some/where/over/the.rainbow |
39 | [-.some.where.over]the.rainbow unixify ../some/where/over/the.rainbow |
40 | [.some.--.where.over]the.rainbow unixify some/../../where/over/the.rainbow |
f86702cc |
41 | [.some...where.over]the.rainbow unixify some/.../where/over/the.rainbow |
42 | [...some.where.over]the.rainbow unixify .../some/where/over/the.rainbow |
43 | [.some.where.over...]the.rainbow unixify some/where/over/.../the.rainbow |
44 | [.some.where.over...] unixify some/where/over/.../ |
45 | [.some.where.over.-] unixify some/where/over/../ |
acbb349e |
46 | [] unixify ./ |
47 | [-] unixify ../ |
48 | [--] unixify ../../ |
f86702cc |
49 | [...] unixify .../ |
acbb349e |
50 | |
51 | # and back again |
52 | /some/where/over/the.rainbow vmsify some:[where.over]the.rainbow |
53 | some/where/over/the.rainbow vmsify [.some.where.over]the.rainbow |
54 | ../some/where/over/the.rainbow vmsify [-.some.where.over]the.rainbow |
55 | some/../../where/over/the.rainbow vmsify [-.where.over]the.rainbow |
f86702cc |
56 | .../some/where/over/the.rainbow vmsify [...some.where.over]the.rainbow |
57 | some/.../where/over/the.rainbow vmsify [.some...where.over]the.rainbow |
58 | /some/.../where/over/the.rainbow vmsify some:[...where.over]the.rainbow |
59 | some/where/... vmsify [.some.where...] |
60 | /where/... vmsify where:[...] |
acbb349e |
61 | . vmsify [] |
62 | .. vmsify [-] |
63 | ../.. vmsify [--] |
f86702cc |
64 | .../ vmsify [...] |
acbb349e |
65 | |
66 | # Fileifying directory specs |
67 | down:[the.garden.path] fileify down:[the.garden]path.dir;1 |
68 | [.down.the.garden.path] fileify [.down.the.garden]path.dir;1 |
69 | /down/the/garden/path fileify /down/the/garden/path.dir;1 |
70 | /down/the/garden/path/ fileify /down/the/garden/path.dir;1 |
71 | down/the/garden/path fileify down/the/garden/path.dir;1 |
72 | down:[the.garden]path fileify down:[the.garden]path.dir;1 |
73 | down:[the.garden]path. fileify # N.B. trailing . ==> null type |
74 | down:[the]garden.path fileify |
75 | /down/the/garden/path. fileify # N.B. trailing . ==> null type |
76 | /down/the/garden.path fileify |
77 | |
78 | # and pathifying them |
79 | down:[the.garden]path.dir;1 pathify down:[the.garden.path] |
80 | [.down.the.garden]path.dir pathify [.down.the.garden.path] |
81 | /down/the/garden/path.dir pathify /down/the/garden/path/ |
82 | down/the/garden/path.dir pathify down/the/garden/path/ |
83 | down:[the.garden]path pathify down:[the.garden.path] |
84 | down:[the.garden]path. pathify # N.B. trailing . ==> null type |
85 | down:[the]garden.path pathify |
86 | /down/the/garden/path. pathify # N.B. trailing . ==> null type |
87 | /down/the/garden.path pathify |
88 | down:[the.garden]path.dir;2 pathify #N.B. ;2 |
89 | path pathify path/ |
f86702cc |
90 | /down/the/garden/. pathify /down/the/garden/./ |
91 | /down/the/garden/.. pathify /down/the/garden/../ |
92 | /down/the/garden/... pathify /down/the/garden/.../ |
acbb349e |
93 | path.notdir pathify |
94 | |
95 | # Both VMS/Unix and file/path conversions |
96 | down:[the.garden]path.dir;1 unixpath /down/the/garden/path/ |
97 | /down/the/garden/path vmspath down:[the.garden.path] |
98 | down:[the.garden.path] unixpath /down/the/garden/path/ |
f86702cc |
99 | down:[the.garden.path...] unixpath /down/the/garden/path/.../ |
acbb349e |
100 | /down/the/garden/path.dir vmspath down:[the.garden.path] |
101 | [.down.the.garden]path.dir unixpath down/the/garden/path/ |
102 | down/the/garden/path vmspath [.down.the.garden.path] |
103 | path vmspath [.path] |
104 | |
105 | # Redundant characters in Unix paths |
740ce14c |
106 | //some/where//over/../the.rainbow vmsify some:[where]the.rainbow |
acbb349e |
107 | /some/where//over/./the.rainbow vmsify some:[where.over]the.rainbow |
108 | ..//../ vmspath [--] |
109 | ./././ vmspath [] |
110 | ./../. vmsify [-] |
111 | |