Commit | Line | Data |
3149a8e4 |
1 | #!./perl |
270d1e39 |
2 | |
3 | BEGIN { |
3149a8e4 |
4 | chdir 't' if -d 't'; |
20822f61 |
5 | @INC = '../lib'; |
d5201bd2 |
6 | if ($^O eq 'MacOS') { |
7 | push @INC, "::lib:$MacPerl::Architecture"; |
8 | } |
270d1e39 |
9 | } |
2586ba89 |
10 | # Grab all of the plain routines from File::Spec |
11 | use File::Spec @File::Spec::EXPORT_OK ; |
12 | |
13 | require File::Spec::Unix ; |
14 | require File::Spec::Win32 ; |
15 | |
16 | eval { |
17 | require VMS::Filespec ; |
18 | } ; |
19 | |
20 | my $skip_exception = "Install VMS::Filespec (from vms/ext)" ; |
21 | |
22 | if ( $@ ) { |
23 | # Not pretty, but it allows testing of things not implemented soley |
24 | # on VMS. It might be better to change File::Spec::VMS to do this, |
25 | # making it more usable when running on (say) Unix but working with |
26 | # VMS paths. |
27 | eval qq- |
28 | sub File::Spec::VMS::vmsify { die "$skip_exception" } |
29 | sub File::Spec::VMS::unixify { die "$skip_exception" } |
30 | sub File::Spec::VMS::vmspath { die "$skip_exception" } |
31 | - ; |
32 | $INC{"VMS/Filespec.pm"} = 1 ; |
33 | } |
34 | require File::Spec::VMS ; |
35 | |
36 | require File::Spec::OS2 ; |
37 | require File::Spec::Mac ; |
38 | |
39 | # $root is only needed by Mac OS tests; these particular |
40 | # tests are skipped on other OSs |
41 | my $root; |
45657e91 |
42 | if ($^O eq 'MacOS') { |
2586ba89 |
43 | $root = File::Spec::Mac->rootdir(); |
44 | } |
270d1e39 |
45 | |
0994714a |
46 | # Each element in this array is a single test. Storing them this way makes |
47 | # maintenance easy, and should be OK since perl should be pretty functional |
48 | # before these tests are run. |
3149a8e4 |
49 | |
0994714a |
50 | @tests = ( |
2586ba89 |
51 | # [ Function , Expected , Platform ] |
52 | |
02961b52 |
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 |
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 |
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 |
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 |
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' ], |
93 | |
0994714a |
94 | [ "Unix->canonpath('')", '' ], |
95 | [ "Unix->canonpath('///../../..//./././a//b/.././c/././')", '/a/b/../c' ], |
6bf11762 |
96 | [ "Unix->canonpath('/.')", '/' ], |
97 | [ "Unix->canonpath('/./')", '/' ], |
98 | [ "Unix->canonpath('/a/./')", '/a' ], |
99 | [ "Unix->canonpath('/a/.')", '/a' ], |
0994714a |
100 | |
101 | [ "Unix->abs2rel('/t1/t2/t3','/t1/t2/t3')", '' ], |
102 | [ "Unix->abs2rel('/t1/t2/t4','/t1/t2/t3')", '../t4' ], |
103 | [ "Unix->abs2rel('/t1/t2','/t1/t2/t3')", '..' ], |
104 | [ "Unix->abs2rel('/t1/t2/t3/t4','/t1/t2/t3')", 't4' ], |
105 | [ "Unix->abs2rel('/t4/t5/t6','/t1/t2/t3')", '../../../t4/t5/t6' ], |
106 | #[ "Unix->abs2rel('../t4','/t1/t2/t3')", '../t4' ], |
107 | [ "Unix->abs2rel('/','/t1/t2/t3')", '../../..' ], |
108 | [ "Unix->abs2rel('///','/t1/t2/t3')", '../../..' ], |
6bf11762 |
109 | [ "Unix->abs2rel('/.','/t1/t2/t3')", '../../..' ], |
0994714a |
110 | [ "Unix->abs2rel('/./','/t1/t2/t3')", '../../..' ], |
111 | #[ "Unix->abs2rel('../t4','/t1/t2/t3')", '../t4' ], |
112 | |
113 | [ "Unix->rel2abs('t4','/t1/t2/t3')", '/t1/t2/t3/t4' ], |
114 | [ "Unix->rel2abs('t4/t5','/t1/t2/t3')", '/t1/t2/t3/t4/t5' ], |
115 | [ "Unix->rel2abs('.','/t1/t2/t3')", '/t1/t2/t3' ], |
116 | [ "Unix->rel2abs('..','/t1/t2/t3')", '/t1/t2/t3/..' ], |
117 | [ "Unix->rel2abs('../t4','/t1/t2/t3')", '/t1/t2/t3/../t4' ], |
118 | [ "Unix->rel2abs('/t1','/t1/t2/t3')", '/t1' ], |
119 | |
120 | [ "Win32->splitpath('file')", ',,file' ], |
121 | [ "Win32->splitpath('\\d1/d2\\d3/')", ',\\d1/d2\\d3/,' ], |
122 | [ "Win32->splitpath('d1/d2\\d3/')", ',d1/d2\\d3/,' ], |
123 | [ "Win32->splitpath('\\d1/d2\\d3/.')", ',\\d1/d2\\d3/.,' ], |
124 | [ "Win32->splitpath('\\d1/d2\\d3/..')", ',\\d1/d2\\d3/..,' ], |
125 | [ "Win32->splitpath('\\d1/d2\\d3/.file')", ',\\d1/d2\\d3/,.file' ], |
126 | [ "Win32->splitpath('\\d1/d2\\d3/file')", ',\\d1/d2\\d3/,file' ], |
127 | [ "Win32->splitpath('d1/d2\\d3/file')", ',d1/d2\\d3/,file' ], |
128 | [ "Win32->splitpath('C:\\d1/d2\\d3/')", 'C:,\\d1/d2\\d3/,' ], |
129 | [ "Win32->splitpath('C:d1/d2\\d3/')", 'C:,d1/d2\\d3/,' ], |
130 | [ "Win32->splitpath('C:\\d1/d2\\d3/file')", 'C:,\\d1/d2\\d3/,file' ], |
131 | [ "Win32->splitpath('C:d1/d2\\d3/file')", 'C:,d1/d2\\d3/,file' ], |
132 | [ "Win32->splitpath('C:\\../d2\\d3/file')", 'C:,\\../d2\\d3/,file' ], |
133 | [ "Win32->splitpath('C:../d2\\d3/file')", 'C:,../d2\\d3/,file' ], |
134 | [ "Win32->splitpath('\\../..\\d1/')", ',\\../..\\d1/,' ], |
135 | [ "Win32->splitpath('\\./.\\d1/')", ',\\./.\\d1/,' ], |
136 | [ "Win32->splitpath('\\\\node\\share\\d1/d2\\d3/')", '\\\\node\\share,\\d1/d2\\d3/,' ], |
137 | [ "Win32->splitpath('\\\\node\\share\\d1/d2\\d3/file')", '\\\\node\\share,\\d1/d2\\d3/,file' ], |
138 | [ "Win32->splitpath('\\\\node\\share\\d1/d2\\file')", '\\\\node\\share,\\d1/d2\\,file' ], |
139 | [ "Win32->splitpath('file',1)", ',file,' ], |
140 | [ "Win32->splitpath('\\d1/d2\\d3/',1)", ',\\d1/d2\\d3/,' ], |
141 | [ "Win32->splitpath('d1/d2\\d3/',1)", ',d1/d2\\d3/,' ], |
142 | [ "Win32->splitpath('\\\\node\\share\\d1/d2\\d3/',1)", '\\\\node\\share,\\d1/d2\\d3/,' ], |
143 | |
144 | [ "Win32->catpath('','','file')", 'file' ], |
145 | [ "Win32->catpath('','\\d1/d2\\d3/','')", '\\d1/d2\\d3/' ], |
146 | [ "Win32->catpath('','d1/d2\\d3/','')", 'd1/d2\\d3/' ], |
147 | [ "Win32->catpath('','\\d1/d2\\d3/.','')", '\\d1/d2\\d3/.' ], |
148 | [ "Win32->catpath('','\\d1/d2\\d3/..','')", '\\d1/d2\\d3/..' ], |
149 | [ "Win32->catpath('','\\d1/d2\\d3/','.file')", '\\d1/d2\\d3/.file' ], |
150 | [ "Win32->catpath('','\\d1/d2\\d3/','file')", '\\d1/d2\\d3/file' ], |
151 | [ "Win32->catpath('','d1/d2\\d3/','file')", 'd1/d2\\d3/file' ], |
152 | [ "Win32->catpath('C:','\\d1/d2\\d3/','')", 'C:\\d1/d2\\d3/' ], |
153 | [ "Win32->catpath('C:','d1/d2\\d3/','')", 'C:d1/d2\\d3/' ], |
154 | [ "Win32->catpath('C:','\\d1/d2\\d3/','file')", 'C:\\d1/d2\\d3/file' ], |
155 | [ "Win32->catpath('C:','d1/d2\\d3/','file')", 'C:d1/d2\\d3/file' ], |
156 | [ "Win32->catpath('C:','\\../d2\\d3/','file')", 'C:\\../d2\\d3/file' ], |
157 | [ "Win32->catpath('C:','../d2\\d3/','file')", 'C:../d2\\d3/file' ], |
158 | [ "Win32->catpath('','\\../..\\d1/','')", '\\../..\\d1/' ], |
159 | [ "Win32->catpath('','\\./.\\d1/','')", '\\./.\\d1/' ], |
160 | [ "Win32->catpath('\\\\node\\share','\\d1/d2\\d3/','')", '\\\\node\\share\\d1/d2\\d3/' ], |
161 | [ "Win32->catpath('\\\\node\\share','\\d1/d2\\d3/','file')", '\\\\node\\share\\d1/d2\\d3/file' ], |
162 | [ "Win32->catpath('\\\\node\\share','\\d1/d2\\','file')", '\\\\node\\share\\d1/d2\\file' ], |
163 | |
164 | [ "Win32->splitdir('')", '' ], |
165 | [ "Win32->splitdir('\\d1/d2\\d3/')", ',d1,d2,d3,' ], |
166 | [ "Win32->splitdir('d1/d2\\d3/')", 'd1,d2,d3,' ], |
167 | [ "Win32->splitdir('\\d1/d2\\d3')", ',d1,d2,d3' ], |
168 | [ "Win32->splitdir('d1/d2\\d3')", 'd1,d2,d3' ], |
169 | |
170 | [ "Win32->catdir()", '' ], |
171 | [ "Win32->catdir('')", '\\' ], |
172 | [ "Win32->catdir('/')", '\\' ], |
173 | [ "Win32->catdir('//d1','d2')", '\\\\d1\\d2' ], |
174 | [ "Win32->catdir('','/d1','d2')", '\\\\d1\\d2' ], |
175 | [ "Win32->catdir('','','/d1','d2')", '\\\\\\d1\\d2' ], |
176 | [ "Win32->catdir('','//d1','d2')", '\\\\\\d1\\d2' ], |
177 | [ "Win32->catdir('','','//d1','d2')", '\\\\\\\\d1\\d2' ], |
178 | [ "Win32->catdir('','d1','','d2','')", '\\d1\\d2' ], |
179 | [ "Win32->catdir('','d1','d2','d3','')", '\\d1\\d2\\d3' ], |
180 | [ "Win32->catdir('d1','d2','d3','')", 'd1\\d2\\d3' ], |
181 | [ "Win32->catdir('','d1','d2','d3')", '\\d1\\d2\\d3' ], |
182 | [ "Win32->catdir('d1','d2','d3')", 'd1\\d2\\d3' ], |
183 | [ "Win32->catdir('A:/d1','d2','d3')", 'A:\\d1\\d2\\d3' ], |
184 | [ "Win32->catdir('A:/d1','d2','d3','')", 'A:\\d1\\d2\\d3' ], |
185 | #[ "Win32->catdir('A:/d1','B:/d2','d3','')", 'A:\\d1\\d2\\d3' ], |
186 | [ "Win32->catdir('A:/d1','B:/d2','d3','')", 'A:\\d1\\B:\\d2\\d3' ], |
187 | [ "Win32->catdir('A:/')", 'A:\\' ], |
188 | |
02961b52 |
189 | [ "Win32->catfile('a','b','c')", 'a\\b\\c' ], |
190 | [ "Win32->catfile('a','b','.\\c')", 'a\\b\\c' ], |
191 | [ "Win32->catfile('.\\a','b','c')", 'a\\b\\c' ], |
192 | [ "Win32->catfile('c')", 'c' ], |
193 | [ "Win32->catfile('.\\c')", 'c' ], |
194 | |
0994714a |
195 | |
196 | [ "Win32->canonpath('')", '' ], |
197 | [ "Win32->canonpath('a:')", 'A:' ], |
198 | [ "Win32->canonpath('A:f')", 'A:f' ], |
199 | [ "Win32->canonpath('//a\\b//c')", '\\\\a\\b\\c' ], |
200 | [ "Win32->canonpath('/a/..../c')", '\\a\\....\\c' ], |
201 | [ "Win32->canonpath('//a/b\\c')", '\\\\a\\b\\c' ], |
202 | [ "Win32->canonpath('////')", '\\\\\\' ], |
203 | [ "Win32->canonpath('//')", '\\' ], |
204 | [ "Win32->canonpath('/.')", '\\.' ], |
205 | [ "Win32->canonpath('//a/b/../../c')", '\\\\a\\b\\..\\..\\c' ], |
206 | [ "Win32->canonpath('//a/../../c')", '\\\\a\\..\\..\\c' ], |
207 | |
9b1c7707 |
208 | ## Hmmm, we should test missing and relative base paths some day... |
209 | ## would need to cd to a known place, get the cwd() and use it I |
210 | ## think. |
0994714a |
211 | [ "Win32->abs2rel('/t1/t2/t3','/t1/t2/t3')", '' ], |
212 | [ "Win32->abs2rel('/t1/t2/t4','/t1/t2/t3')", '..\\t4' ], |
213 | [ "Win32->abs2rel('/t1/t2','/t1/t2/t3')", '..' ], |
214 | [ "Win32->abs2rel('/t1/t2/t3/t4','/t1/t2/t3')", 't4' ], |
215 | [ "Win32->abs2rel('/t4/t5/t6','/t1/t2/t3')", '..\\..\\..\\t4\\t5\\t6' ], |
216 | #[ "Win32->abs2rel('../t4','/t1/t2/t3')", '\\t1\\t2\\t3\\..\\t4' ], |
217 | [ "Win32->abs2rel('/','/t1/t2/t3')", '..\\..\\..' ], |
218 | [ "Win32->abs2rel('///','/t1/t2/t3')", '..\\..\\..' ], |
219 | [ "Win32->abs2rel('/.','/t1/t2/t3')", '..\\..\\..\\.' ], |
220 | [ "Win32->abs2rel('/./','/t1/t2/t3')", '..\\..\\..' ], |
221 | [ "Win32->abs2rel('\\\\a/t1/t2/t4','/t2/t3')", '..\\t4' ], |
222 | [ "Win32->abs2rel('//a/t1/t2/t4','/t2/t3')", '..\\t4' ], |
9b1c7707 |
223 | [ "Win32->abs2rel('A:/t1/t2/t3','B:/t1/t2/t3')",'' ], |
224 | [ "Win32->abs2rel('A:/t1/t2/t3/t4','B:/t1/t2/t3')",'t4' ], |
0994714a |
225 | |
226 | [ "Win32->rel2abs('temp','C:/')", 'C:\\temp' ], |
227 | [ "Win32->rel2abs('temp','C:/a')", 'C:\\a\\temp' ], |
228 | [ "Win32->rel2abs('temp','C:/a/')", 'C:\\a\\temp' ], |
229 | [ "Win32->rel2abs('../','C:/')", 'C:\\..' ], |
230 | [ "Win32->rel2abs('../','C:/a')", 'C:\\a\\..' ], |
231 | [ "Win32->rel2abs('temp','//prague_main/work/')", '\\\\prague_main\\work\\temp' ], |
232 | [ "Win32->rel2abs('../temp','//prague_main/work/')", '\\\\prague_main\\work\\..\\temp' ], |
233 | [ "Win32->rel2abs('temp','//prague_main/work')", '\\\\prague_main\\work\\temp' ], |
234 | [ "Win32->rel2abs('../','//prague_main/work')", '\\\\prague_main\\work\\..' ], |
235 | |
02961b52 |
236 | |
237 | [ "VMS->catfile('a','b','c')", '[.a.b]c' ], |
238 | [ "VMS->catfile('a','b','[]c')", '[.a.b]c' ], |
239 | [ "VMS->catfile('[.a]','b','c')", '[.a.b]c' ], |
240 | [ "VMS->catfile('c')", 'c' ], |
241 | [ "VMS->catfile('[]c')", 'c' ], |
242 | |
0994714a |
243 | [ "VMS->splitpath('file')", ',,file' ], |
08c7cbbb |
244 | [ "VMS->splitpath('[d1.d2.d3]')", ',[d1.d2.d3],' ], |
245 | [ "VMS->splitpath('[.d1.d2.d3]')", ',[.d1.d2.d3],' ], |
246 | [ "VMS->splitpath('[d1.d2.d3]file')", ',[d1.d2.d3],file' ], |
247 | [ "VMS->splitpath('d1/d2/d3/file')", ',[.d1.d2.d3],file' ], |
248 | [ "VMS->splitpath('/d1/d2/d3/file')", 'd1:,[d2.d3],file' ], |
249 | [ "VMS->splitpath('[.d1.d2.d3]file')", ',[.d1.d2.d3],file' ], |
250 | [ "VMS->splitpath('node::volume:[d1.d2.d3]')", 'node::volume:,[d1.d2.d3],' ], |
251 | [ "VMS->splitpath('node::volume:[d1.d2.d3]file')", 'node::volume:,[d1.d2.d3],file' ], |
252 | [ "VMS->splitpath('node\"access_spec\"::volume:[d1.d2.d3]')", 'node"access_spec"::volume:,[d1.d2.d3],' ], |
253 | [ "VMS->splitpath('node\"access_spec\"::volume:[d1.d2.d3]file')", 'node"access_spec"::volume:,[d1.d2.d3],file' ], |
0994714a |
254 | |
255 | [ "VMS->catpath('','','file')", 'file' ], |
256 | [ "VMS->catpath('','[d1.d2.d3]','')", '[d1.d2.d3]' ], |
257 | [ "VMS->catpath('','[.d1.d2.d3]','')", '[.d1.d2.d3]' ], |
258 | [ "VMS->catpath('','[d1.d2.d3]','file')", '[d1.d2.d3]file' ], |
259 | [ "VMS->catpath('','[.d1.d2.d3]','file')", '[.d1.d2.d3]file' ], |
08c7cbbb |
260 | [ "VMS->catpath('','d1/d2/d3','file')", '[.d1.d2.d3]file' ], |
261 | [ "VMS->catpath('v','d1/d2/d3','file')", 'v:[.d1.d2.d3]file' ], |
0994714a |
262 | [ "VMS->catpath('node::volume:','[d1.d2.d3]','')", 'node::volume:[d1.d2.d3]' ], |
263 | [ "VMS->catpath('node::volume:','[d1.d2.d3]','file')", 'node::volume:[d1.d2.d3]file' ], |
264 | [ "VMS->catpath('node\"access_spec\"::volume:','[d1.d2.d3]','')", 'node"access_spec"::volume:[d1.d2.d3]' ], |
265 | [ "VMS->catpath('node\"access_spec\"::volume:','[d1.d2.d3]','file')", 'node"access_spec"::volume:[d1.d2.d3]file' ], |
266 | |
267 | [ "VMS->canonpath('')", '' ], |
178326fd |
268 | [ "VMS->canonpath('volume:[d1]file')", 'volume:[d1]file' ], |
08c7cbbb |
269 | [ "VMS->canonpath('volume:[d1.-.d2.][d3.d4.-]')", 'volume:[d2.d3]' ], |
178326fd |
270 | [ "VMS->canonpath('volume:[000000.d1]d2.dir;1')", 'volume:[d1]d2.dir;1' ], |
0994714a |
271 | |
272 | [ "VMS->splitdir('')", '' ], |
273 | [ "VMS->splitdir('[]')", '' ], |
274 | [ "VMS->splitdir('d1.d2.d3')", 'd1,d2,d3' ], |
275 | [ "VMS->splitdir('[d1.d2.d3]')", 'd1,d2,d3' ], |
276 | [ "VMS->splitdir('.d1.d2.d3')", ',d1,d2,d3' ], |
277 | [ "VMS->splitdir('[.d1.d2.d3]')", ',d1,d2,d3' ], |
278 | [ "VMS->splitdir('.-.d2.d3')", ',-,d2,d3' ], |
279 | [ "VMS->splitdir('[.-.d2.d3]')", ',-,d2,d3' ], |
280 | |
08c7cbbb |
281 | [ "VMS->catdir('')", '' ], |
282 | [ "VMS->catdir('d1','d2','d3')", '[.d1.d2.d3]' ], |
283 | [ "VMS->catdir('d1','d2/','d3')", '[.d1.d2.d3]' ], |
284 | [ "VMS->catdir('','d1','d2','d3')", '[.d1.d2.d3]' ], |
285 | [ "VMS->catdir('','-','d2','d3')", '[-.d2.d3]' ], |
286 | [ "VMS->catdir('','-','','d3')", '[-.d3]' ], |
287 | [ "VMS->catdir('dir.dir','d2.dir','d3.dir')", '[.dir.d2.d3]' ], |
288 | [ "VMS->catdir('[.name]')", '[.name]' ], |
45657e91 |
289 | [ "VMS->catdir('[.name]','[.name]')", '[.name.name]'], |
0994714a |
290 | |
291 | [ "VMS->abs2rel('node::volume:[t1.t2.t3]','[t1.t2.t3]')", '' ], |
292 | [ "VMS->abs2rel('node::volume:[t1.t2.t4]','[t1.t2.t3]')", '[-.t4]' ], |
293 | [ "VMS->abs2rel('[t1.t2.t3]','[t1.t2.t3]')", '' ], |
294 | [ "VMS->abs2rel('[t1.t2.t3]file','[t1.t2.t3]')", 'file' ], |
295 | [ "VMS->abs2rel('[t1.t2.t4]','[t1.t2.t3]')", '[-.t4]' ], |
296 | [ "VMS->abs2rel('[t1.t2]file','[t1.t2.t3]')", '[-]file' ], |
297 | [ "VMS->abs2rel('[t1.t2.t3.t4]','[t1.t2.t3]')", '[t4]' ], |
08c7cbbb |
298 | [ "VMS->abs2rel('[t4.t5.t6]','[t1.t2.t3]')", '[---.t4.t5.t6]' ], |
737c380e |
299 | [ "VMS->abs2rel('[000000]','[t1.t2.t3]')", '[---]' ], |
08c7cbbb |
300 | [ "VMS->abs2rel('a:[t1.t2.t4]','[t1.t2.t3]')", '[-.t4]' ], |
301 | [ "VMS->abs2rel('[a.-.b.c.-]','[t1.t2.t3]')", '[---.b]' ], |
270d1e39 |
302 | |
0994714a |
303 | [ "VMS->rel2abs('[.t4]','[t1.t2.t3]')", '[t1.t2.t3.t4]' ], |
304 | [ "VMS->rel2abs('[.t4.t5]','[t1.t2.t3]')", '[t1.t2.t3.t4.t5]' ], |
305 | [ "VMS->rel2abs('[]','[t1.t2.t3]')", '[t1.t2.t3]' ], |
08c7cbbb |
306 | [ "VMS->rel2abs('[-]','[t1.t2.t3]')", '[t1.t2]' ], |
307 | [ "VMS->rel2abs('[-.t4]','[t1.t2.t3]')", '[t1.t2.t4]' ], |
0994714a |
308 | [ "VMS->rel2abs('[t1]','[t1.t2.t3]')", '[t1]' ], |
270d1e39 |
309 | |
0994714a |
310 | [ "OS2->catdir('A:/d1','B:/d2','d3','')", 'A:/d1/B:/d2/d3' ], |
02961b52 |
311 | |
0994714a |
312 | [ "OS2->catfile('a','b','c')", 'a/b/c' ], |
02961b52 |
313 | [ "OS2->catfile('a','b','./c')", 'a/b/c' ], |
314 | [ "OS2->catfile('./a','b','c')", 'a/b/c' ], |
315 | [ "OS2->catfile('c')", 'c' ], |
316 | [ "OS2->catfile('./c')", 'c' ], |
0994714a |
317 | |
be708cc0 |
318 | |
319 | [ "Mac->catpath('','','')", '' ], |
320 | [ "Mac->catpath('',':','')", ':' ], |
321 | [ "Mac->catpath('','::','')", '::' ], |
322 | |
323 | [ "Mac->catpath('hd','','')", 'hd:' ], |
324 | [ "Mac->catpath('hd:','','')", 'hd:' ], |
45657e91 |
325 | [ "Mac->catpath('hd:',':','')", 'hd:' ], |
be708cc0 |
326 | [ "Mac->catpath('hd:','::','')", 'hd::' ], |
327 | |
328 | [ "Mac->catpath('hd','','file')", 'hd:file' ], |
329 | [ "Mac->catpath('hd',':','file')", 'hd:file' ], |
330 | [ "Mac->catpath('hd','::','file')", 'hd::file' ], |
331 | [ "Mac->catpath('hd',':::','file')", 'hd:::file' ], |
332 | |
333 | [ "Mac->catpath('hd:','',':file')", 'hd:file' ], |
334 | [ "Mac->catpath('hd:',':',':file')", 'hd:file' ], |
335 | [ "Mac->catpath('hd:','::',':file')", 'hd::file' ], |
336 | [ "Mac->catpath('hd:',':::',':file')", 'hd:::file' ], |
337 | |
338 | [ "Mac->catpath('hd:','d1','file')", 'hd:d1:file' ], |
339 | [ "Mac->catpath('hd:',':d1:',':file')", 'hd:d1:file' ], |
340 | |
341 | [ "Mac->catpath('','d1','')", ':d1:' ], |
342 | [ "Mac->catpath('',':d1','')", ':d1:' ], |
343 | [ "Mac->catpath('',':d1:','')", ':d1:' ], |
344 | |
345 | [ "Mac->catpath('','d1','file')", ':d1:file' ], |
346 | [ "Mac->catpath('',':d1:',':file')", ':d1:file' ], |
347 | |
348 | [ "Mac->catpath('','','file')", 'file' ], |
349 | [ "Mac->catpath('','',':file')", 'file' ], # ! |
350 | [ "Mac->catpath('',':',':file')", ':file' ], # ! |
351 | |
352 | |
353 | [ "Mac->splitpath(':')", ',:,' ], |
354 | [ "Mac->splitpath('::')", ',::,' ], |
355 | [ "Mac->splitpath(':::')", ',:::,' ], |
356 | |
357 | [ "Mac->splitpath('file')", ',,file' ], |
358 | [ "Mac->splitpath(':file')", ',:,file' ], |
359 | |
360 | [ "Mac->splitpath('d1',1)", ',:d1:,' ], # dir, not volume |
361 | [ "Mac->splitpath(':d1',1)", ',:d1:,' ], |
362 | [ "Mac->splitpath(':d1:',1)", ',:d1:,' ], |
363 | [ "Mac->splitpath(':d1:')", ',:d1:,' ], |
364 | [ "Mac->splitpath(':d1:d2:d3:')", ',:d1:d2:d3:,' ], |
365 | [ "Mac->splitpath(':d1:d2:d3:',1)", ',:d1:d2:d3:,' ], |
366 | [ "Mac->splitpath(':d1:file')", ',:d1:,file' ], |
367 | [ "Mac->splitpath('::d1:file')", ',::d1:,file' ], |
368 | |
369 | [ "Mac->splitpath('hd:', 1)", 'hd:,,' ], |
370 | [ "Mac->splitpath('hd:')", 'hd:,,' ], |
371 | [ "Mac->splitpath('hd:d1:d2:')", 'hd:,:d1:d2:,' ], |
372 | [ "Mac->splitpath('hd:d1:d2',1)", 'hd:,:d1:d2:,' ], |
373 | [ "Mac->splitpath('hd:d1:d2:file')", 'hd:,:d1:d2:,file' ], |
374 | [ "Mac->splitpath('hd:d1:d2::file')", 'hd:,:d1:d2::,file' ], |
375 | [ "Mac->splitpath('hd::d1:d2:file')", 'hd:,::d1:d2:,file' ], # invalid path |
376 | [ "Mac->splitpath('hd:file')", 'hd:,,file' ], |
377 | |
2586ba89 |
378 | [ "Mac->splitdir()", '' ], |
be708cc0 |
379 | [ "Mac->splitdir('')", '' ], |
380 | [ "Mac->splitdir(':')", ':' ], |
381 | [ "Mac->splitdir('::')", '::' ], |
2586ba89 |
382 | [ "Mac->splitdir(':::')", '::,::' ], |
383 | [ "Mac->splitdir(':::d1:d2')", '::,::,d1,d2' ], |
384 | |
385 | [ "Mac->splitdir(':d1:d2:d3::')", 'd1,d2,d3,::'], |
386 | [ "Mac->splitdir(':d1:d2:d3:')", 'd1,d2,d3' ], |
387 | [ "Mac->splitdir(':d1:d2:d3')", 'd1,d2,d3' ], |
388 | |
389 | # absolute paths in splitdir() work, but you'd better use splitpath() |
390 | [ "Mac->splitdir('hd:')", 'hd:' ], |
391 | [ "Mac->splitdir('hd::')", 'hd:,::' ], # invalid path, but it works |
392 | [ "Mac->splitdir('hd::d1:')", 'hd:,::,d1' ], # invalid path, but it works |
393 | [ "Mac->splitdir('hd:d1:d2:::')", 'hd:,d1,d2,::,::' ], |
394 | [ "Mac->splitdir('hd:d1:d2::')", 'hd:,d1,d2,::' ], |
395 | [ "Mac->splitdir('hd:d1:d2:')", 'hd:,d1,d2' ], |
396 | [ "Mac->splitdir('hd:d1:d2')", 'hd:,d1,d2' ], |
397 | [ "Mac->splitdir('hd:d1::d2::')", 'hd:,d1,::,d2,::' ], |
398 | |
399 | [ "Mac->catdir()", '' ], |
400 | [ "Mac->catdir('')", $root, 'MacOS' ], # skipped on other OS |
401 | [ "Mac->catdir(':')", ':' ], |
402 | |
403 | [ "Mac->catdir('', '')", $root, 'MacOS' ], # skipped on other OS |
45657e91 |
404 | [ "Mac->catdir('', ':')", $root, 'MacOS' ], # skipped on other OS |
405 | [ "Mac->catdir(':', ':')", ':' ], |
406 | [ "Mac->catdir(':', '')", ':' ], |
2586ba89 |
407 | |
408 | [ "Mac->catdir('', '::')", $root, 'MacOS' ], # skipped on other OS |
45657e91 |
409 | [ "Mac->catdir(':', '::')", '::' ], |
2586ba89 |
410 | |
45657e91 |
411 | [ "Mac->catdir('::', '')", '::' ], |
412 | [ "Mac->catdir('::', ':')", '::' ], |
2586ba89 |
413 | |
45657e91 |
414 | [ "Mac->catdir('::', '::')", ':::' ], |
2586ba89 |
415 | |
416 | [ "Mac->catdir(':d1')", ':d1:' ], |
417 | [ "Mac->catdir(':d1:')", ':d1:' ], |
418 | [ "Mac->catdir(':d1','d2')", ':d1:d2:' ], |
419 | [ "Mac->catdir(':d1',':d2')", ':d1:d2:' ], |
420 | [ "Mac->catdir(':d1',':d2:')", ':d1:d2:' ], |
421 | [ "Mac->catdir(':d1',':d2::')", ':d1:d2::' ], |
422 | [ "Mac->catdir(':',':d1',':d2')", ':d1:d2:' ], |
423 | [ "Mac->catdir('::',':d1',':d2')", '::d1:d2:' ], |
424 | [ "Mac->catdir('::','::',':d1',':d2')", ':::d1:d2:' ], |
425 | [ "Mac->catdir(':',':',':d1',':d2')", ':d1:d2:' ], |
426 | [ "Mac->catdir('::',':',':d1',':d2')", '::d1:d2:' ], |
427 | |
428 | [ "Mac->catdir('d1')", ':d1:' ], |
429 | [ "Mac->catdir('d1','d2','d3')", ':d1:d2:d3:' ], |
430 | [ "Mac->catdir('d1','d2/','d3')", ':d1:d2/:d3:' ], |
431 | [ "Mac->catdir('d1','',':d2')", ':d1:d2:' ], |
432 | [ "Mac->catdir('d1',':',':d2')", ':d1:d2:' ], |
433 | [ "Mac->catdir('d1','::',':d2')", ':d1::d2:' ], |
434 | [ "Mac->catdir('d1',':::',':d2')", ':d1:::d2:' ], |
435 | [ "Mac->catdir('d1','::','::',':d2')", ':d1:::d2:' ], |
436 | [ "Mac->catdir('d1','d2')", ':d1:d2:' ], |
437 | [ "Mac->catdir('d1','d2', '')", ':d1:d2:' ], |
438 | [ "Mac->catdir('d1','d2', ':')", ':d1:d2:' ], |
439 | [ "Mac->catdir('d1','d2', '::')", ':d1:d2::' ], |
440 | [ "Mac->catdir('d1','d2','','')", ':d1:d2:' ], |
441 | [ "Mac->catdir('d1','d2',':','::')", ':d1:d2::' ], |
442 | [ "Mac->catdir('d1','d2','::','::')", ':d1:d2:::' ], |
443 | [ "Mac->catdir('d1',':d2')", ':d1:d2:' ], |
444 | [ "Mac->catdir('d1',':d2:')", ':d1:d2:' ], |
445 | |
446 | [ "Mac->catdir('','d1','d2','d3')", $root . 'd1:d2:d3:', 'MacOS' ], # skipped on other OS |
447 | [ "Mac->catdir('',':','d1','d2')", $root . 'd1:d2:' , 'MacOS' ], # skipped on other OS |
448 | [ "Mac->catdir('','::','d1','d2')", $root . 'd1:d2:' , 'MacOS' ], # skipped on other OS |
449 | [ "Mac->catdir('',':','','d1')", $root . 'd1:' , 'MacOS' ], # skipped on other OS |
450 | [ "Mac->catdir('', ':d1',':d2')", $root . 'd1:d2:' , 'MacOS' ], # skipped on other OS |
451 | [ "Mac->catdir('','',':d1',':d2')", $root . 'd1:d2:' , 'MacOS' ], # skipped on other OS |
be708cc0 |
452 | |
be708cc0 |
453 | [ "Mac->catdir('hd:',':d1')", 'hd:d1:' ], |
454 | [ "Mac->catdir('hd:d1:',':d2')", 'hd:d1:d2:' ], |
455 | [ "Mac->catdir('hd:','d1')", 'hd:d1:' ], |
be708cc0 |
456 | [ "Mac->catdir('hd:d1:',':d2')", 'hd:d1:d2:' ], |
457 | [ "Mac->catdir('hd:d1:',':d2:')", 'hd:d1:d2:' ], |
458 | |
45657e91 |
459 | [ "Mac->catfile()", '' ], |
2586ba89 |
460 | [ "Mac->catfile('')", '' ], |
45657e91 |
461 | [ "Mac->catfile('', '')", $root , 'MacOS' ], # skipped on other OS |
2586ba89 |
462 | [ "Mac->catfile('', 'file')", $root . 'file', 'MacOS' ], # skipped on other OS |
463 | [ "Mac->catfile(':')", ':' ], |
464 | [ "Mac->catfile(':', '')", ':' ], |
be708cc0 |
465 | |
2586ba89 |
466 | [ "Mac->catfile('d1','d2','file')", ':d1:d2:file' ], |
467 | [ "Mac->catfile('d1','d2',':file')", ':d1:d2:file' ], |
45657e91 |
468 | [ "Mac->catfile('file')", 'file' ], |
469 | [ "Mac->catfile(':', 'file')", ':file' ], |
470 | |
0994714a |
471 | [ "Mac->canonpath('')", '' ], |
472 | [ "Mac->canonpath(':')", ':' ], |
473 | [ "Mac->canonpath('::')", '::' ], |
474 | [ "Mac->canonpath('a::')", 'a::' ], |
475 | [ "Mac->canonpath(':a::')", ':a::' ], |
476 | |
be708cc0 |
477 | [ "Mac->abs2rel('hd:d1:d2:','hd:d1:d2:')", ':' ], |
478 | [ "Mac->abs2rel('hd:d1:d2:','hd:d1:d2:file')", ':' ], # ignore base's file portion |
45657e91 |
479 | [ "Mac->abs2rel('hd:d1:d2:file','hd:d1:d2:')", ':file' ], |
be708cc0 |
480 | [ "Mac->abs2rel('hd:d1:','hd:d1:d2:')", '::' ], |
481 | [ "Mac->abs2rel('hd:d3:','hd:d1:d2:')", ':::d3:' ], |
482 | [ "Mac->abs2rel('hd:d3:','hd:d1:d2::')", '::d3:' ], |
483 | [ "Mac->abs2rel('hd:d1:d4:d5:','hd:d1::d2:d3::')", '::d1:d4:d5:' ], |
484 | [ "Mac->abs2rel('hd:d1:d4:d5:','hd:d1::d2:d3:')", ':::d1:d4:d5:' ], # first, resolve updirs in base |
485 | [ "Mac->abs2rel('hd:d1:d3:','hd:d1:d2:')", '::d3:' ], |
486 | [ "Mac->abs2rel('hd:d1::d3:','hd:d1:d2:')", ':::d3:' ], |
487 | [ "Mac->abs2rel('hd:d3:','hd:d1:d2:')", ':::d3:' ], # same as above |
488 | [ "Mac->abs2rel('hd:d1:d2:d3:','hd:d1:d2:')", ':d3:' ], |
489 | [ "Mac->abs2rel('hd:d1:d2:d3::','hd:d1:d2:')", ':d3::' ], |
2586ba89 |
490 | [ "Mac->abs2rel('hd1:d3:d4:d5:','hd2:d1:d2:')", ':::d3:d4:d5:' ], # ignore base's volume |
be708cc0 |
491 | [ "Mac->abs2rel('hd:','hd:d1:d2:')", ':::' ], |
492 | |
45657e91 |
493 | [ "Mac->rel2abs(':d3:','hd:d1:d2:')", 'hd:d1:d2:d3:' ], |
494 | [ "Mac->rel2abs(':d3:d4:','hd:d1:d2:')", 'hd:d1:d2:d3:d4:' ], |
be708cc0 |
495 | [ "Mac->rel2abs('','hd:d1:d2:')", '' ], |
496 | [ "Mac->rel2abs('::','hd:d1:d2:')", 'hd:d1:d2::' ], |
497 | [ "Mac->rel2abs('::','hd:d1:d2:file')", 'hd:d1:d2::' ],# ignore base's file portion |
498 | [ "Mac->rel2abs(':file','hd:d1:d2:')", 'hd:d1:d2:file' ], |
499 | [ "Mac->rel2abs('::file','hd:d1:d2:')", 'hd:d1:d2::file' ], |
500 | [ "Mac->rel2abs('::d3:','hd:d1:d2:')", 'hd:d1:d2::d3:' ], |
501 | [ "Mac->rel2abs('hd:','hd:d1:d2:')", 'hd:' ], # path already absolute |
502 | [ "Mac->rel2abs('hd:d3:file','hd:d1:d2:')", 'hd:d3:file' ], |
503 | [ "Mac->rel2abs('hd:d3:','hd:d1:file')", 'hd:d3:' ], |
0994714a |
504 | ) ; |
505 | |
270d1e39 |
506 | |
0994714a |
507 | print "1..", scalar( @tests ), "\n" ; |
508 | |
509 | my $current_test= 1 ; |
510 | |
0994714a |
511 | # Test out the class methods |
512 | for ( @tests ) { |
513 | tryfunc( @$_ ) ; |
270d1e39 |
514 | } |
515 | |
0994714a |
516 | |
0994714a |
517 | # |
518 | # Tries a named function with the given args and compares the result against |
519 | # an expected result. Works with functions that return scalars or arrays. |
520 | # |
521 | sub tryfunc { |
522 | my $function = shift ; |
523 | my $expected = shift ; |
f6a53ef2 |
524 | my $platform = shift ; |
525 | |
526 | if ($platform && $^O ne $platform) { |
527 | print "ok $current_test # skipped: $function\n" ; |
528 | ++$current_test ; |
529 | return; |
530 | } |
0994714a |
531 | |
532 | $function =~ s#\\#\\\\#g ; |
533 | |
534 | my $got ; |
535 | if ( $function =~ /^[^\$].*->/ ) { |
536 | $got = eval( "join( ',', File::Spec::$function )" ) ; |
537 | } |
538 | else { |
539 | $got = eval( "join( ',', $function )" ) ; |
540 | } |
541 | |
542 | if ( $@ ) { |
d7bc03f0 |
543 | if ( substr( $@, 0, length $skip_exception ) eq $skip_exception ) { |
544 | chomp $@ ; |
545 | print "ok $current_test # skip $function: $@\n" ; |
0994714a |
546 | } |
547 | else { |
548 | chomp $@ ; |
549 | print "not ok $current_test # $function: $@\n" ; |
550 | } |
551 | } |
552 | elsif ( !defined( $got ) || $got ne $expected ) { |
553 | print "not ok $current_test # $function: got '$got', expected '$expected'\n" ; |
554 | } |
555 | else { |
556 | print "ok $current_test # $function\n" ; |
557 | } |
558 | ++$current_test ; |
559 | } |