[differences between cumulative patch application and perl5.004_01]
[p5sagit/p5-mst-13.2.git] / vms / ext / filespec.t
CommitLineData
acbb349e 1#!./perl
2
aa689395 3BEGIN { unshift(@INC,'../lib') if -d '../lib'; }
4
acbb349e 5use VMS::Filespec;
6
7foreach (<DATA>) {
8 chomp;
9 s/\s*#.*//;
10 next if /^\s*$/;
11 push(@tests,$_);
12}
740ce14c 13print '1..',scalar(@tests)+3,"\n";
acbb349e 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
28print +(rmsexpand('[]') eq "\U$ENV{DEFAULT}" ? 'ok ' : 'not ok '),++$idx,"\n";
740ce14c 29print +(rmsexpand('from.here') eq "\L$ENV{DEFAULT}from.here" ?
30 'ok ' : 'not ok '),++$idx,"\n";
31print +(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
37some:[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
53some/where/over/the.rainbow vmsify [.some.where.over]the.rainbow
54../some/where/over/the.rainbow vmsify [-.some.where.over]the.rainbow
55some/../../where/over/the.rainbow vmsify [-.where.over]the.rainbow
f86702cc 56.../some/where/over/the.rainbow vmsify [...some.where.over]the.rainbow
57some/.../where/over/the.rainbow vmsify [.some...where.over]the.rainbow
58/some/.../where/over/the.rainbow vmsify some:[...where.over]the.rainbow
59some/where/... vmsify [.some.where...]
60/where/... vmsify where:[...]
acbb349e 61. vmsify []
62.. vmsify [-]
63../.. vmsify [--]
f86702cc 64.../ vmsify [...]
acbb349e 65
66# Fileifying directory specs
67down:[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
71down/the/garden/path fileify down/the/garden/path.dir;1
72down:[the.garden]path fileify down:[the.garden]path.dir;1
73down:[the.garden]path. fileify # N.B. trailing . ==> null type
74down:[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
79down:[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/
82down/the/garden/path.dir pathify down/the/garden/path/
83down:[the.garden]path pathify down:[the.garden.path]
84down:[the.garden]path. pathify # N.B. trailing . ==> null type
85down:[the]garden.path pathify
86/down/the/garden/path. pathify # N.B. trailing . ==> null type
87/down/the/garden.path pathify
88down:[the.garden]path.dir;2 pathify #N.B. ;2
89path 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 93path.notdir pathify
94
95# Both VMS/Unix and file/path conversions
96down:[the.garden]path.dir;1 unixpath /down/the/garden/path/
97/down/the/garden/path vmspath down:[the.garden.path]
98down:[the.garden.path] unixpath /down/the/garden/path/
f86702cc 99down:[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/
102down/the/garden/path vmspath [.down.the.garden.path]
103path 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