Commit | Line | Data |
acbb349e |
1 | #!./perl |
2 | |
3 | use VMS::Filespec; |
4 | |
5 | foreach (<DATA>) { |
6 | chomp; |
7 | s/\s*#.*//; |
8 | next if /^\s*$/; |
9 | push(@tests,$_); |
10 | } |
740ce14c |
11 | print '1..',scalar(@tests)+3,"\n"; |
acbb349e |
12 | |
13 | foreach $test (@tests) { |
14 | ($arg,$func,$expect) = split(/\t+/,$test); |
15 | $idx++; |
16 | $rslt = eval "$func('$arg')"; |
17 | if ($@) { print "not ok $idx : eval error: $@\n"; next; } |
18 | else { |
19 | if ($rslt ne $expect) { |
20 | print "not ok $idx : $func('$arg') expected |$expect|, got |$rslt|\n"; |
21 | } |
22 | else { print "ok $idx\n"; } |
23 | } |
24 | } |
25 | |
26 | print +(rmsexpand('[]') eq "\U$ENV{DEFAULT}" ? 'ok ' : 'not ok '),++$idx,"\n"; |
740ce14c |
27 | print +(rmsexpand('from.here') eq "\L$ENV{DEFAULT}from.here" ? |
28 | 'ok ' : 'not ok '),++$idx,"\n"; |
29 | print +(rmsexpand('from.here','cant:[get.there];2') eq |
30 | 'cant:[get.there]from.here;2' ? 'ok ' : 'not ok '),++$idx,"\n"; |
acbb349e |
31 | |
32 | __DATA__ |
33 | |
34 | # Basic VMS to Unix filespecs |
35 | some:[where.over]the.rainbow unixify /some/where/over/the.rainbow |
36 | [.some.where.over]the.rainbow unixify some/where/over/the.rainbow |
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 | [] unixify ./ |
40 | [-] unixify ../ |
41 | [--] unixify ../../ |
42 | |
43 | # and back again |
44 | /some/where/over/the.rainbow vmsify some:[where.over]the.rainbow |
45 | some/where/over/the.rainbow vmsify [.some.where.over]the.rainbow |
46 | ../some/where/over/the.rainbow vmsify [-.some.where.over]the.rainbow |
47 | some/../../where/over/the.rainbow vmsify [-.where.over]the.rainbow |
48 | . vmsify [] |
49 | .. vmsify [-] |
50 | ../.. vmsify [--] |
51 | |
52 | # Fileifying directory specs |
53 | down:[the.garden.path] fileify down:[the.garden]path.dir;1 |
54 | [.down.the.garden.path] fileify [.down.the.garden]path.dir;1 |
55 | /down/the/garden/path fileify /down/the/garden/path.dir;1 |
56 | /down/the/garden/path/ fileify /down/the/garden/path.dir;1 |
57 | down/the/garden/path fileify down/the/garden/path.dir;1 |
58 | down:[the.garden]path fileify down:[the.garden]path.dir;1 |
59 | down:[the.garden]path. fileify # N.B. trailing . ==> null type |
60 | down:[the]garden.path fileify |
61 | /down/the/garden/path. fileify # N.B. trailing . ==> null type |
62 | /down/the/garden.path fileify |
63 | |
64 | # and pathifying them |
65 | down:[the.garden]path.dir;1 pathify down:[the.garden.path] |
66 | [.down.the.garden]path.dir pathify [.down.the.garden.path] |
67 | /down/the/garden/path.dir pathify /down/the/garden/path/ |
68 | down/the/garden/path.dir pathify down/the/garden/path/ |
69 | down:[the.garden]path pathify down:[the.garden.path] |
70 | down:[the.garden]path. pathify # N.B. trailing . ==> null type |
71 | down:[the]garden.path pathify |
72 | /down/the/garden/path. pathify # N.B. trailing . ==> null type |
73 | /down/the/garden.path pathify |
74 | down:[the.garden]path.dir;2 pathify #N.B. ;2 |
75 | path pathify path/ |
76 | path.notdir pathify |
77 | |
78 | # Both VMS/Unix and file/path conversions |
79 | down:[the.garden]path.dir;1 unixpath /down/the/garden/path/ |
80 | /down/the/garden/path vmspath down:[the.garden.path] |
81 | down:[the.garden.path] unixpath /down/the/garden/path/ |
82 | /down/the/garden/path.dir vmspath down:[the.garden.path] |
83 | [.down.the.garden]path.dir unixpath down/the/garden/path/ |
84 | down/the/garden/path vmspath [.down.the.garden.path] |
85 | path vmspath [.path] |
86 | |
87 | # Redundant characters in Unix paths |
740ce14c |
88 | //some/where//over/../the.rainbow vmsify some:[where]the.rainbow |
acbb349e |
89 | /some/where//over/./the.rainbow vmsify some:[where.over]the.rainbow |
90 | ..//../ vmspath [--] |
91 | ./././ vmspath [] |
92 | ./../. vmsify [-] |
93 | |