Commit | Line | Data |
---|---|---|
e021ab8e JH |
1 | #!/usr/bin/perl -w |
2 | ||
cba09117 NC |
3 | use strict; |
4 | use Test::More; | |
270d1e39 | 5 | |
cba09117 | 6 | require_ok('File::Spec'); |
2586ba89 | 7 | |
5b287435 | 8 | require Cwd; |
2586ba89 | 9 | |
ae5a807c JM |
10 | my $vms_unix_rpt; |
11 | my $vms_efs; | |
12 | ||
13 | if ($^O eq 'VMS') { | |
14 | if (eval 'require VMS::Feature') { | |
15 | $vms_unix_rpt = VMS::Feature::current("filename_unix_report"); | |
16 | $vms_efs = VMS::Feature::current("efs_charset"); | |
17 | } else { | |
18 | my $unix_rpt = $ENV{'DECC$FILENAME_UNIX_REPORT'} || ''; | |
19 | my $efs_charset = $ENV{'DECC$EFS_CHARSET'} || ''; | |
20 | $vms_unix_rpt = $unix_rpt =~ /^[ET1]/i; | |
21 | $vms_efs = $efs_charset =~ /^[ET1]/i; | |
22 | } | |
23 | } | |
24 | ||
25 | ||
2586ba89 JH |
26 | my $skip_exception = "Install VMS::Filespec (from vms/ext)" ; |
27 | ||
06ecd9c7 CB |
28 | eval { |
29 | require VMS::Filespec ; | |
30 | } ; | |
31 | ||
2586ba89 | 32 | if ( $@ ) { |
c4a6f826 | 33 | # Not pretty, but it allows testing of things not implemented solely |
2586ba89 JH |
34 | # on VMS. It might be better to change File::Spec::VMS to do this, |
35 | # making it more usable when running on (say) Unix but working with | |
36 | # VMS paths. | |
37 | eval qq- | |
38 | sub File::Spec::VMS::vmsify { die "$skip_exception" } | |
39 | sub File::Spec::VMS::unixify { die "$skip_exception" } | |
40 | sub File::Spec::VMS::vmspath { die "$skip_exception" } | |
41 | - ; | |
42 | $INC{"VMS/Filespec.pm"} = 1 ; | |
43 | } | |
2586ba89 | 44 | |
cba09117 NC |
45 | foreach (qw(Unix Win32 VMS OS2 Mac Epoc Cygwin)) { |
46 | require_ok("File::Spec::$_"); | |
47 | } | |
2586ba89 | 48 | |
0994714a GS |
49 | # Each element in this array is a single test. Storing them this way makes |
50 | # maintenance easy, and should be OK since perl should be pretty functional | |
51 | # before these tests are run. | |
3149a8e4 | 52 | |
cba09117 | 53 | my @tests = ( |
2586ba89 JH |
54 | # [ Function , Expected , Platform ] |
55 | ||
e021ab8e JH |
56 | [ "Unix->case_tolerant()", '0' ], |
57 | ||
02961b52 MS |
58 | [ "Unix->catfile('a','b','c')", 'a/b/c' ], |
59 | [ "Unix->catfile('a','b','./c')", 'a/b/c' ], | |
60 | [ "Unix->catfile('./a','b','c')", 'a/b/c' ], | |
61 | [ "Unix->catfile('c')", 'c' ], | |
62 | [ "Unix->catfile('./c')", 'c' ], | |
270d1e39 | 63 | |
0994714a GS |
64 | [ "Unix->splitpath('file')", ',,file' ], |
65 | [ "Unix->splitpath('/d1/d2/d3/')", ',/d1/d2/d3/,' ], | |
66 | [ "Unix->splitpath('d1/d2/d3/')", ',d1/d2/d3/,' ], | |
67 | [ "Unix->splitpath('/d1/d2/d3/.')", ',/d1/d2/d3/.,' ], | |
68 | [ "Unix->splitpath('/d1/d2/d3/..')", ',/d1/d2/d3/..,' ], | |
69 | [ "Unix->splitpath('/d1/d2/d3/.file')", ',/d1/d2/d3/,.file' ], | |
70 | [ "Unix->splitpath('d1/d2/d3/file')", ',d1/d2/d3/,file' ], | |
71 | [ "Unix->splitpath('/../../d1/')", ',/../../d1/,' ], | |
72 | [ "Unix->splitpath('/././d1/')", ',/././d1/,' ], | |
270d1e39 | 73 | |
0994714a GS |
74 | [ "Unix->catpath('','','file')", 'file' ], |
75 | [ "Unix->catpath('','/d1/d2/d3/','')", '/d1/d2/d3/' ], | |
76 | [ "Unix->catpath('','d1/d2/d3/','')", 'd1/d2/d3/' ], | |
77 | [ "Unix->catpath('','/d1/d2/d3/.','')", '/d1/d2/d3/.' ], | |
78 | [ "Unix->catpath('','/d1/d2/d3/..','')", '/d1/d2/d3/..' ], | |
79 | [ "Unix->catpath('','/d1/d2/d3/','.file')", '/d1/d2/d3/.file' ], | |
80 | [ "Unix->catpath('','d1/d2/d3/','file')", 'd1/d2/d3/file' ], | |
81 | [ "Unix->catpath('','/../../d1/','')", '/../../d1/' ], | |
82 | [ "Unix->catpath('','/././d1/','')", '/././d1/' ], | |
83 | [ "Unix->catpath('d1','d2/d3/','')", 'd2/d3/' ], | |
84 | [ "Unix->catpath('d1','d2','d3/')", 'd2/d3/' ], | |
270d1e39 | 85 | |
0994714a GS |
86 | [ "Unix->splitdir('')", '' ], |
87 | [ "Unix->splitdir('/d1/d2/d3/')", ',d1,d2,d3,' ], | |
88 | [ "Unix->splitdir('d1/d2/d3/')", 'd1,d2,d3,' ], | |
89 | [ "Unix->splitdir('/d1/d2/d3')", ',d1,d2,d3' ], | |
90 | [ "Unix->splitdir('d1/d2/d3')", 'd1,d2,d3' ], | |
270d1e39 | 91 | |
0994714a | 92 | [ "Unix->catdir()", '' ], |
ae5a807c | 93 | [ "Unix->catdir('')", '/' ], |
0994714a GS |
94 | [ "Unix->catdir('/')", '/' ], |
95 | [ "Unix->catdir('','d1','d2','d3','')", '/d1/d2/d3' ], | |
96 | [ "Unix->catdir('d1','d2','d3','')", 'd1/d2/d3' ], | |
97 | [ "Unix->catdir('','d1','d2','d3')", '/d1/d2/d3' ], | |
98 | [ "Unix->catdir('d1','d2','d3')", 'd1/d2/d3' ], | |
ff235dd6 | 99 | [ "Unix->catdir('/','d2/d3')", '/d2/d3' ], |
0994714a | 100 | |
0994714a | 101 | [ "Unix->canonpath('///../../..//./././a//b/.././c/././')", '/a/b/../c' ], |
9596c75c RGS |
102 | [ "Unix->canonpath('')", '' ], |
103 | # rt.perl.org 27052 | |
104 | [ "Unix->canonpath('a/../../b/c')", 'a/../../b/c' ], | |
105 | [ "Unix->canonpath('/.')", '/' ], | |
106 | [ "Unix->canonpath('/./')", '/' ], | |
107 | [ "Unix->canonpath('/a/./')", '/a' ], | |
108 | [ "Unix->canonpath('/a/.')", '/a' ], | |
109 | [ "Unix->canonpath('/../../')", '/' ], | |
110 | [ "Unix->canonpath('/../..')", '/' ], | |
0994714a | 111 | |
9d5071ba | 112 | [ "Unix->abs2rel('/t1/t2/t3','/t1/t2/t3')", '.' ], |
0994714a GS |
113 | [ "Unix->abs2rel('/t1/t2/t4','/t1/t2/t3')", '../t4' ], |
114 | [ "Unix->abs2rel('/t1/t2','/t1/t2/t3')", '..' ], | |
115 | [ "Unix->abs2rel('/t1/t2/t3/t4','/t1/t2/t3')", 't4' ], | |
116 | [ "Unix->abs2rel('/t4/t5/t6','/t1/t2/t3')", '../../../t4/t5/t6' ], | |
117 | #[ "Unix->abs2rel('../t4','/t1/t2/t3')", '../t4' ], | |
118 | [ "Unix->abs2rel('/','/t1/t2/t3')", '../../..' ], | |
119 | [ "Unix->abs2rel('///','/t1/t2/t3')", '../../..' ], | |
6bf11762 | 120 | [ "Unix->abs2rel('/.','/t1/t2/t3')", '../../..' ], |
0994714a GS |
121 | [ "Unix->abs2rel('/./','/t1/t2/t3')", '../../..' ], |
122 | #[ "Unix->abs2rel('../t4','/t1/t2/t3')", '../t4' ], | |
ff235dd6 SP |
123 | [ "Unix->abs2rel('/t1/t2/t3', '/')", 't1/t2/t3' ], |
124 | [ "Unix->abs2rel('/t1/t2/t3', '/t1')", 't2/t3' ], | |
c47834cd RGS |
125 | [ "Unix->abs2rel('t1/t2/t3', 't1')", 't2/t3' ], |
126 | [ "Unix->abs2rel('t1/t2/t3', 't4')", '../t1/t2/t3' ], | |
0994714a GS |
127 | |
128 | [ "Unix->rel2abs('t4','/t1/t2/t3')", '/t1/t2/t3/t4' ], | |
129 | [ "Unix->rel2abs('t4/t5','/t1/t2/t3')", '/t1/t2/t3/t4/t5' ], | |
130 | [ "Unix->rel2abs('.','/t1/t2/t3')", '/t1/t2/t3' ], | |
131 | [ "Unix->rel2abs('..','/t1/t2/t3')", '/t1/t2/t3/..' ], | |
132 | [ "Unix->rel2abs('../t4','/t1/t2/t3')", '/t1/t2/t3/../t4' ], | |
133 | [ "Unix->rel2abs('/t1','/t1/t2/t3')", '/t1' ], | |
134 | ||
e021ab8e | 135 | [ "Win32->case_tolerant()", '1' ], |
60598624 | 136 | [ "Win32->rootdir()", '\\' ], |
e021ab8e | 137 | |
0994714a GS |
138 | [ "Win32->splitpath('file')", ',,file' ], |
139 | [ "Win32->splitpath('\\d1/d2\\d3/')", ',\\d1/d2\\d3/,' ], | |
140 | [ "Win32->splitpath('d1/d2\\d3/')", ',d1/d2\\d3/,' ], | |
141 | [ "Win32->splitpath('\\d1/d2\\d3/.')", ',\\d1/d2\\d3/.,' ], | |
142 | [ "Win32->splitpath('\\d1/d2\\d3/..')", ',\\d1/d2\\d3/..,' ], | |
143 | [ "Win32->splitpath('\\d1/d2\\d3/.file')", ',\\d1/d2\\d3/,.file' ], | |
144 | [ "Win32->splitpath('\\d1/d2\\d3/file')", ',\\d1/d2\\d3/,file' ], | |
145 | [ "Win32->splitpath('d1/d2\\d3/file')", ',d1/d2\\d3/,file' ], | |
146 | [ "Win32->splitpath('C:\\d1/d2\\d3/')", 'C:,\\d1/d2\\d3/,' ], | |
147 | [ "Win32->splitpath('C:d1/d2\\d3/')", 'C:,d1/d2\\d3/,' ], | |
148 | [ "Win32->splitpath('C:\\d1/d2\\d3/file')", 'C:,\\d1/d2\\d3/,file' ], | |
149 | [ "Win32->splitpath('C:d1/d2\\d3/file')", 'C:,d1/d2\\d3/,file' ], | |
150 | [ "Win32->splitpath('C:\\../d2\\d3/file')", 'C:,\\../d2\\d3/,file' ], | |
151 | [ "Win32->splitpath('C:../d2\\d3/file')", 'C:,../d2\\d3/,file' ], | |
152 | [ "Win32->splitpath('\\../..\\d1/')", ',\\../..\\d1/,' ], | |
153 | [ "Win32->splitpath('\\./.\\d1/')", ',\\./.\\d1/,' ], | |
154 | [ "Win32->splitpath('\\\\node\\share\\d1/d2\\d3/')", '\\\\node\\share,\\d1/d2\\d3/,' ], | |
155 | [ "Win32->splitpath('\\\\node\\share\\d1/d2\\d3/file')", '\\\\node\\share,\\d1/d2\\d3/,file' ], | |
156 | [ "Win32->splitpath('\\\\node\\share\\d1/d2\\file')", '\\\\node\\share,\\d1/d2\\,file' ], | |
157 | [ "Win32->splitpath('file',1)", ',file,' ], | |
158 | [ "Win32->splitpath('\\d1/d2\\d3/',1)", ',\\d1/d2\\d3/,' ], | |
159 | [ "Win32->splitpath('d1/d2\\d3/',1)", ',d1/d2\\d3/,' ], | |
160 | [ "Win32->splitpath('\\\\node\\share\\d1/d2\\d3/',1)", '\\\\node\\share,\\d1/d2\\d3/,' ], | |
161 | ||
162 | [ "Win32->catpath('','','file')", 'file' ], | |
163 | [ "Win32->catpath('','\\d1/d2\\d3/','')", '\\d1/d2\\d3/' ], | |
164 | [ "Win32->catpath('','d1/d2\\d3/','')", 'd1/d2\\d3/' ], | |
165 | [ "Win32->catpath('','\\d1/d2\\d3/.','')", '\\d1/d2\\d3/.' ], | |
166 | [ "Win32->catpath('','\\d1/d2\\d3/..','')", '\\d1/d2\\d3/..' ], | |
167 | [ "Win32->catpath('','\\d1/d2\\d3/','.file')", '\\d1/d2\\d3/.file' ], | |
168 | [ "Win32->catpath('','\\d1/d2\\d3/','file')", '\\d1/d2\\d3/file' ], | |
169 | [ "Win32->catpath('','d1/d2\\d3/','file')", 'd1/d2\\d3/file' ], | |
170 | [ "Win32->catpath('C:','\\d1/d2\\d3/','')", 'C:\\d1/d2\\d3/' ], | |
171 | [ "Win32->catpath('C:','d1/d2\\d3/','')", 'C:d1/d2\\d3/' ], | |
172 | [ "Win32->catpath('C:','\\d1/d2\\d3/','file')", 'C:\\d1/d2\\d3/file' ], | |
173 | [ "Win32->catpath('C:','d1/d2\\d3/','file')", 'C:d1/d2\\d3/file' ], | |
174 | [ "Win32->catpath('C:','\\../d2\\d3/','file')", 'C:\\../d2\\d3/file' ], | |
175 | [ "Win32->catpath('C:','../d2\\d3/','file')", 'C:../d2\\d3/file' ], | |
176 | [ "Win32->catpath('','\\../..\\d1/','')", '\\../..\\d1/' ], | |
177 | [ "Win32->catpath('','\\./.\\d1/','')", '\\./.\\d1/' ], | |
178 | [ "Win32->catpath('\\\\node\\share','\\d1/d2\\d3/','')", '\\\\node\\share\\d1/d2\\d3/' ], | |
179 | [ "Win32->catpath('\\\\node\\share','\\d1/d2\\d3/','file')", '\\\\node\\share\\d1/d2\\d3/file' ], | |
180 | [ "Win32->catpath('\\\\node\\share','\\d1/d2\\','file')", '\\\\node\\share\\d1/d2\\file' ], | |
181 | ||
182 | [ "Win32->splitdir('')", '' ], | |
183 | [ "Win32->splitdir('\\d1/d2\\d3/')", ',d1,d2,d3,' ], | |
184 | [ "Win32->splitdir('d1/d2\\d3/')", 'd1,d2,d3,' ], | |
185 | [ "Win32->splitdir('\\d1/d2\\d3')", ',d1,d2,d3' ], | |
186 | [ "Win32->splitdir('d1/d2\\d3')", 'd1,d2,d3' ], | |
187 | ||
188 | [ "Win32->catdir()", '' ], | |
189 | [ "Win32->catdir('')", '\\' ], | |
190 | [ "Win32->catdir('/')", '\\' ], | |
638113eb JH |
191 | [ "Win32->catdir('/', '../')", '\\' ], |
192 | [ "Win32->catdir('/', '..\\')", '\\' ], | |
193 | [ "Win32->catdir('\\', '../')", '\\' ], | |
194 | [ "Win32->catdir('\\', '..\\')", '\\' ], | |
0994714a | 195 | [ "Win32->catdir('//d1','d2')", '\\\\d1\\d2' ], |
e021ab8e JH |
196 | [ "Win32->catdir('\\d1\\','d2')", '\\d1\\d2' ], |
197 | [ "Win32->catdir('\\d1','d2')", '\\d1\\d2' ], | |
198 | [ "Win32->catdir('\\d1','\\d2')", '\\d1\\d2' ], | |
199 | [ "Win32->catdir('\\d1','\\d2\\')", '\\d1\\d2' ], | |
bf7c0a3d SP |
200 | [ "Win32->catdir('','/d1','d2')", '\\d1\\d2' ], |
201 | [ "Win32->catdir('','','/d1','d2')", '\\d1\\d2' ], | |
202 | [ "Win32->catdir('','//d1','d2')", '\\d1\\d2' ], | |
203 | [ "Win32->catdir('','','//d1','d2')", '\\d1\\d2' ], | |
0994714a GS |
204 | [ "Win32->catdir('','d1','','d2','')", '\\d1\\d2' ], |
205 | [ "Win32->catdir('','d1','d2','d3','')", '\\d1\\d2\\d3' ], | |
206 | [ "Win32->catdir('d1','d2','d3','')", 'd1\\d2\\d3' ], | |
207 | [ "Win32->catdir('','d1','d2','d3')", '\\d1\\d2\\d3' ], | |
208 | [ "Win32->catdir('d1','d2','d3')", 'd1\\d2\\d3' ], | |
209 | [ "Win32->catdir('A:/d1','d2','d3')", 'A:\\d1\\d2\\d3' ], | |
210 | [ "Win32->catdir('A:/d1','d2','d3','')", 'A:\\d1\\d2\\d3' ], | |
211 | #[ "Win32->catdir('A:/d1','B:/d2','d3','')", 'A:\\d1\\d2\\d3' ], | |
212 | [ "Win32->catdir('A:/d1','B:/d2','d3','')", 'A:\\d1\\B:\\d2\\d3' ], | |
213 | [ "Win32->catdir('A:/')", 'A:\\' ], | |
638113eb | 214 | [ "Win32->catdir('\\', 'foo')", '\\foo' ], |
bf7c0a3d | 215 | [ "Win32->catdir('','','..')", '\\' ], |
795ee885 | 216 | [ "Win32->catdir('A:', 'foo')", 'A:\\foo' ], |
c47834cd | 217 | |
02961b52 MS |
218 | [ "Win32->catfile('a','b','c')", 'a\\b\\c' ], |
219 | [ "Win32->catfile('a','b','.\\c')", 'a\\b\\c' ], | |
220 | [ "Win32->catfile('.\\a','b','c')", 'a\\b\\c' ], | |
221 | [ "Win32->catfile('c')", 'c' ], | |
222 | [ "Win32->catfile('.\\c')", 'c' ], | |
bf7c0a3d | 223 | [ "Win32->catfile('a/..','../b')", '..\\b' ], |
795ee885 | 224 | [ "Win32->catfile('A:', 'foo')", 'A:\\foo' ], |
02961b52 | 225 | |
0994714a GS |
226 | |
227 | [ "Win32->canonpath('')", '' ], | |
228 | [ "Win32->canonpath('a:')", 'A:' ], | |
229 | [ "Win32->canonpath('A:f')", 'A:f' ], | |
638113eb | 230 | [ "Win32->canonpath('A:/')", 'A:\\' ], |
9596c75c RGS |
231 | # rt.perl.org 27052 |
232 | [ "Win32->canonpath('a\\..\\..\\b\\c')", '..\\b\\c' ], | |
0994714a GS |
233 | [ "Win32->canonpath('//a\\b//c')", '\\\\a\\b\\c' ], |
234 | [ "Win32->canonpath('/a/..../c')", '\\a\\....\\c' ], | |
235 | [ "Win32->canonpath('//a/b\\c')", '\\\\a\\b\\c' ], | |
bf7c0a3d | 236 | [ "Win32->canonpath('////')", '\\' ], |
0994714a | 237 | [ "Win32->canonpath('//')", '\\' ], |
bf7c0a3d | 238 | [ "Win32->canonpath('/.')", '\\' ], |
cc23144f | 239 | [ "Win32->canonpath('//a/b/../../c')", '\\\\a\\b\\c' ], |
240 | [ "Win32->canonpath('//a/b/c/../d')", '\\\\a\\b\\d' ], | |
241 | [ "Win32->canonpath('//a/b/c/../../d')",'\\\\a\\b\\d' ], | |
242 | [ "Win32->canonpath('//a/b/c/.../d')", '\\\\a\\b\\d' ], | |
243 | [ "Win32->canonpath('/a/b/c/../../d')", '\\a\\d' ], | |
244 | [ "Win32->canonpath('/a/b/c/.../d')", '\\a\\d' ], | |
e021ab8e | 245 | [ "Win32->canonpath('\\../temp\\')", '\\temp' ], |
638113eb JH |
246 | [ "Win32->canonpath('\\../')", '\\' ], |
247 | [ "Win32->canonpath('\\..\\')", '\\' ], | |
248 | [ "Win32->canonpath('/../')", '\\' ], | |
249 | [ "Win32->canonpath('/..\\')", '\\' ], | |
c47834cd RGS |
250 | [ "Win32->canonpath('d1/../foo')", 'foo' ], |
251 | ||
5b287435 | 252 | # FakeWin32 subclass (see below) just sets CWD to C:\one\two and getdcwd('D') to D:\alpha\beta |
e021ab8e | 253 | |
9d5071ba | 254 | [ "FakeWin32->abs2rel('/t1/t2/t3','/t1/t2/t3')", '.' ], |
e021ab8e JH |
255 | [ "FakeWin32->abs2rel('/t1/t2/t4','/t1/t2/t3')", '..\\t4' ], |
256 | [ "FakeWin32->abs2rel('/t1/t2','/t1/t2/t3')", '..' ], | |
257 | [ "FakeWin32->abs2rel('/t1/t2/t3/t4','/t1/t2/t3')", 't4' ], | |
258 | [ "FakeWin32->abs2rel('/t4/t5/t6','/t1/t2/t3')", '..\\..\\..\\t4\\t5\\t6' ], | |
5b287435 | 259 | [ "FakeWin32->abs2rel('../t4','/t1/t2/t3')", '..\\..\\..\\one\\t4' ], # Uses _cwd() |
e021ab8e JH |
260 | [ "FakeWin32->abs2rel('/','/t1/t2/t3')", '..\\..\\..' ], |
261 | [ "FakeWin32->abs2rel('///','/t1/t2/t3')", '..\\..\\..' ], | |
262 | [ "FakeWin32->abs2rel('/.','/t1/t2/t3')", '..\\..\\..' ], | |
263 | [ "FakeWin32->abs2rel('/./','/t1/t2/t3')", '..\\..\\..' ], | |
264 | [ "FakeWin32->abs2rel('\\\\a/t1/t2/t4','/t2/t3')", '\\\\a\\t1\\t2\\t4' ], | |
265 | [ "FakeWin32->abs2rel('//a/t1/t2/t4','/t2/t3')", '\\\\a\\t1\\t2\\t4' ], | |
9d5071ba | 266 | [ "FakeWin32->abs2rel('A:/t1/t2/t3','A:/t1/t2/t3')", '.' ], |
e021ab8e JH |
267 | [ "FakeWin32->abs2rel('A:/t1/t2/t3/t4','A:/t1/t2/t3')", 't4' ], |
268 | [ "FakeWin32->abs2rel('A:/t1/t2/t3','A:/t1/t2/t3/t4')", '..' ], | |
269 | [ "FakeWin32->abs2rel('A:/t1/t2/t3','B:/t1/t2/t3')", 'A:\\t1\\t2\\t3' ], | |
270 | [ "FakeWin32->abs2rel('A:/t1/t2/t3/t4','B:/t1/t2/t3')", 'A:\\t1\\t2\\t3\\t4' ], | |
271 | [ "FakeWin32->abs2rel('E:/foo/bar/baz')", 'E:\\foo\\bar\\baz' ], | |
272 | [ "FakeWin32->abs2rel('C:/one/two/three')", 'three' ], | |
fa52125f SP |
273 | [ "FakeWin32->abs2rel('C:\\Windows\\System32', 'C:\\')", 'Windows\System32' ], |
274 | [ "FakeWin32->abs2rel('\\\\computer2\\share3\\foo.txt', '\\\\computer2\\share3')", 'foo.txt' ], | |
110c90cc | 275 | [ "FakeWin32->abs2rel('C:\\one\\two\\t\\asd1\\', 't\\asd\\')", '..\\asd1' ], |
81a4c762 | 276 | [ "FakeWin32->abs2rel('\\one\\two', 'A:\\foo')", 'C:\\one\\two' ], |
e021ab8e JH |
277 | |
278 | [ "FakeWin32->rel2abs('temp','C:/')", 'C:\\temp' ], | |
279 | [ "FakeWin32->rel2abs('temp','C:/a')", 'C:\\a\\temp' ], | |
280 | [ "FakeWin32->rel2abs('temp','C:/a/')", 'C:\\a\\temp' ], | |
281 | [ "FakeWin32->rel2abs('../','C:/')", 'C:\\' ], | |
282 | [ "FakeWin32->rel2abs('../','C:/a')", 'C:\\' ], | |
110c90cc | 283 | [ "FakeWin32->rel2abs('\\foo','C:/a')", 'C:\\foo' ], |
e021ab8e JH |
284 | [ "FakeWin32->rel2abs('temp','//prague_main/work/')", '\\\\prague_main\\work\\temp' ], |
285 | [ "FakeWin32->rel2abs('../temp','//prague_main/work/')", '\\\\prague_main\\work\\temp' ], | |
286 | [ "FakeWin32->rel2abs('temp','//prague_main/work')", '\\\\prague_main\\work\\temp' ], | |
287 | [ "FakeWin32->rel2abs('../','//prague_main/work')", '\\\\prague_main\\work' ], | |
c1e8580e | 288 | [ "FakeWin32->rel2abs('D:foo.txt')", 'D:\\alpha\\beta\\foo.txt' ], |
e021ab8e JH |
289 | |
290 | [ "VMS->case_tolerant()", '1' ], | |
02961b52 | 291 | |
ae5a807c | 292 | [ "VMS->catfile('a','b','c')", $vms_unix_rpt ? 'a/b/c' : '[.a.b]c' ], |
02961b52 MS |
293 | [ "VMS->catfile('a','b','[]c')", '[.a.b]c' ], |
294 | [ "VMS->catfile('[.a]','b','c')", '[.a.b]c' ], | |
295 | [ "VMS->catfile('c')", 'c' ], | |
296 | [ "VMS->catfile('[]c')", 'c' ], | |
297 | ||
ae5a807c JM |
298 | [ "VMS->catfile('0','b','c')", $vms_unix_rpt ? '0/b/c' : '[.0.b]c' ], |
299 | [ "VMS->catfile('a','0','c')", $vms_unix_rpt ? 'a/0/c' : '[.a.0]c' ], | |
300 | [ "VMS->catfile('a','b','0')", $vms_unix_rpt ? 'a/b/0' : '[.a.b]0' ], | |
301 | [ "VMS->catfile('0','0','c')", $vms_unix_rpt ? '0/0/c' : '[.0.0]c' ], | |
302 | [ "VMS->catfile('a','0','0')", $vms_unix_rpt ? 'a/0/0' : '[.a.0]0' ], | |
303 | [ "VMS->catfile('0','b','0')", $vms_unix_rpt ? '0/b/0' : '[.0.b]0' ], | |
304 | [ "VMS->catfile('0','0','0')", $vms_unix_rpt ? '0/0/0' : '[.0.0]0' ], | |
ff235dd6 SP |
305 | |
306 | ||
0994714a | 307 | [ "VMS->splitpath('file')", ',,file' ], |
08c7cbbb GS |
308 | [ "VMS->splitpath('[d1.d2.d3]')", ',[d1.d2.d3],' ], |
309 | [ "VMS->splitpath('[.d1.d2.d3]')", ',[.d1.d2.d3],' ], | |
310 | [ "VMS->splitpath('[d1.d2.d3]file')", ',[d1.d2.d3],file' ], | |
ae5a807c JM |
311 | [ "VMS->splitpath('d1/d2/d3/file')", |
312 | $vms_efs ? ',d1/d2/d3/,file' : ',[.d1.d2.d3],file' ], | |
313 | [ "VMS->splitpath('/d1/d2/d3/file')", | |
314 | $vms_efs ? ',/d1/d2/d3/,file' : 'd1:,[d2.d3],file' ], | |
08c7cbbb GS |
315 | [ "VMS->splitpath('[.d1.d2.d3]file')", ',[.d1.d2.d3],file' ], |
316 | [ "VMS->splitpath('node::volume:[d1.d2.d3]')", 'node::volume:,[d1.d2.d3],' ], | |
317 | [ "VMS->splitpath('node::volume:[d1.d2.d3]file')", 'node::volume:,[d1.d2.d3],file' ], | |
318 | [ "VMS->splitpath('node\"access_spec\"::volume:[d1.d2.d3]')", 'node"access_spec"::volume:,[d1.d2.d3],' ], | |
319 | [ "VMS->splitpath('node\"access_spec\"::volume:[d1.d2.d3]file')", 'node"access_spec"::volume:,[d1.d2.d3],file' ], | |
0994714a | 320 | |
486bcc50 NC |
321 | [ "VMS->splitpath('[]')", ',[],' ], |
322 | [ "VMS->splitpath('[-]')", ',[-],' ], | |
323 | [ "VMS->splitpath('[]file')", ',[],file' ], | |
324 | [ "VMS->splitpath('[-]file')", ',[-],file' ], | |
325 | [ "VMS->splitpath('')", ',,' ], | |
326 | [ "VMS->splitpath('0')", ',,0' ], | |
327 | [ "VMS->splitpath('[0]')", ',[0],' ], | |
328 | [ "VMS->splitpath('[.0]')", ',[.0],' ], | |
329 | [ "VMS->splitpath('[0.0.0]')", ',[0.0.0],' ], | |
330 | [ "VMS->splitpath('[.0.0.0]')", ',[.0.0.0],' ], | |
331 | [ "VMS->splitpath('[0]0')", ',[0],0' ], | |
332 | [ "VMS->splitpath('[0.0.0]0')", ',[0.0.0],0' ], | |
333 | [ "VMS->splitpath('[.0.0.0]0')", ',[.0.0.0],0' ], | |
ae5a807c JM |
334 | [ "VMS->splitpath('0/0')", $vms_efs ? ',0/,0' : ',[.0],0' ], |
335 | [ "VMS->splitpath('0/0/0')", $vms_efs ? ',0/0/,0' : ',[.0.0],0' ], | |
336 | [ "VMS->splitpath('/0/0')", $vms_efs ? ',/0/,0' : '0:,[000000],0' ], | |
337 | [ "VMS->splitpath('/0/0/0')", $vms_efs ? ',/0/0/,0' : '0:,[0],0' ], | |
486bcc50 NC |
338 | [ "VMS->splitpath('d1',1)", ',d1,' ], |
339 | # $no_file tests | |
340 | [ "VMS->splitpath('[d1.d2.d3]',1)", ',[d1.d2.d3],' ], | |
341 | [ "VMS->splitpath('[.d1.d2.d3]',1)", ',[.d1.d2.d3],' ], | |
ae5a807c JM |
342 | [ "VMS->splitpath('d1/d2/d3',1)", $vms_efs ? ',d1/d2/d3,' : ',[.d1.d2.d3],' ], |
343 | [ "VMS->splitpath('/d1/d2/d3',1)", $vms_efs ? ',/d1/d2/d3,' : 'd1:,[d2.d3],' ], | |
486bcc50 NC |
344 | [ "VMS->splitpath('node::volume:[d1.d2.d3]',1)", 'node::volume:,[d1.d2.d3],' ], |
345 | [ "VMS->splitpath('node\"access_spec\"::volume:[d1.d2.d3]',1)", 'node"access_spec"::volume:,[d1.d2.d3],' ], | |
346 | [ "VMS->splitpath('[]',1)", ',[],' ], | |
347 | [ "VMS->splitpath('[-]',1)", ',[-],' ], | |
348 | [ "VMS->splitpath('',1)", ',,' ], | |
349 | [ "VMS->splitpath('0',1)", ',0,' ], | |
350 | [ "VMS->splitpath('[0]',1)", ',[0],' ], | |
351 | [ "VMS->splitpath('[.0]',1)", ',[.0],' ], | |
352 | [ "VMS->splitpath('[0.0.0]',1)", ',[0.0.0],' ], | |
353 | [ "VMS->splitpath('[.0.0.0]',1)", ',[.0.0.0],' ], | |
ae5a807c JM |
354 | [ "VMS->splitpath('0/0',1)", $vms_efs ? ',0/0,' : ',[.0.0],' ], |
355 | [ "VMS->splitpath('0/0/0',1)", $vms_efs ? ',0/0/0,' : ',[.0.0.0],' ], | |
356 | [ "VMS->splitpath('/0/0',1)", $vms_efs ? ',/0/0,' : '0:,[000000.0],' ], | |
357 | [ "VMS->splitpath('/0/0/0',1)", $vms_efs ? ',/0/0/0,' : '0:,[0.0],' ], | |
486bcc50 | 358 | |
0994714a GS |
359 | [ "VMS->catpath('','','file')", 'file' ], |
360 | [ "VMS->catpath('','[d1.d2.d3]','')", '[d1.d2.d3]' ], | |
361 | [ "VMS->catpath('','[.d1.d2.d3]','')", '[.d1.d2.d3]' ], | |
362 | [ "VMS->catpath('','[d1.d2.d3]','file')", '[d1.d2.d3]file' ], | |
363 | [ "VMS->catpath('','[.d1.d2.d3]','file')", '[.d1.d2.d3]file' ], | |
ae5a807c JM |
364 | [ "VMS->catpath('','d1/d2/d3','file')", |
365 | $vms_efs ? 'd1/d2/d3/file' : '[.d1.d2.d3]file' ], | |
366 | [ "VMS->catpath('v','d1/d2/d3','file')", 'v:[.d1.d2.d3]file' ], | |
385aae1c | 367 | [ "VMS->catpath('v','','file')", 'v:file' ], |
638113eb | 368 | [ "VMS->catpath('v','w:[d1.d2.d3]','file')", 'v:[d1.d2.d3]file' ], |
0994714a GS |
369 | [ "VMS->catpath('node::volume:','[d1.d2.d3]','')", 'node::volume:[d1.d2.d3]' ], |
370 | [ "VMS->catpath('node::volume:','[d1.d2.d3]','file')", 'node::volume:[d1.d2.d3]file' ], | |
371 | [ "VMS->catpath('node\"access_spec\"::volume:','[d1.d2.d3]','')", 'node"access_spec"::volume:[d1.d2.d3]' ], | |
372 | [ "VMS->catpath('node\"access_spec\"::volume:','[d1.d2.d3]','file')", 'node"access_spec"::volume:[d1.d2.d3]file' ], | |
373 | ||
374 | [ "VMS->canonpath('')", '' ], | |
178326fd | 375 | [ "VMS->canonpath('volume:[d1]file')", 'volume:[d1]file' ], |
08c7cbbb | 376 | [ "VMS->canonpath('volume:[d1.-.d2.][d3.d4.-]')", 'volume:[d2.d3]' ], |
178326fd | 377 | [ "VMS->canonpath('volume:[000000.d1]d2.dir;1')", 'volume:[d1]d2.dir;1' ], |
bdc74e5c CB |
378 | [ "VMS->canonpath('volume:[d1.d2.d3]file.txt')", 'volume:[d1.d2.d3]file.txt' ], |
379 | [ "VMS->canonpath('[d1.d2.d3]file.txt')", '[d1.d2.d3]file.txt' ], | |
380 | [ "VMS->canonpath('volume:[-.d1.d2.d3]file.txt')", 'volume:[-.d1.d2.d3]file.txt' ], | |
381 | [ "VMS->canonpath('[-.d1.d2.d3]file.txt')", '[-.d1.d2.d3]file.txt' ], | |
382 | [ "VMS->canonpath('volume:[--.d1.d2.d3]file.txt')", 'volume:[--.d1.d2.d3]file.txt' ], | |
383 | [ "VMS->canonpath('[--.d1.d2.d3]file.txt')", '[--.d1.d2.d3]file.txt' ], | |
384 | [ "VMS->canonpath('volume:[d1.-.d2.d3]file.txt')", 'volume:[d2.d3]file.txt' ], | |
385 | [ "VMS->canonpath('[d1.-.d2.d3]file.txt')", '[d2.d3]file.txt' ], | |
386 | [ "VMS->canonpath('volume:[d1.--.d2.d3]file.txt')", 'volume:[-.d2.d3]file.txt' ], | |
387 | [ "VMS->canonpath('[d1.--.d2.d3]file.txt')", '[-.d2.d3]file.txt' ], | |
388 | [ "VMS->canonpath('volume:[d1.d2.-.d3]file.txt')", 'volume:[d1.d3]file.txt' ], | |
389 | [ "VMS->canonpath('[d1.d2.-.d3]file.txt')", '[d1.d3]file.txt' ], | |
390 | [ "VMS->canonpath('volume:[d1.d2.--.d3]file.txt')", 'volume:[d3]file.txt' ], | |
391 | [ "VMS->canonpath('[d1.d2.--.d3]file.txt')", '[d3]file.txt' ], | |
392 | [ "VMS->canonpath('volume:[d1.d2.d3.-]file.txt')", 'volume:[d1.d2]file.txt' ], | |
393 | [ "VMS->canonpath('[d1.d2.d3.-]file.txt')", '[d1.d2]file.txt' ], | |
394 | [ "VMS->canonpath('volume:[d1.d2.d3.--]file.txt')", 'volume:[d1]file.txt' ], | |
395 | [ "VMS->canonpath('[d1.d2.d3.--]file.txt')", '[d1]file.txt' ], | |
396 | [ "VMS->canonpath('volume:[d1.000000.][000000.][d3.--]file.txt')", 'volume:[d1]file.txt' ], | |
397 | [ "VMS->canonpath('[d1.000000.][000000.][d3.--]file.txt')", '[d1]file.txt' ], | |
398 | [ "VMS->canonpath('volume:[d1.000000.][000000.][d2.000000]file.txt')", 'volume:[d1.000000.d2.000000]file.txt' ], | |
399 | [ "VMS->canonpath('[d1.000000.][000000.][d2.000000]file.txt')", '[d1.000000.d2.000000]file.txt' ], | |
400 | [ "VMS->canonpath('volume:[d1.000000.][000000.][d3.--.000000]file.txt')",'volume:[d1.000000]file.txt' ], | |
401 | [ "VMS->canonpath('[d1.000000.][000000.][d3.--.000000]file.txt')", '[d1.000000]file.txt' ], | |
402 | [ "VMS->canonpath('volume:[d1.000000.][000000.][-.-.000000]file.txt')", 'volume:[000000]file.txt' ], | |
403 | [ "VMS->canonpath('[d1.000000.][000000.][--.-.000000]file.txt')", '[-.000000]file.txt' ], | |
99f36a73 | 404 | [ "VMS->canonpath('[d1.d2.--]file')", '[000000]file' ], |
0994714a GS |
405 | |
406 | [ "VMS->splitdir('')", '' ], | |
407 | [ "VMS->splitdir('[]')", '' ], | |
408 | [ "VMS->splitdir('d1.d2.d3')", 'd1,d2,d3' ], | |
409 | [ "VMS->splitdir('[d1.d2.d3]')", 'd1,d2,d3' ], | |
2e74f398 CB |
410 | [ "VMS->splitdir('.d1.d2.d3')", 'd1,d2,d3' ], |
411 | [ "VMS->splitdir('[.d1.d2.d3]')", 'd1,d2,d3' ], | |
412 | [ "VMS->splitdir('.-.d2.d3')", '-,d2,d3' ], | |
413 | [ "VMS->splitdir('[.-.d2.d3]')", '-,d2,d3' ], | |
bdc74e5c CB |
414 | [ "VMS->splitdir('[d1.d2]')", 'd1,d2' ], |
415 | [ "VMS->splitdir('[d1-.--d2]')", 'd1-,--d2' ], | |
416 | [ "VMS->splitdir('[d1---.-.d2]')", 'd1---,-,d2' ], | |
417 | [ "VMS->splitdir('[d1.---.d2]')", 'd1,-,-,-,d2' ], | |
418 | [ "VMS->splitdir('[d1---d2]')", 'd1---d2' ], | |
419 | [ "VMS->splitdir('[d1.][000000.d2]')", 'd1,d2' ], | |
2e74f398 | 420 | [ "VMS->splitdir('[.d1.d2^.d3]')", 'd1,d2^.d3' ], |
0994714a | 421 | |
ae5a807c JM |
422 | [ "VMS->catdir('')", '' ], |
423 | [ "VMS->catdir('d1','d2','d3')", $vms_unix_rpt ? 'd1/d2/d3' : '[.d1.d2.d3]' ], | |
424 | [ "VMS->catdir('d1','d2/','d3')", $vms_efs ? 'd1/d2/d3' : '[.d1.d2.d3]' ], | |
425 | [ "VMS->catdir('','d1','d2','d3')", | |
426 | $vms_unix_rpt ? '/d1/d2/d3' : | |
427 | $vms_efs ? '[d1.d2.d3]' : '[.d1.d2.d3]' ], | |
428 | [ "VMS->catdir('','-','d2','d3')", '[-.d2.d3]' ], | |
429 | [ "VMS->catdir('','-','','d3')", '[-.d3]' ], | |
430 | [ "VMS->catdir('dir.dir','d2.dir','d3.dir')", | |
431 | $vms_unix_rpt ? 'dir.dir/d2.dir/d3.dir' : '[.dir.d2.d3]' ], | |
432 | [ "VMS->catdir('[.name]')", '[.name]' ], | |
433 | [ "VMS->catdir('[.name]','[.name]')", '[.name.name]'], | |
0994714a | 434 | |
9d5071ba | 435 | [ "VMS->abs2rel('node::volume:[t1.t2.t3]','node::volume:[t1.t2.t3]')", '[]' ], |
cda9bddd | 436 | [ "VMS->abs2rel('node::volume:[t1.t2.t3]','[t1.t2.t3]')", 'node::volume:[t1.t2.t3]' ], |
416c0615 | 437 | [ "VMS->abs2rel('node::volume:[t1.t2.t4]','node::volume:[t1.t2.t3]')", '[-.t4]' ], |
cda9bddd | 438 | [ "VMS->abs2rel('node::volume:[t1.t2.t4]','[t1.t2.t3]')", 'node::volume:[t1.t2.t4]' ], |
9d5071ba | 439 | [ "VMS->abs2rel('[t1.t2.t3]','[t1.t2.t3]')", '[]' ], |
0994714a | 440 | [ "VMS->abs2rel('[t1.t2.t3]file','[t1.t2.t3]')", 'file' ], |
638113eb JH |
441 | [ "VMS->abs2rel('[t1.t2.t3]file','[t1.t2]')", '[.t3]file' ], |
442 | [ "VMS->abs2rel('v:[t1.t2.t3]file','v:[t1.t2]')", '[.t3]file' ], | |
0994714a GS |
443 | [ "VMS->abs2rel('[t1.t2.t4]','[t1.t2.t3]')", '[-.t4]' ], |
444 | [ "VMS->abs2rel('[t1.t2]file','[t1.t2.t3]')", '[-]file' ], | |
638113eb | 445 | [ "VMS->abs2rel('[t1.t2.t3.t4]','[t1.t2.t3]')", '[.t4]' ], |
08c7cbbb | 446 | [ "VMS->abs2rel('[t4.t5.t6]','[t1.t2.t3]')", '[---.t4.t5.t6]' ], |
737c380e | 447 | [ "VMS->abs2rel('[000000]','[t1.t2.t3]')", '[---]' ], |
9d5071ba | 448 | [ "VMS->abs2rel('a:[t1.t2.t4]','a:[t1.t2.t3]')", '[-.t4]' ], |
cda9bddd | 449 | [ "VMS->abs2rel('a:[t1.t2.t4]','[t1.t2.t3]')", 'a:[t1.t2.t4]' ], |
08c7cbbb | 450 | [ "VMS->abs2rel('[a.-.b.c.-]','[t1.t2.t3]')", '[---.b]' ], |
270d1e39 | 451 | |
0994714a GS |
452 | [ "VMS->rel2abs('[.t4]','[t1.t2.t3]')", '[t1.t2.t3.t4]' ], |
453 | [ "VMS->rel2abs('[.t4.t5]','[t1.t2.t3]')", '[t1.t2.t3.t4.t5]' ], | |
454 | [ "VMS->rel2abs('[]','[t1.t2.t3]')", '[t1.t2.t3]' ], | |
08c7cbbb GS |
455 | [ "VMS->rel2abs('[-]','[t1.t2.t3]')", '[t1.t2]' ], |
456 | [ "VMS->rel2abs('[-.t4]','[t1.t2.t3]')", '[t1.t2.t4]' ], | |
0994714a | 457 | [ "VMS->rel2abs('[t1]','[t1.t2.t3]')", '[t1]' ], |
270d1e39 | 458 | |
e021ab8e JH |
459 | [ "OS2->case_tolerant()", '1' ], |
460 | ||
0994714a | 461 | [ "OS2->catdir('A:/d1','B:/d2','d3','')", 'A:/d1/B:/d2/d3' ], |
02961b52 | 462 | |
0994714a | 463 | [ "OS2->catfile('a','b','c')", 'a/b/c' ], |
02961b52 MS |
464 | [ "OS2->catfile('a','b','./c')", 'a/b/c' ], |
465 | [ "OS2->catfile('./a','b','c')", 'a/b/c' ], | |
466 | [ "OS2->catfile('c')", 'c' ], | |
467 | [ "OS2->catfile('./c')", 'c' ], | |
0994714a | 468 | |
638113eb JH |
469 | [ "OS2->catdir('/', '../')", '/' ], |
470 | [ "OS2->catdir('/', '..\\')", '/' ], | |
471 | [ "OS2->catdir('\\', '../')", '/' ], | |
472 | [ "OS2->catdir('\\', '..\\')", '/' ], | |
473 | ||
e021ab8e | 474 | [ "Mac->case_tolerant()", '1' ], |
be708cc0 JH |
475 | |
476 | [ "Mac->catpath('','','')", '' ], | |
477 | [ "Mac->catpath('',':','')", ':' ], | |
478 | [ "Mac->catpath('','::','')", '::' ], | |
479 | ||
480 | [ "Mac->catpath('hd','','')", 'hd:' ], | |
481 | [ "Mac->catpath('hd:','','')", 'hd:' ], | |
45657e91 | 482 | [ "Mac->catpath('hd:',':','')", 'hd:' ], |
be708cc0 JH |
483 | [ "Mac->catpath('hd:','::','')", 'hd::' ], |
484 | ||
485 | [ "Mac->catpath('hd','','file')", 'hd:file' ], | |
486 | [ "Mac->catpath('hd',':','file')", 'hd:file' ], | |
487 | [ "Mac->catpath('hd','::','file')", 'hd::file' ], | |
488 | [ "Mac->catpath('hd',':::','file')", 'hd:::file' ], | |
489 | ||
490 | [ "Mac->catpath('hd:','',':file')", 'hd:file' ], | |
491 | [ "Mac->catpath('hd:',':',':file')", 'hd:file' ], | |
492 | [ "Mac->catpath('hd:','::',':file')", 'hd::file' ], | |
493 | [ "Mac->catpath('hd:',':::',':file')", 'hd:::file' ], | |
494 | ||
495 | [ "Mac->catpath('hd:','d1','file')", 'hd:d1:file' ], | |
496 | [ "Mac->catpath('hd:',':d1:',':file')", 'hd:d1:file' ], | |
638113eb | 497 | [ "Mac->catpath('hd:','hd:d1','')", 'hd:d1:' ], |
be708cc0 JH |
498 | |
499 | [ "Mac->catpath('','d1','')", ':d1:' ], | |
500 | [ "Mac->catpath('',':d1','')", ':d1:' ], | |
501 | [ "Mac->catpath('',':d1:','')", ':d1:' ], | |
502 | ||
503 | [ "Mac->catpath('','d1','file')", ':d1:file' ], | |
504 | [ "Mac->catpath('',':d1:',':file')", ':d1:file' ], | |
505 | ||
506 | [ "Mac->catpath('','','file')", 'file' ], | |
507 | [ "Mac->catpath('','',':file')", 'file' ], # ! | |
508 | [ "Mac->catpath('',':',':file')", ':file' ], # ! | |
509 | ||
510 | ||
511 | [ "Mac->splitpath(':')", ',:,' ], | |
512 | [ "Mac->splitpath('::')", ',::,' ], | |
513 | [ "Mac->splitpath(':::')", ',:::,' ], | |
514 | ||
515 | [ "Mac->splitpath('file')", ',,file' ], | |
516 | [ "Mac->splitpath(':file')", ',:,file' ], | |
517 | ||
518 | [ "Mac->splitpath('d1',1)", ',:d1:,' ], # dir, not volume | |
519 | [ "Mac->splitpath(':d1',1)", ',:d1:,' ], | |
520 | [ "Mac->splitpath(':d1:',1)", ',:d1:,' ], | |
521 | [ "Mac->splitpath(':d1:')", ',:d1:,' ], | |
522 | [ "Mac->splitpath(':d1:d2:d3:')", ',:d1:d2:d3:,' ], | |
523 | [ "Mac->splitpath(':d1:d2:d3:',1)", ',:d1:d2:d3:,' ], | |
524 | [ "Mac->splitpath(':d1:file')", ',:d1:,file' ], | |
525 | [ "Mac->splitpath('::d1:file')", ',::d1:,file' ], | |
526 | ||
527 | [ "Mac->splitpath('hd:', 1)", 'hd:,,' ], | |
528 | [ "Mac->splitpath('hd:')", 'hd:,,' ], | |
529 | [ "Mac->splitpath('hd:d1:d2:')", 'hd:,:d1:d2:,' ], | |
530 | [ "Mac->splitpath('hd:d1:d2',1)", 'hd:,:d1:d2:,' ], | |
531 | [ "Mac->splitpath('hd:d1:d2:file')", 'hd:,:d1:d2:,file' ], | |
532 | [ "Mac->splitpath('hd:d1:d2::file')", 'hd:,:d1:d2::,file' ], | |
533 | [ "Mac->splitpath('hd::d1:d2:file')", 'hd:,::d1:d2:,file' ], # invalid path | |
534 | [ "Mac->splitpath('hd:file')", 'hd:,,file' ], | |
535 | ||
2586ba89 | 536 | [ "Mac->splitdir()", '' ], |
be708cc0 JH |
537 | [ "Mac->splitdir('')", '' ], |
538 | [ "Mac->splitdir(':')", ':' ], | |
539 | [ "Mac->splitdir('::')", '::' ], | |
2586ba89 JH |
540 | [ "Mac->splitdir(':::')", '::,::' ], |
541 | [ "Mac->splitdir(':::d1:d2')", '::,::,d1,d2' ], | |
542 | ||
543 | [ "Mac->splitdir(':d1:d2:d3::')", 'd1,d2,d3,::'], | |
544 | [ "Mac->splitdir(':d1:d2:d3:')", 'd1,d2,d3' ], | |
545 | [ "Mac->splitdir(':d1:d2:d3')", 'd1,d2,d3' ], | |
546 | ||
547 | # absolute paths in splitdir() work, but you'd better use splitpath() | |
548 | [ "Mac->splitdir('hd:')", 'hd:' ], | |
549 | [ "Mac->splitdir('hd::')", 'hd:,::' ], # invalid path, but it works | |
550 | [ "Mac->splitdir('hd::d1:')", 'hd:,::,d1' ], # invalid path, but it works | |
551 | [ "Mac->splitdir('hd:d1:d2:::')", 'hd:,d1,d2,::,::' ], | |
552 | [ "Mac->splitdir('hd:d1:d2::')", 'hd:,d1,d2,::' ], | |
553 | [ "Mac->splitdir('hd:d1:d2:')", 'hd:,d1,d2' ], | |
554 | [ "Mac->splitdir('hd:d1:d2')", 'hd:,d1,d2' ], | |
555 | [ "Mac->splitdir('hd:d1::d2::')", 'hd:,d1,::,d2,::' ], | |
556 | ||
557 | [ "Mac->catdir()", '' ], | |
2586ba89 JH |
558 | [ "Mac->catdir(':')", ':' ], |
559 | ||
45657e91 JH |
560 | [ "Mac->catdir(':', ':')", ':' ], |
561 | [ "Mac->catdir(':', '')", ':' ], | |
2586ba89 | 562 | |
45657e91 | 563 | [ "Mac->catdir(':', '::')", '::' ], |
2586ba89 | 564 | |
45657e91 JH |
565 | [ "Mac->catdir('::', '')", '::' ], |
566 | [ "Mac->catdir('::', ':')", '::' ], | |
2586ba89 | 567 | |
45657e91 | 568 | [ "Mac->catdir('::', '::')", ':::' ], |
2586ba89 JH |
569 | |
570 | [ "Mac->catdir(':d1')", ':d1:' ], | |
571 | [ "Mac->catdir(':d1:')", ':d1:' ], | |
572 | [ "Mac->catdir(':d1','d2')", ':d1:d2:' ], | |
573 | [ "Mac->catdir(':d1',':d2')", ':d1:d2:' ], | |
574 | [ "Mac->catdir(':d1',':d2:')", ':d1:d2:' ], | |
575 | [ "Mac->catdir(':d1',':d2::')", ':d1:d2::' ], | |
576 | [ "Mac->catdir(':',':d1',':d2')", ':d1:d2:' ], | |
577 | [ "Mac->catdir('::',':d1',':d2')", '::d1:d2:' ], | |
578 | [ "Mac->catdir('::','::',':d1',':d2')", ':::d1:d2:' ], | |
579 | [ "Mac->catdir(':',':',':d1',':d2')", ':d1:d2:' ], | |
580 | [ "Mac->catdir('::',':',':d1',':d2')", '::d1:d2:' ], | |
581 | ||
582 | [ "Mac->catdir('d1')", ':d1:' ], | |
583 | [ "Mac->catdir('d1','d2','d3')", ':d1:d2:d3:' ], | |
584 | [ "Mac->catdir('d1','d2/','d3')", ':d1:d2/:d3:' ], | |
585 | [ "Mac->catdir('d1','',':d2')", ':d1:d2:' ], | |
586 | [ "Mac->catdir('d1',':',':d2')", ':d1:d2:' ], | |
587 | [ "Mac->catdir('d1','::',':d2')", ':d1::d2:' ], | |
588 | [ "Mac->catdir('d1',':::',':d2')", ':d1:::d2:' ], | |
589 | [ "Mac->catdir('d1','::','::',':d2')", ':d1:::d2:' ], | |
590 | [ "Mac->catdir('d1','d2')", ':d1:d2:' ], | |
591 | [ "Mac->catdir('d1','d2', '')", ':d1:d2:' ], | |
592 | [ "Mac->catdir('d1','d2', ':')", ':d1:d2:' ], | |
593 | [ "Mac->catdir('d1','d2', '::')", ':d1:d2::' ], | |
594 | [ "Mac->catdir('d1','d2','','')", ':d1:d2:' ], | |
595 | [ "Mac->catdir('d1','d2',':','::')", ':d1:d2::' ], | |
596 | [ "Mac->catdir('d1','d2','::','::')", ':d1:d2:::' ], | |
597 | [ "Mac->catdir('d1',':d2')", ':d1:d2:' ], | |
598 | [ "Mac->catdir('d1',':d2:')", ':d1:d2:' ], | |
599 | ||
be708cc0 JH |
600 | [ "Mac->catdir('hd:',':d1')", 'hd:d1:' ], |
601 | [ "Mac->catdir('hd:d1:',':d2')", 'hd:d1:d2:' ], | |
602 | [ "Mac->catdir('hd:','d1')", 'hd:d1:' ], | |
be708cc0 JH |
603 | [ "Mac->catdir('hd:d1:',':d2')", 'hd:d1:d2:' ], |
604 | [ "Mac->catdir('hd:d1:',':d2:')", 'hd:d1:d2:' ], | |
605 | ||
45657e91 | 606 | [ "Mac->catfile()", '' ], |
2586ba89 | 607 | [ "Mac->catfile('')", '' ], |
2586ba89 JH |
608 | [ "Mac->catfile(':')", ':' ], |
609 | [ "Mac->catfile(':', '')", ':' ], | |
be708cc0 | 610 | |
2586ba89 JH |
611 | [ "Mac->catfile('d1','d2','file')", ':d1:d2:file' ], |
612 | [ "Mac->catfile('d1','d2',':file')", ':d1:d2:file' ], | |
45657e91 JH |
613 | [ "Mac->catfile('file')", 'file' ], |
614 | [ "Mac->catfile(':', 'file')", ':file' ], | |
615 | ||
0994714a GS |
616 | [ "Mac->canonpath('')", '' ], |
617 | [ "Mac->canonpath(':')", ':' ], | |
618 | [ "Mac->canonpath('::')", '::' ], | |
619 | [ "Mac->canonpath('a::')", 'a::' ], | |
620 | [ "Mac->canonpath(':a::')", ':a::' ], | |
621 | ||
be708cc0 JH |
622 | [ "Mac->abs2rel('hd:d1:d2:','hd:d1:d2:')", ':' ], |
623 | [ "Mac->abs2rel('hd:d1:d2:','hd:d1:d2:file')", ':' ], # ignore base's file portion | |
45657e91 | 624 | [ "Mac->abs2rel('hd:d1:d2:file','hd:d1:d2:')", ':file' ], |
be708cc0 JH |
625 | [ "Mac->abs2rel('hd:d1:','hd:d1:d2:')", '::' ], |
626 | [ "Mac->abs2rel('hd:d3:','hd:d1:d2:')", ':::d3:' ], | |
627 | [ "Mac->abs2rel('hd:d3:','hd:d1:d2::')", '::d3:' ], | |
628 | [ "Mac->abs2rel('hd:d1:d4:d5:','hd:d1::d2:d3::')", '::d1:d4:d5:' ], | |
629 | [ "Mac->abs2rel('hd:d1:d4:d5:','hd:d1::d2:d3:')", ':::d1:d4:d5:' ], # first, resolve updirs in base | |
630 | [ "Mac->abs2rel('hd:d1:d3:','hd:d1:d2:')", '::d3:' ], | |
631 | [ "Mac->abs2rel('hd:d1::d3:','hd:d1:d2:')", ':::d3:' ], | |
632 | [ "Mac->abs2rel('hd:d3:','hd:d1:d2:')", ':::d3:' ], # same as above | |
633 | [ "Mac->abs2rel('hd:d1:d2:d3:','hd:d1:d2:')", ':d3:' ], | |
634 | [ "Mac->abs2rel('hd:d1:d2:d3::','hd:d1:d2:')", ':d3::' ], | |
638113eb | 635 | [ "Mac->abs2rel('hd1:d3:d4:d5:','hd2:d1:d2:')", 'hd1:d3:d4:d5:'], # volume mismatch |
be708cc0 JH |
636 | [ "Mac->abs2rel('hd:','hd:d1:d2:')", ':::' ], |
637 | ||
45657e91 JH |
638 | [ "Mac->rel2abs(':d3:','hd:d1:d2:')", 'hd:d1:d2:d3:' ], |
639 | [ "Mac->rel2abs(':d3:d4:','hd:d1:d2:')", 'hd:d1:d2:d3:d4:' ], | |
be708cc0 JH |
640 | [ "Mac->rel2abs('','hd:d1:d2:')", '' ], |
641 | [ "Mac->rel2abs('::','hd:d1:d2:')", 'hd:d1:d2::' ], | |
642 | [ "Mac->rel2abs('::','hd:d1:d2:file')", 'hd:d1:d2::' ],# ignore base's file portion | |
643 | [ "Mac->rel2abs(':file','hd:d1:d2:')", 'hd:d1:d2:file' ], | |
644 | [ "Mac->rel2abs('::file','hd:d1:d2:')", 'hd:d1:d2::file' ], | |
645 | [ "Mac->rel2abs('::d3:','hd:d1:d2:')", 'hd:d1:d2::d3:' ], | |
646 | [ "Mac->rel2abs('hd:','hd:d1:d2:')", 'hd:' ], # path already absolute | |
647 | [ "Mac->rel2abs('hd:d3:file','hd:d1:d2:')", 'hd:d3:file' ], | |
648 | [ "Mac->rel2abs('hd:d3:','hd:d1:file')", 'hd:d3:' ], | |
e021ab8e JH |
649 | |
650 | [ "Epoc->case_tolerant()", '1' ], | |
651 | ||
652 | [ "Epoc->canonpath('')", '' ], | |
653 | [ "Epoc->canonpath('///../../..//./././a//b/.././c/././')", '/a/b/../c' ], | |
654 | [ "Epoc->canonpath('/./')", '/' ], | |
655 | [ "Epoc->canonpath('/a/./')", '/a' ], | |
656 | ||
657 | # XXX Todo, copied from Unix, but fail. Should they? 2003-07-07 Tels | |
658 | #[ "Epoc->canonpath('/a/.')", '/a' ], | |
659 | #[ "Epoc->canonpath('/.')", '/' ], | |
660 | ||
8915552c | 661 | [ "Cygwin->case_tolerant()", '1' ], |
e4f3fca4 RU |
662 | [ "Cygwin->catfile('a','b','c')", 'a/b/c' ], |
663 | [ "Cygwin->catfile('a','b','./c')", 'a/b/c' ], | |
664 | [ "Cygwin->catfile('./a','b','c')", 'a/b/c' ], | |
665 | [ "Cygwin->catfile('c')", 'c' ], | |
666 | [ "Cygwin->catfile('./c')", 'c' ], | |
667 | ||
668 | [ "Cygwin->splitpath('file')", ',,file' ], | |
669 | [ "Cygwin->splitpath('/d1/d2/d3/')", ',/d1/d2/d3/,' ], | |
670 | [ "Cygwin->splitpath('d1/d2/d3/')", ',d1/d2/d3/,' ], | |
671 | [ "Cygwin->splitpath('/d1/d2/d3/.')", ',/d1/d2/d3/.,' ], | |
672 | [ "Cygwin->splitpath('/d1/d2/d3/..')", ',/d1/d2/d3/..,' ], | |
673 | [ "Cygwin->splitpath('/d1/d2/d3/.file')", ',/d1/d2/d3/,.file' ], | |
674 | [ "Cygwin->splitpath('d1/d2/d3/file')", ',d1/d2/d3/,file' ], | |
675 | [ "Cygwin->splitpath('/../../d1/')", ',/../../d1/,' ], | |
676 | [ "Cygwin->splitpath('/././d1/')", ',/././d1/,' ], | |
677 | ||
678 | [ "Cygwin->catpath('','','file')", 'file' ], | |
679 | [ "Cygwin->catpath('','/d1/d2/d3/','')", '/d1/d2/d3/' ], | |
680 | [ "Cygwin->catpath('','d1/d2/d3/','')", 'd1/d2/d3/' ], | |
681 | [ "Cygwin->catpath('','/d1/d2/d3/.','')", '/d1/d2/d3/.' ], | |
682 | [ "Cygwin->catpath('','/d1/d2/d3/..','')", '/d1/d2/d3/..' ], | |
683 | [ "Cygwin->catpath('','/d1/d2/d3/','.file')", '/d1/d2/d3/.file' ], | |
684 | [ "Cygwin->catpath('','d1/d2/d3/','file')", 'd1/d2/d3/file' ], | |
685 | [ "Cygwin->catpath('','/../../d1/','')", '/../../d1/' ], | |
686 | [ "Cygwin->catpath('','/././d1/','')", '/././d1/' ], | |
687 | [ "Cygwin->catpath('d1','d2/d3/','')", 'd2/d3/' ], | |
688 | [ "Cygwin->catpath('d1','d2','d3/')", 'd2/d3/' ], | |
689 | ||
690 | [ "Cygwin->splitdir('')", '' ], | |
691 | [ "Cygwin->splitdir('/d1/d2/d3/')", ',d1,d2,d3,' ], | |
692 | [ "Cygwin->splitdir('d1/d2/d3/')", 'd1,d2,d3,' ], | |
693 | [ "Cygwin->splitdir('/d1/d2/d3')", ',d1,d2,d3' ], | |
694 | [ "Cygwin->splitdir('d1/d2/d3')", 'd1,d2,d3' ], | |
695 | ||
696 | [ "Cygwin->catdir()", '' ], | |
697 | [ "Cygwin->catdir('/')", '/' ], | |
698 | [ "Cygwin->catdir('','d1','d2','d3','')", '/d1/d2/d3' ], | |
699 | [ "Cygwin->catdir('d1','d2','d3','')", 'd1/d2/d3' ], | |
700 | [ "Cygwin->catdir('','d1','d2','d3')", '/d1/d2/d3' ], | |
701 | [ "Cygwin->catdir('d1','d2','d3')", 'd1/d2/d3' ], | |
ff235dd6 | 702 | [ "Cygwin->catdir('/','d2/d3')", '/d2/d3' ], |
e021ab8e | 703 | |
e4f3fca4 RU |
704 | [ "Cygwin->canonpath('///../../..//./././a//b/.././c/././')", '/a/b/../c' ], |
705 | [ "Cygwin->canonpath('')", '' ], | |
706 | [ "Cygwin->canonpath('a/../../b/c')", 'a/../../b/c' ], | |
707 | [ "Cygwin->canonpath('/.')", '/' ], | |
708 | [ "Cygwin->canonpath('/./')", '/' ], | |
709 | [ "Cygwin->canonpath('/a/./')", '/a' ], | |
710 | [ "Cygwin->canonpath('/a/.')", '/a' ], | |
711 | [ "Cygwin->canonpath('/../../')", '/' ], | |
712 | [ "Cygwin->canonpath('/../..')", '/' ], | |
713 | ||
714 | [ "Cygwin->abs2rel('/t1/t2/t3','/t1/t2/t3')", '.' ], | |
715 | [ "Cygwin->abs2rel('/t1/t2/t4','/t1/t2/t3')", '../t4' ], | |
716 | [ "Cygwin->abs2rel('/t1/t2','/t1/t2/t3')", '..' ], | |
717 | [ "Cygwin->abs2rel('/t1/t2/t3/t4','/t1/t2/t3')", 't4' ], | |
718 | [ "Cygwin->abs2rel('/t4/t5/t6','/t1/t2/t3')", '../../../t4/t5/t6' ], | |
719 | #[ "Cygwin->abs2rel('../t4','/t1/t2/t3')", '../t4' ], | |
720 | [ "Cygwin->abs2rel('/','/t1/t2/t3')", '../../..' ], | |
721 | [ "Cygwin->abs2rel('///','/t1/t2/t3')", '../../..' ], | |
722 | [ "Cygwin->abs2rel('/.','/t1/t2/t3')", '../../..' ], | |
723 | [ "Cygwin->abs2rel('/./','/t1/t2/t3')", '../../..' ], | |
724 | #[ "Cygwin->abs2rel('../t4','/t1/t2/t3')", '../t4' ], | |
725 | [ "Cygwin->abs2rel('/t1/t2/t3', '/')", 't1/t2/t3' ], | |
726 | [ "Cygwin->abs2rel('/t1/t2/t3', '/t1')", 't2/t3' ], | |
727 | [ "Cygwin->abs2rel('t1/t2/t3', 't1')", 't2/t3' ], | |
728 | [ "Cygwin->abs2rel('t1/t2/t3', 't4')", '../t1/t2/t3' ], | |
729 | ||
730 | [ "Cygwin->rel2abs('t4','/t1/t2/t3')", '/t1/t2/t3/t4' ], | |
731 | [ "Cygwin->rel2abs('t4/t5','/t1/t2/t3')", '/t1/t2/t3/t4/t5' ], | |
732 | [ "Cygwin->rel2abs('.','/t1/t2/t3')", '/t1/t2/t3' ], | |
733 | [ "Cygwin->rel2abs('..','/t1/t2/t3')", '/t1/t2/t3/..' ], | |
734 | [ "Cygwin->rel2abs('../t4','/t1/t2/t3')", '/t1/t2/t3/../t4' ], | |
735 | [ "Cygwin->rel2abs('/t1','/t1/t2/t3')", '/t1' ], | |
bf7c0a3d | 736 | [ "Cygwin->rel2abs('//t1/t2/t3','/foo')", '//t1/t2/t3' ], |
e4f3fca4 | 737 | |
0994714a GS |
738 | ) ; |
739 | ||
cba09117 | 740 | can_ok('File::Spec::Win32', '_cwd'); |
270d1e39 | 741 | |
e021ab8e | 742 | { |
5b287435 RGS |
743 | package File::Spec::FakeWin32; |
744 | use vars qw(@ISA); | |
745 | @ISA = qw(File::Spec::Win32); | |
746 | ||
747 | sub _cwd { 'C:\\one\\two' } | |
748 | ||
749 | # Some funky stuff to override Cwd::getdcwd() for testing purposes, | |
750 | # in the limited scope of the rel2abs() method. | |
99f36a73 | 751 | if ($Cwd::VERSION && $Cwd::VERSION gt '2.17') { # Avoid a 'used only once' warning |
5b287435 RGS |
752 | local $^W; |
753 | *rel2abs = sub { | |
754 | my $self = shift; | |
755 | local $^W; | |
756 | local *Cwd::getdcwd = sub { | |
757 | return 'D:\alpha\beta' if $_[0] eq 'D:'; | |
758 | return 'C:\one\two' if $_[0] eq 'C:'; | |
759 | return; | |
760 | }; | |
761 | *Cwd::getdcwd = *Cwd::getdcwd; # Avoid a 'used only once' warning | |
762 | return $self->SUPER::rel2abs(@_); | |
763 | }; | |
764 | *rel2abs = *rel2abs; # Avoid a 'used only once' warning | |
765 | } | |
e021ab8e | 766 | } |
0994714a | 767 | |
0994714a GS |
768 | # Tries a named function with the given args and compares the result against |
769 | # an expected result. Works with functions that return scalars or arrays. | |
e5247eac NC |
770 | for ( @tests ) { |
771 | my ($function, $expected) = @$_; | |
0994714a GS |
772 | |
773 | $function =~ s#\\#\\\\#g ; | |
e021ab8e JH |
774 | $function =~ s/^([^\$].*->)/File::Spec::$1/; |
775 | my $got = join ',', eval $function; | |
0994714a | 776 | |
cba09117 NC |
777 | SKIP: { |
778 | if ($@) { | |
779 | skip "skip $function: $skip_exception", 1 | |
780 | if $@ =~ /^\Q$skip_exception/; | |
781 | is($@, '', $function); | |
782 | } else { | |
783 | is($got, $expected, $function); | |
784 | } | |
0994714a | 785 | } |
0994714a | 786 | } |
cba09117 NC |
787 | |
788 | done_testing(); |