This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update Changes.
[perl5.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}
17f28c40 13print '1..',scalar(@tests)+6,"\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
17f28c40
CB
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.
33EOW
34
84902520
TB
35if (rmsexpand('[]') eq "\U$ENV{DEFAULT}") { print 'ok ',++$idx,"\n"; }
36else {
37 print 'not ok ', ++$idx, ": rmsexpand('[]') = |", rmsexpand('[]'),
17f28c40 38 "|, \$ENV{DEFAULT} = |\U$ENV{DEFAULT}|\n$defwarn";
84902520
TB
39}
40if (rmsexpand('from.here') eq "\L$ENV{DEFAULT}from.here") {
41 print 'ok ', ++$idx, "\n";
42}
43else {
44 print 'not ok ', ++$idx, ": rmsexpand('from.here') = |",
45 rmsexpand('from.here'),
17f28c40
CB
46 "|, \$ENV{DEFAULT}from.here = |\L$ENV{DEFAULT}from.here|\n$defwarn";
47}
48if (rmsexpand('from') eq "\L$ENV{DEFAULT}from") {
49 print 'ok ', ++$idx, "\n";
50}
51else {
52 print 'not ok ', ++$idx, ": rmsexpand('from') = |",
53 rmsexpand('from'),
54 "|, \$ENV{DEFAULT}from = |\L$ENV{DEFAULT}from|\n$defwarn";
84902520
TB
55}
56if (rmsexpand('from.here','cant:[get.there];2') eq
57 'cant:[get.there]from.here;2') { print 'ok ',++$idx,"\n"; }
58else {
59 print 'not ok ', ++$idx, ': expected |cant:[get.there]from.here;2|, got |',
60 rmsexpand('from.here','cant:[get.there];2'),"|\n";
61}
acbb349e 62
09b7f37c
CB
63# Make sure we're using redirected mkdir, which strips trailing '/', since
64# the CRTL's mkdir can't handle this.
65print +(mkdir('testdir/',0777) ? 'ok ' : 'not ok '),++$idx,"\n";
66print +(rmdir('testdir/') ? 'ok ' : 'not ok '),++$idx,"\n";
67
acbb349e 68__DATA__
69
70# Basic VMS to Unix filespecs
a3bd614a
PP
71some_logical_name_not_likely:[where.over]the.rainbow unixify /some_logical_name_not_likely/where/over/the.rainbow
72[.some_logical_name_not_likely.where.over]the.rainbow unixify some_logical_name_not_likely/where/over/the.rainbow
73[-.some_logical_name_not_likely.where.over]the.rainbow unixify ../some_logical_name_not_likely/where/over/the.rainbow
74[.some_logical_name_not_likely.--.where.over]the.rainbow unixify some_logical_name_not_likely/../../where/over/the.rainbow
75[.some_logical_name_not_likely...where.over]the.rainbow unixify some_logical_name_not_likely/.../where/over/the.rainbow
76[...some_logical_name_not_likely.where.over]the.rainbow unixify .../some_logical_name_not_likely/where/over/the.rainbow
77[.some_logical_name_not_likely.where.over...]the.rainbow unixify some_logical_name_not_likely/where/over/.../the.rainbow
78[.some_logical_name_not_likely.where.over...] unixify some_logical_name_not_likely/where/over/.../
79[.some_logical_name_not_likely.where.over.-] unixify some_logical_name_not_likely/where/over/../
acbb349e 80[] unixify ./
81[-] unixify ../
82[--] unixify ../../
f86702cc 83[...] unixify .../
acbb349e 84
85# and back again
a3bd614a
PP
86/some_logical_name_not_likely/where/over/the.rainbow vmsify some_logical_name_not_likely:[where.over]the.rainbow
87some_logical_name_not_likely/where/over/the.rainbow vmsify [.some_logical_name_not_likely.where.over]the.rainbow
88../some_logical_name_not_likely/where/over/the.rainbow vmsify [-.some_logical_name_not_likely.where.over]the.rainbow
89some_logical_name_not_likely/../../where/over/the.rainbow vmsify [-.where.over]the.rainbow
90.../some_logical_name_not_likely/where/over/the.rainbow vmsify [...some_logical_name_not_likely.where.over]the.rainbow
91some_logical_name_not_likely/.../where/over/the.rainbow vmsify [.some_logical_name_not_likely...where.over]the.rainbow
92/some_logical_name_not_likely/.../where/over/the.rainbow vmsify some_logical_name_not_likely:[...where.over]the.rainbow
93some_logical_name_not_likely/where/... vmsify [.some_logical_name_not_likely.where...]
f86702cc 94/where/... vmsify where:[...]
acbb349e 95. vmsify []
96.. vmsify [-]
97../.. vmsify [--]
f86702cc 98.../ vmsify [...]
491527d0 99/ vmsify sys$disk:[000000]
acbb349e 100
101# Fileifying directory specs
a3bd614a
PP
102down_logical_name_not_likely:[the.garden.path] fileify down_logical_name_not_likely:[the.garden]path.dir;1
103[.down_logical_name_not_likely.the.garden.path] fileify [.down_logical_name_not_likely.the.garden]path.dir;1
104/down_logical_name_not_likely/the/garden/path fileify /down_logical_name_not_likely/the/garden/path.dir;1
105/down_logical_name_not_likely/the/garden/path/ fileify /down_logical_name_not_likely/the/garden/path.dir;1
106down_logical_name_not_likely/the/garden/path fileify down_logical_name_not_likely/the/garden/path.dir;1
107down_logical_name_not_likely:[the.garden]path fileify down_logical_name_not_likely:[the.garden]path.dir;1
108down_logical_name_not_likely:[the.garden]path. fileify # N.B. trailing . ==> null type
109down_logical_name_not_likely:[the]garden.path fileify
110/down_logical_name_not_likely/the/garden/path. fileify # N.B. trailing . ==> null type
111/down_logical_name_not_likely/the/garden.path fileify
acbb349e 112
113# and pathifying them
a3bd614a
PP
114down_logical_name_not_likely:[the.garden]path.dir;1 pathify down_logical_name_not_likely:[the.garden.path]
115[.down_logical_name_not_likely.the.garden]path.dir pathify [.down_logical_name_not_likely.the.garden.path]
116/down_logical_name_not_likely/the/garden/path.dir pathify /down_logical_name_not_likely/the/garden/path/
117down_logical_name_not_likely/the/garden/path.dir pathify down_logical_name_not_likely/the/garden/path/
118down_logical_name_not_likely:[the.garden]path pathify down_logical_name_not_likely:[the.garden.path]
119down_logical_name_not_likely:[the.garden]path. pathify # N.B. trailing . ==> null type
120down_logical_name_not_likely:[the]garden.path pathify
121/down_logical_name_not_likely/the/garden/path. pathify # N.B. trailing . ==> null type
122/down_logical_name_not_likely/the/garden.path pathify
123down_logical_name_not_likely:[the.garden]path.dir;2 pathify #N.B. ;2
acbb349e 124path pathify path/
a3bd614a
PP
125/down_logical_name_not_likely/the/garden/. pathify /down_logical_name_not_likely/the/garden/./
126/down_logical_name_not_likely/the/garden/.. pathify /down_logical_name_not_likely/the/garden/../
127/down_logical_name_not_likely/the/garden/... pathify /down_logical_name_not_likely/the/garden/.../
acbb349e 128path.notdir pathify
129
130# Both VMS/Unix and file/path conversions
a3bd614a
PP
131down_logical_name_not_likely:[the.garden]path.dir;1 unixpath /down_logical_name_not_likely/the/garden/path/
132/down_logical_name_not_likely/the/garden/path vmspath down_logical_name_not_likely:[the.garden.path]
133down_logical_name_not_likely:[the.garden.path] unixpath /down_logical_name_not_likely/the/garden/path/
134down_logical_name_not_likely:[the.garden.path...] unixpath /down_logical_name_not_likely/the/garden/path/.../
135/down_logical_name_not_likely/the/garden/path.dir vmspath down_logical_name_not_likely:[the.garden.path]
136[.down_logical_name_not_likely.the.garden]path.dir unixpath down_logical_name_not_likely/the/garden/path/
137down_logical_name_not_likely/the/garden/path vmspath [.down_logical_name_not_likely.the.garden.path]
acbb349e 138path vmspath [.path]
491527d0 139/ vmspath sys$disk:[000000]
acbb349e 140
141# Redundant characters in Unix paths
a3bd614a
PP
142//some_logical_name_not_likely/where//over/../the.rainbow vmsify some_logical_name_not_likely:[where]the.rainbow
143/some_logical_name_not_likely/where//over/./the.rainbow vmsify some_logical_name_not_likely:[where.over]the.rainbow
acbb349e 144..//../ vmspath [--]
145./././ vmspath []
146./../. vmsify [-]
147