This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
more case tolerance for vms/ext/filespec.t
[perl5.git] / vms / ext / filespec.t
CommitLineData
acbb349e
PP
1#!./perl
2
aa689395
PP
3BEGIN { unshift(@INC,'../lib') if -d '../lib'; }
4
acbb349e 5use VMS::Filespec;
0e9538e6 6use File::Spec;
acbb349e
PP
7
8foreach (<DATA>) {
9 chomp;
10 s/\s*#.*//;
11 next if /^\s*$/;
12 push(@tests,$_);
13}
cd5cd3a3
MS
14
15require './test.pl';
16plan(tests => scalar(2*@tests)+6);
acbb349e
PP
17
18foreach $test (@tests) {
cd5cd3a3
MS
19 ($arg,$func,$expect) = split(/\s+/,$test);
20
9ba1b7d2 21 $expect = undef if $expect eq 'undef';
acbb349e 22 $rslt = eval "$func('$arg')";
9ba1b7d2 23 is($@, '', "eval ${func}('$arg')");
51078f7b 24 is(lc($rslt), lc($expect), "${func}('$arg'): '$rslt'");
acbb349e
PP
25}
26
17f28c40
CB
27$defwarn = <<'EOW';
28# Note: This failure may have occurred because your default device
29# was set using a non-concealed logical name. If this is the case,
30# you will need to determine by inspection that the two resultant
9ba1b7d2 31# file specifications shown above are in fact equivalent.
17f28c40
CB
32EOW
33
b4558e59 34is(uc(rmsexpand('[]')), "\U$ENV{DEFAULT}", 'rmsexpand()') || print $defwarn;
51078f7b
CB
35is(lc(rmsexpand('from.here')),"\L$ENV{DEFAULT}from.here") || print $defwarn;
36is(lc(rmsexpand('from')), "\L$ENV{DEFAULT}from") || print $defwarn;
cd5cd3a3 37
51078f7b 38is(lc(rmsexpand('from.here','cant:[get.there];2')),
cd5cd3a3
MS
39 'cant:[get.there]from.here;2') || print $defwarn;
40
acbb349e 41
09b7f37c
CB
42# Make sure we're using redirected mkdir, which strips trailing '/', since
43# the CRTL's mkdir can't handle this.
cd5cd3a3
MS
44ok(mkdir('testdir/',0777), 'using redirected mkdir()');
45ok(rmdir('testdir/'), ' rmdir()');
09b7f37c 46
acbb349e
PP
47__DATA__
48
0e9538e6
CB
49# lots of underscores used to minimize collision with existing logical names
50
acbb349e 51# Basic VMS to Unix filespecs
0e9538e6
CB
52__some_:[__where_.__over_]__the_.__rainbow_ unixify /__some_/__where_/__over_/__the_.__rainbow_
53[.__some_.__where_.__over_]__the_.__rainbow_ unixify __some_/__where_/__over_/__the_.__rainbow_
54[-.__some_.__where_.__over_]__the_.__rainbow_ unixify ../__some_/__where_/__over_/__the_.__rainbow_
55[.__some_.--.__where_.__over_]__the_.__rainbow_ unixify __some_/../../__where_/__over_/__the_.__rainbow_
7fc7512a 56[.__some_...__where_.__over_]__the_.__rainbow_ unixify __some_/.../__where_/__over_/__the_.__rainbow_
0e9538e6
CB
57[...__some_.__where_.__over_]__the_.__rainbow_ unixify .../__some_/__where_/__over_/__the_.__rainbow_
58[.__some_.__where_.__over_...]__the_.__rainbow_ unixify __some_/__where_/__over_/.../__the_.__rainbow_
59[.__some_.__where_.__over_...] unixify __some_/__where_/__over_/.../
60[.__some_.__where_.__over_.-] unixify __some_/__where_/__over_/../
acbb349e
PP
61[] unixify ./
62[-] unixify ../
63[--] unixify ../../
f86702cc 64[...] unixify .../
acbb349e
PP
65
66# and back again
0e9538e6
CB
67/__some_/__where_/__over_/__the_.__rainbow_ vmsify __some_:[__where_.__over_]__the_.__rainbow_
68__some_/__where_/__over_/__the_.__rainbow_ vmsify [.__some_.__where_.__over_]__the_.__rainbow_
69../__some_/__where_/__over_/__the_.__rainbow_ vmsify [-.__some_.__where_.__over_]__the_.__rainbow_
70__some_/../../__where_/__over_/__the_.__rainbow_ vmsify [-.__where_.__over_]__the_.__rainbow_
71.../__some_/__where_/__over_/__the_.__rainbow_ vmsify [...__some_.__where_.__over_]__the_.__rainbow_
72__some_/.../__where_/__over_/__the_.__rainbow_ vmsify [.__some_...__where_.__over_]__the_.__rainbow_
73/__some_/.../__where_/__over_/__the_.__rainbow_ vmsify __some_:[...__where_.__over_]__the_.__rainbow_
74__some_/__where_/... vmsify [.__some_.__where_...]
75/__where_/... vmsify __where_:[...]
acbb349e
PP
76. vmsify []
77.. vmsify [-]
78../.. vmsify [--]
f86702cc 79.../ vmsify [...]
491527d0 80/ vmsify sys$disk:[000000]
acbb349e
PP
81
82# Fileifying directory specs
0e9538e6
CB
83__down_:[__the_.__garden_.__path_] fileify __down_:[__the_.__garden_]__path_.dir;1
84[.__down_.__the_.__garden_.__path_] fileify [.__down_.__the_.__garden_]__path_.dir;1
85/__down_/__the_/__garden_/__path_ fileify /__down_/__the_/__garden_/__path_.dir;1
86/__down_/__the_/__garden_/__path_/ fileify /__down_/__the_/__garden_/__path_.dir;1
87__down_/__the_/__garden_/__path_ fileify __down_/__the_/__garden_/__path_.dir;1
88__down_:[__the_.__garden_]__path_ fileify __down_:[__the_.__garden_]__path_.dir;1
89__down_:[__the_.__garden_]__path_. fileify # N.B. trailing . ==> null type
9ba1b7d2 90__down_:[__the_]__garden_.__path_ fileify undef
0e9538e6 91/__down_/__the_/__garden_/__path_. fileify # N.B. trailing . ==> null type
9ba1b7d2 92/__down_/__the_/__garden_.__path_ fileify undef
acbb349e
PP
93
94# and pathifying them
0e9538e6
CB
95__down_:[__the_.__garden_]__path_.dir;1 pathify __down_:[__the_.__garden_.__path_]
96[.__down_.__the_.__garden_]__path_.dir pathify [.__down_.__the_.__garden_.__path_]
97/__down_/__the_/__garden_/__path_.dir pathify /__down_/__the_/__garden_/__path_/
98__down_/__the_/__garden_/__path_.dir pathify __down_/__the_/__garden_/__path_/
99__down_:[__the_.__garden_]__path_ pathify __down_:[__the_.__garden_.__path_]
100__down_:[__the_.__garden_]__path_. pathify # N.B. trailing . ==> null type
9ba1b7d2 101__down_:[__the_]__garden_.__path_ pathify undef
0e9538e6 102/__down_/__the_/__garden_/__path_. pathify # N.B. trailing . ==> null type
9ba1b7d2 103/__down_/__the_/__garden_.__path_ pathify undef
0e9538e6
CB
104__down_:[__the_.__garden_]__path_.dir;2 pathify #N.B. ;2
105__path_ pathify __path_/
106/__down_/__the_/__garden_/. pathify /__down_/__the_/__garden_/./
107/__down_/__the_/__garden_/.. pathify /__down_/__the_/__garden_/../
108/__down_/__the_/__garden_/... pathify /__down_/__the_/__garden_/.../
9ba1b7d2 109__path_.notdir pathify undef
acbb349e
PP
110
111# Both VMS/Unix and file/path conversions
0e9538e6
CB
112__down_:[__the_.__garden_]__path_.dir;1 unixpath /__down_/__the_/__garden_/__path_/
113/__down_/__the_/__garden_/__path_ vmspath __down_:[__the_.__garden_.__path_]
114__down_:[__the_.__garden_.__path_] unixpath /__down_/__the_/__garden_/__path_/
115__down_:[__the_.__garden_.__path_...] unixpath /__down_/__the_/__garden_/__path_/.../
116/__down_/__the_/__garden_/__path_.dir vmspath __down_:[__the_.__garden_.__path_]
117[.__down_.__the_.__garden_]__path_.dir unixpath __down_/__the_/__garden_/__path_/
118__down_/__the_/__garden_/__path_ vmspath [.__down_.__the_.__garden_.__path_]
119__path_ vmspath [.__path_]
491527d0 120/ vmspath sys$disk:[000000]
acbb349e
PP
121
122# Redundant characters in Unix paths
0e9538e6
CB
123//__some_/__where_//__over_/../__the_.__rainbow_ vmsify __some_:[__where_]__the_.__rainbow_
124/__some_/__where_//__over_/./__the_.__rainbow_ vmsify __some_:[__where_.__over_]__the_.__rainbow_
acbb349e
PP
125..//../ vmspath [--]
126./././ vmspath []
127./../. vmsify [-]
0e9538e6
CB
128
129# Our override of File::Spec->canonpath can do some strange things
78b110b0 130__dev:[__dir.000000]__foo File::Spec->canonpath __dev:[__dir.000000]__foo
0e9538e6 131__dev:[__dir.][000000]__foo File::Spec->canonpath __dev:[__dir]__foo