This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add tests for VMS-Unix file syntax conversion routines
[perl5.git] / vms / ext / filespec.t
CommitLineData
acbb349e 1#!./perl
2
3use VMS::Filespec;
4
5foreach (<DATA>) {
6 chomp;
7 s/\s*#.*//;
8 next if /^\s*$/;
9 push(@tests,$_);
10}
11print '1..',scalar(@tests)+1,"\n";
12
13foreach $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
26print +(rmsexpand('[]') eq "\U$ENV{DEFAULT}" ? 'ok ' : 'not ok '),++$idx,"\n";
27
28__DATA__
29
30# Basic VMS to Unix filespecs
31some:[where.over]the.rainbow unixify /some/where/over/the.rainbow
32[.some.where.over]the.rainbow unixify some/where/over/the.rainbow
33[-.some.where.over]the.rainbow unixify ../some/where/over/the.rainbow
34[.some.--.where.over]the.rainbow unixify some/../../where/over/the.rainbow
35[] unixify ./
36[-] unixify ../
37[--] unixify ../../
38
39# and back again
40/some/where/over/the.rainbow vmsify some:[where.over]the.rainbow
41some/where/over/the.rainbow vmsify [.some.where.over]the.rainbow
42../some/where/over/the.rainbow vmsify [-.some.where.over]the.rainbow
43some/../../where/over/the.rainbow vmsify [-.where.over]the.rainbow
44. vmsify []
45.. vmsify [-]
46../.. vmsify [--]
47
48# Fileifying directory specs
49down:[the.garden.path] fileify down:[the.garden]path.dir;1
50[.down.the.garden.path] fileify [.down.the.garden]path.dir;1
51/down/the/garden/path fileify /down/the/garden/path.dir;1
52/down/the/garden/path/ fileify /down/the/garden/path.dir;1
53down/the/garden/path fileify down/the/garden/path.dir;1
54down:[the.garden]path fileify down:[the.garden]path.dir;1
55down:[the.garden]path. fileify # N.B. trailing . ==> null type
56down:[the]garden.path fileify
57/down/the/garden/path. fileify # N.B. trailing . ==> null type
58/down/the/garden.path fileify
59
60# and pathifying them
61down:[the.garden]path.dir;1 pathify down:[the.garden.path]
62[.down.the.garden]path.dir pathify [.down.the.garden.path]
63/down/the/garden/path.dir pathify /down/the/garden/path/
64down/the/garden/path.dir pathify down/the/garden/path/
65down:[the.garden]path pathify down:[the.garden.path]
66down:[the.garden]path. pathify # N.B. trailing . ==> null type
67down:[the]garden.path pathify
68/down/the/garden/path. pathify # N.B. trailing . ==> null type
69/down/the/garden.path pathify
70down:[the.garden]path.dir;2 pathify #N.B. ;2
71path pathify path/
72path.notdir pathify
73
74# Both VMS/Unix and file/path conversions
75down:[the.garden]path.dir;1 unixpath /down/the/garden/path/
76/down/the/garden/path vmspath down:[the.garden.path]
77down:[the.garden.path] unixpath /down/the/garden/path/
78/down/the/garden/path.dir vmspath down:[the.garden.path]
79[.down.the.garden]path.dir unixpath down/the/garden/path/
80down/the/garden/path vmspath [.down.the.garden.path]
81path vmspath [.path]
82
83# Redundant characters in Unix paths
84/some/where//over/./the.rainbow vmsify some:[where.over]the.rainbow
85..//../ vmspath [--]
86./././ vmspath []
87./../. vmsify [-]
88