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