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