source: trunk/essentials/dev-lang/perl/vms/ext/filespec.t@ 3186

Last change on this file since 3186 was 3181, checked in by bird, 19 years ago

perl 5.8.8

File size: 6.2 KB
Line 
1#!./perl
2
3BEGIN { unshift(@INC,'../lib') if -d '../lib'; }
4
5use VMS::Filespec;
6use File::Spec;
7
8foreach (<DATA>) {
9 chomp;
10 s/\s*#.*//;
11 next if /^\s*$/;
12 push(@tests,$_);
13}
14
15require './test.pl';
16plan(tests => scalar(2*@tests)+6);
17
18foreach $test (@tests) {
19 ($arg,$func,$expect) = split(/\s+/,$test);
20
21 $expect = undef if $expect eq 'undef';
22 $rslt = eval "$func('$arg')";
23 is($@, '', "eval ${func}('$arg')");
24 is($rslt, $expect, "${func}('$arg'): '$rslt'");
25}
26
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
31# file specifications shown above are in fact equivalent.
32EOW
33
34is(uc(rmsexpand('[]')), "\U$ENV{DEFAULT}", 'rmsexpand()') || print $defwarn;
35is(rmsexpand('from.here'),"\L$ENV{DEFAULT}from.here") || print $defwarn;
36is(rmsexpand('from'), "\L$ENV{DEFAULT}from") || print $defwarn;
37
38is(rmsexpand('from.here','cant:[get.there];2'),
39 'cant:[get.there]from.here;2') || print $defwarn;
40
41
42# Make sure we're using redirected mkdir, which strips trailing '/', since
43# the CRTL's mkdir can't handle this.
44ok(mkdir('testdir/',0777), 'using redirected mkdir()');
45ok(rmdir('testdir/'), ' rmdir()');
46
47__DATA__
48
49# lots of underscores used to minimize collision with existing logical names
50
51# Basic VMS to Unix filespecs
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_
56[.__some_...__where_.__over_]__the_.__rainbow_ unixify __some_/.../__where_/__over_/__the_.__rainbow_
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_/../
61[] unixify ./
62[-] unixify ../
63[--] unixify ../../
64[...] unixify .../
65
66# and back again
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_:[...]
76. vmsify []
77.. vmsify [-]
78../.. vmsify [--]
79.../ vmsify [...]