Commit | Line | Data |
---|---|---|
3149a8e4 | 1 | #!./perl |
270d1e39 GS |
2 | |
3 | BEGIN { | |
3149a8e4 GS |
4 | $^O = ''; |
5 | chdir 't' if -d 't'; | |
93430cb4 | 6 | unshift @INC, '../lib'; |
270d1e39 GS |
7 | } |
8 | ||
0994714a GS |
9 | # Each element in this array is a single test. Storing them this way makes |
10 | # maintenance easy, and should be OK since perl should be pretty functional | |
11 | # before these tests are run. | |
3149a8e4 | 12 | |
0994714a GS |
13 | @tests = ( |
14 | # Function Expected | |
15 | [ "Unix->catfile('a','b','c')", 'a/b/c' ], | |
270d1e39 | 16 | |
0994714a GS |
17 | [ "Unix->splitpath('file')", ',,file' ], |
18 | [ "Unix->splitpath('/d1/d2/d3/')", ',/d1/d2/d3/,' ], | |
19 | [ "Unix->splitpath('d1/d2/d3/')", ',d1/d2/d3/,' ], | |
20 | [ "Unix->splitpath('/d1/d2/d3/.')", ',/d1/d2/d3/.,' ], | |
21 | [ "Unix->splitpath('/d1/d2/d3/..')", ',/d1/d2/d3/..,' ], | |
22 | [ "Unix->splitpath('/d1/d2/d3/.file')", ',/d1/d2/d3/,.file' ], | |
23 | [ "Unix->splitpath('d1/d2/d3/file')", ',d1/d2/d3/,file' ], | |
24 | [ "Unix->splitpath('/../../d1/')", ',/../../d1/,' ], | |
25 | [ "Unix->splitpath('/././d1/')", ',/././d1/,' ], | |
270d1e39 | 26 | |
0994714a GS |
27 | [ "Unix->catpath('','','file')", 'file' ], |
28 | [ "Unix->catpath('','/d1/d2/d3/','')", '/d1/d2/d3/' ], | |
29 | [ "Unix->catpath('','d1/d2/d3/','')", 'd1/d2/d3/' ], | |
30 | [ "Unix->catpath('','/d1/d2/d3/.','')", '/d1/d2/d3/.' ], | |
31 | [ "Unix->catpath('','/d1/d2/d3/..','')", '/d1/d2/d3/..' ], | |
32 | [ "Unix->catpath('','/d1/d2/d3/','.file')", '/d1/d2/d3/.file' ], | |
33 | [ "Unix->catpath('','d1/d2/d3/','file')", 'd1/d2/d3/file' ], | |
34 | [ "Unix->catpath('','/../../d1/','')", '/../../d1/' ], | |
35 | [ "Unix->catpath('','/././d1/','')", '/././d1/' ], | |
36 | [ "Unix->catpath('d1','d2/d3/','')", 'd2/d3/' ], | |
37 | [ "Unix->catpath('d1','d2','d3/')", 'd2/d3/' ], | |
270d1e39 | 38 | |
0994714a GS |
39 | [ "Unix->splitdir('')", '' ], |
40 | [ "Unix->splitdir('/d1/d2/d3/')", ',d1,d2,d3,' ], | |
41 | [ "Unix->splitdir('d1/d2/d3/')", 'd1,d2,d3,' ], | |
42 | [ "Unix->splitdir('/d1/d2/d3')", ',d1,d2,d3' ], | |
43 | [ "Unix->splitdir('d1/d2/d3')", 'd1,d2,d3' ], | |
270d1e39 | 44 | |
0994714a GS |
45 | [ "Unix->catdir()", '' ], |
46 | [ "Unix->catdir('/')", '/' ], | |
47 | [ "Unix->catdir('','d1','d2','d3','')", '/d1/d2/d3' ], | |
48 | [ "Unix->catdir('d1','d2','d3','')", 'd1/d2/d3' ], | |
49 | [ "Unix->catdir('','d1','d2','d3')", '/d1/d2/d3' ], | |
50 | [ "Unix->catdir('d1','d2','d3')", 'd1/d2/d3' ], | |
51 | ||
52 | [ "Unix->catfile('a','b','c')", 'a/b/c' ], | |
53 | ||
54 | [ "Unix->canonpath('')", '' ], | |
55 | [ "Unix->canonpath('///../../..//./././a//b/.././c/././')", '/a/b/../c' ], | |
56 | [ "Unix->canonpath('/.')", '/.' ], | |
57 | ||
58 | [ "Unix->abs2rel('/t1/t2/t3','/t1/t2/t3')", '' ], | |
59 | [ "Unix->abs2rel('/t1/t2/t4','/t1/t2/t3')", '../t4' ], | |
60 | [ "Unix->abs2rel('/t1/t2','/t1/t2/t3')", '..' ], | |
61 | [ "Unix->abs2rel('/t1/t2/t3/t4','/t1/t2/t3')", 't4' ], | |
62 | [ "Unix->abs2rel('/t4/t5/t6','/t1/t2/t3')", '../../../t4/t5/t6' ], | |
63 | #[ "Unix->abs2rel('../t4','/t1/t2/t3')", '../t4' ], | |
64 | [ "Unix->abs2rel('/','/t1/t2/t3')", '../../..' ], | |
65 | [ "Unix->abs2rel('///','/t1/t2/t3')", '../../..' ], | |
66 | [ "Unix->abs2rel('/.','/t1/t2/t3')", '../../../.' ], | |
67 | [ "Unix->abs2rel('/./','/t1/t2/t3')", '../../..' ], | |
68 | #[ "Unix->abs2rel('../t4','/t1/t2/t3')", '../t4' ], | |
69 | ||
70 | [ "Unix->rel2abs('t4','/t1/t2/t3')", '/t1/t2/t3/t4' ], | |
71 | [ "Unix->rel2abs('t4/t5','/t1/t2/t3')", '/t1/t2/t3/t4/t5' ], | |
72 | [ "Unix->rel2abs('.','/t1/t2/t3')", '/t1/t2/t3' ], | |
73 | [ "Unix->rel2abs('..','/t1/t2/t3')", '/t1/t2/t3/..' ], | |
74 | [ "Unix->rel2abs('../t4','/t1/t2/t3')", '/t1/t2/t3/../t4' ], | |
75 | [ "Unix->rel2abs('/t1','/t1/t2/t3')", '/t1' ], | |
76 | ||
77 | [ "Win32->splitpath('file')", ',,file' ], | |
78 | [ "Win32->splitpath('\\d1/d2\\d3/')", ',\\d1/d2\\d3/,' ], | |
79 | [ "Win32->splitpath('d1/d2\\d3/')", ',d1/d2\\d3/,' ], | |
80 | [ "Win32->splitpath('\\d1/d2\\d3/.')", ',\\d1/d2\\d3/.,' ], | |
81 | [ "Win32->splitpath('\\d1/d2\\d3/..')", ',\\d1/d2\\d3/..,' ], | |
82 | [ "Win32->splitpath('\\d1/d2\\d3/.file')", ',\\d1/d2\\d3/,.file' ], | |
83 | [ "Win32->splitpath('\\d1/d2\\d3/file')", ',\\d1/d2\\d3/,file' ], | |
84 | [ "Win32->splitpath('d1/d2\\d3/file')", ',d1/d2\\d3/,file' ], | |
85 | [ "Win32->splitpath('C:\\d1/d2\\d3/')", 'C:,\\d1/d2\\d3/,' ], | |
86 | [ "Win32->splitpath('C:d1/d2\\d3/')", 'C:,d1/d2\\d3/,' ], | |
87 | [ "Win32->splitpath('C:\\d1/d2\\d3/file')", 'C:,\\d1/d2\\d3/,file' ], | |
88 | [ "Win32->splitpath('C:d1/d2\\d3/file')", 'C:,d1/d2\\d3/,file' ], | |
89 | [ "Win32->splitpath('C:\\../d2\\d3/file')", 'C:,\\../d2\\d3/,file' ], | |
90 | [ "Win32->splitpath('C:../d2\\d3/file')", 'C:,../d2\\d3/,file' ], | |
91 | [ "Win32->splitpath('\\../..\\d1/')", ',\\../..\\d1/,' ], | |
92 | [ "Win32->splitpath('\\./.\\d1/')", ',\\./.\\d1/,' ], | |
93 | [ "Win32->splitpath('\\\\node\\share\\d1/d2\\d3/')", '\\\\node\\share,\\d1/d2\\d3/,' ], | |
94 | [ "Win32->splitpath('\\\\node\\share\\d1/d2\\d3/file')", '\\\\node\\share,\\d1/d2\\d3/,file' ], | |
95 | [ "Win32->splitpath('\\\\node\\share\\d1/d2\\file')", '\\\\node\\share,\\d1/d2\\,file' ], | |
96 | [ "Win32->splitpath('file',1)", ',file,' ], | |
97 | [ "Win32->splitpath('\\d1/d2\\d3/',1)", ',\\d1/d2\\d3/,' ], | |
98 | [ "Win32->splitpath('d1/d2\\d3/',1)", ',d1/d2\\d3/,' ], | |
99 | [ "Win32->splitpath('\\\\node\\share\\d1/d2\\d3/',1)", '\\\\node\\share,\\d1/d2\\d3/,' ], | |
100 | ||
101 | [ "Win32->catpath('','','file')", 'file' ], | |
102 | [ "Win32->catpath('','\\d1/d2\\d3/','')", '\\d1/d2\\d3/' ], | |
103 | [ "Win32->catpath('','d1/d2\\d3/','')", 'd1/d2\\d3/' ], | |
104 | [ "Win32->catpath('','\\d1/d2\\d3/.','')", '\\d1/d2\\d3/.' ], | |
105 | [ "Win32->catpath('','\\d1/d2\\d3/..','')", '\\d1/d2\\d3/..' ], | |
106 | [ "Win32->catpath('','\\d1/d2\\d3/','.file')", '\\d1/d2\\d3/.file' ], | |
107 | [ "Win32->catpath('','\\d1/d2\\d3/','file')", '\\d1/d2\\d3/file' ], | |
108 | [ "Win32->catpath('','d1/d2\\d3/','file')", 'd1/d2\\d3/file' ], | |
109 | [ "Win32->catpath('C:','\\d1/d2\\d3/','')", 'C:\\d1/d2\\d3/' ], | |
110 | [ "Win32->catpath('C:','d1/d2\\d3/','')", 'C:d1/d2\\d3/' ], | |
111 | [ "Win32->catpath('C:','\\d1/d2\\d3/','file')", 'C:\\d1/d2\\d3/file' ], | |
112 | [ "Win32->catpath('C:','d1/d2\\d3/','file')", 'C:d1/d2\\d3/file' ], | |
113 | [ "Win32->catpath('C:','\\../d2\\d3/','file')", 'C:\\../d2\\d3/file' ], | |
114 | [ "Win32->catpath('C:','../d2\\d3/','file')", 'C:../d2\\d3/file' ], | |
115 | [ "Win32->catpath('','\\../..\\d1/','')", '\\../..\\d1/' ], | |
116 | [ "Win32->catpath('','\\./.\\d1/','')", '\\./.\\d1/' ], | |
117 | [ "Win32->catpath('\\\\node\\share','\\d1/d2\\d3/','')", '\\\\node\\share\\d1/d2\\d3/' ], | |
118 | [ "Win32->catpath('\\\\node\\share','\\d1/d2\\d3/','file')", '\\\\node\\share\\d1/d2\\d3/file' ], | |
119 | [ "Win32->catpath('\\\\node\\share','\\d1/d2\\','file')", '\\\\node\\share\\d1/d2\\file' ], | |
120 | ||
121 | [ "Win32->splitdir('')", '' ], | |
122 | [ "Win32->splitdir('\\d1/d2\\d3/')", ',d1,d2,d3,' ], | |
123 | [ "Win32->splitdir('d1/d2\\d3/')", 'd1,d2,d3,' ], | |
124 | [ "Win32->splitdir('\\d1/d2\\d3')", ',d1,d2,d3' ], | |
125 | [ "Win32->splitdir('d1/d2\\d3')", 'd1,d2,d3' ], | |
126 | ||
127 | [ "Win32->catdir()", '' ], | |
128 | [ "Win32->catdir('')", '\\' ], | |
129 | [ "Win32->catdir('/')", '\\' ], | |
130 | [ "Win32->catdir('//d1','d2')", '\\\\d1\\d2' ], | |
131 | [ "Win32->catdir('','/d1','d2')", '\\\\d1\\d2' ], | |
132 | [ "Win32->catdir('','','/d1','d2')", '\\\\\\d1\\d2' ], | |
133 | [ "Win32->catdir('','//d1','d2')", '\\\\\\d1\\d2' ], | |
134 | [ "Win32->catdir('','','//d1','d2')", '\\\\\\\\d1\\d2' ], | |
135 | [ "Win32->catdir('','d1','','d2','')", '\\d1\\d2' ], | |
136 | [ "Win32->catdir('','d1','d2','d3','')", '\\d1\\d2\\d3' ], | |
137 | [ "Win32->catdir('d1','d2','d3','')", 'd1\\d2\\d3' ], | |
138 | [ "Win32->catdir('','d1','d2','d3')", '\\d1\\d2\\d3' ], | |
139 | [ "Win32->catdir('d1','d2','d3')", 'd1\\d2\\d3' ], | |
140 | [ "Win32->catdir('A:/d1','d2','d3')", 'A:\\d1\\d2\\d3' ], | |
141 | [ "Win32->catdir('A:/d1','d2','d3','')", 'A:\\d1\\d2\\d3' ], | |
142 | #[ "Win32->catdir('A:/d1','B:/d2','d3','')", 'A:\\d1\\d2\\d3' ], | |
143 | [ "Win32->catdir('A:/d1','B:/d2','d3','')", 'A:\\d1\\B:\\d2\\d3' ], | |
144 | [ "Win32->catdir('A:/')", 'A:\\' ], | |
145 | ||
146 | [ "Win32->catfile('a','b','c')", 'a\\b\\c' ], | |
147 | ||
148 | [ "Win32->canonpath('')", '' ], | |
149 | [ "Win32->canonpath('a:')", 'A:' ], | |
150 | [ "Win32->canonpath('A:f')", 'A:f' ], | |
151 | [ "Win32->canonpath('//a\\b//c')", '\\\\a\\b\\c' ], | |
152 | [ "Win32->canonpath('/a/..../c')", '\\a\\....\\c' ], | |
153 | [ "Win32->canonpath('//a/b\\c')", '\\\\a\\b\\c' ], | |
154 | [ "Win32->canonpath('////')", '\\\\\\' ], | |
155 | [ "Win32->canonpath('//')", '\\' ], | |
156 | [ "Win32->canonpath('/.')", '\\.' ], | |
157 | [ "Win32->canonpath('//a/b/../../c')", '\\\\a\\b\\..\\..\\c' ], | |
158 | [ "Win32->canonpath('//a/../../c')", '\\\\a\\..\\..\\c' ], | |
159 | ||
160 | [ "Win32->abs2rel('/t1/t2/t3','/t1/t2/t3')", '' ], | |
161 | [ "Win32->abs2rel('/t1/t2/t4','/t1/t2/t3')", '..\\t4' ], | |
162 | [ "Win32->abs2rel('/t1/t2','/t1/t2/t3')", '..' ], | |
163 | [ "Win32->abs2rel('/t1/t2/t3/t4','/t1/t2/t3')", 't4' ], | |
164 | [ "Win32->abs2rel('/t4/t5/t6','/t1/t2/t3')", '..\\..\\..\\t4\\t5\\t6' ], | |
165 | #[ "Win32->abs2rel('../t4','/t1/t2/t3')", '\\t1\\t2\\t3\\..\\t4' ], | |
166 | [ "Win32->abs2rel('/','/t1/t2/t3')", '..\\..\\..' ], | |
167 | [ "Win32->abs2rel('///','/t1/t2/t3')", '..\\..\\..' ], | |
168 | [ "Win32->abs2rel('/.','/t1/t2/t3')", '..\\..\\..\\.' ], | |
169 | [ "Win32->abs2rel('/./','/t1/t2/t3')", '..\\..\\..' ], | |
170 | [ "Win32->abs2rel('\\\\a/t1/t2/t4','/t2/t3')", '..\\t4' ], | |
171 | [ "Win32->abs2rel('//a/t1/t2/t4','/t2/t3')", '..\\t4' ], | |
172 | ||
173 | [ "Win32->rel2abs('temp','C:/')", 'C:\\temp' ], | |
174 | [ "Win32->rel2abs('temp','C:/a')", 'C:\\a\\temp' ], | |
175 | [ "Win32->rel2abs('temp','C:/a/')", 'C:\\a\\temp' ], | |
176 | [ "Win32->rel2abs('../','C:/')", 'C:\\..' ], | |
177 | [ "Win32->rel2abs('../','C:/a')", 'C:\\a\\..' ], | |
178 | [ "Win32->rel2abs('temp','//prague_main/work/')", '\\\\prague_main\\work\\temp' ], | |
179 | [ "Win32->rel2abs('../temp','//prague_main/work/')", '\\\\prague_main\\work\\..\\temp' ], | |
180 | [ "Win32->rel2abs('temp','//prague_main/work')", '\\\\prague_main\\work\\temp' ], | |
181 | [ "Win32->rel2abs('../','//prague_main/work')", '\\\\prague_main\\work\\..' ], | |
182 | ||
183 | [ "VMS->splitpath('file')", ',,file' ], | |
184 | [ "VMS->splitpath('[d1.d2.d3]')", ',d1.d2.d3,' ], | |
185 | [ "VMS->splitpath('[.d1.d2.d3]')", ',.d1.d2.d3,' ], | |
186 | [ "VMS->splitpath('[d1.d2.d3]file')", ',d1.d2.d3,file' ], | |
187 | [ "VMS->splitpath('d1/d2/d3/file')", ',d1/d2/d3/,file' ], | |
188 | [ "VMS->splitpath('/d1/d2/d3/file')", '/d1,/d2/d3/,file' ], | |
189 | [ "VMS->splitpath('[.d1.d2.d3]file')", ',.d1.d2.d3,file' ], | |
190 | [ "VMS->splitpath('node::volume:[d1.d2.d3]')", 'node::volume:,d1.d2.d3,' ], | |
191 | [ "VMS->splitpath('node::volume:[d1.d2.d3]file')", 'node::volume:,d1.d2.d3,file' ], | |
192 | [ "VMS->splitpath('node\"access_spec\"::volume:[d1.d2.d3]')", 'node"access_spec"::volume:,d1.d2.d3,' ], | |
193 | [ "VMS->splitpath('node\"access_spec\"::volume:[d1.d2.d3]file')", 'node"access_spec"::volume:,d1.d2.d3,file' ], | |
194 | ||
195 | [ "VMS->catpath('','','file')", 'file' ], | |
196 | [ "VMS->catpath('','[d1.d2.d3]','')", '[d1.d2.d3]' ], | |
197 | [ "VMS->catpath('','[.d1.d2.d3]','')", '[.d1.d2.d3]' ], | |
198 | [ "VMS->catpath('','[d1.d2.d3]','file')", '[d1.d2.d3]file' ], | |
199 | [ "VMS->catpath('','[.d1.d2.d3]','file')", '[.d1.d2.d3]file' ], | |
200 | [ "VMS->catpath('','d1/d2/d3','file')", 'd1/d2/d3/file' ], | |
201 | [ "VMS->catpath('v','d1/d2/d3','file')", 'd1/d2/d3/file' ], | |
202 | [ "VMS->catpath('node::volume:','[d1.d2.d3]','')", 'node::volume:[d1.d2.d3]' ], | |
203 | [ "VMS->catpath('node::volume:','[d1.d2.d3]','file')", 'node::volume:[d1.d2.d3]file' ], | |
204 | [ "VMS->catpath('node\"access_spec\"::volume:','[d1.d2.d3]','')", 'node"access_spec"::volume:[d1.d2.d3]' ], | |
205 | [ "VMS->catpath('node\"access_spec\"::volume:','[d1.d2.d3]','file')", 'node"access_spec"::volume:[d1.d2.d3]file' ], | |
206 | ||
207 | [ "VMS->canonpath('')", '' ], | |
178326fd CB |
208 | [ "VMS->canonpath('volume:[d1]file')", 'volume:[d1]file' ], |
209 | [ "VMS->canonpath('volume:[d1.-.d2.][d3.d4.-]')", 'volume:[d1.-.d2.d3.d4.-]' ], | |
178326fd | 210 | [ "VMS->canonpath('volume:[000000.d1]d2.dir;1')", 'volume:[d1]d2.dir;1' ], |
0994714a GS |
211 | |
212 | [ "VMS->splitdir('')", '' ], | |
213 | [ "VMS->splitdir('[]')", '' ], | |
214 | [ "VMS->splitdir('d1.d2.d3')", 'd1,d2,d3' ], | |
215 | [ "VMS->splitdir('[d1.d2.d3]')", 'd1,d2,d3' ], | |
216 | [ "VMS->splitdir('.d1.d2.d3')", ',d1,d2,d3' ], | |
217 | [ "VMS->splitdir('[.d1.d2.d3]')", ',d1,d2,d3' ], | |
218 | [ "VMS->splitdir('.-.d2.d3')", ',-,d2,d3' ], | |
219 | [ "VMS->splitdir('[.-.d2.d3]')", ',-,d2,d3' ], | |
220 | ||
f6a53ef2 GS |
221 | # these appear to need VMS::Filespec, which won't work on other platforms |
222 | [ "VMS->canonpath('///../../..//./././a//b/.././c/././')", '/a/b/../c', 'VMS' ], | |
223 | [ "VMS->catdir('d1','d2','d3')", '[.d1.d2.d3]', 'VMS' ], | |
224 | [ "VMS->catdir('d1','d2/','d3')", '[.d1.d2.d3]', 'VMS' ], | |
225 | [ "VMS->catdir('','d1','d2','d3')", '[.d1.d2.d3]', 'VMS' ], | |
226 | [ "VMS->catdir('','-','d2','d3')", '[-.d2.d3]', 'VMS' ], | |
227 | [ "VMS->catdir('','-','','d3')", '[-.d3]', 'VMS' ], | |
228 | [ "VMS->catdir('[]','<->','[]','[d3]')", '[-.d3]', 'VMS' ], | |
229 | [ "VMS->catdir('dir.dir','d2.dir','d3.dir')", '[.dir.d2.d3]','VMS' ], | |
230 | [ "VMS->catdir('[.name]')", '[.name]', 'VMS' ], | |
231 | [ "VMS->catdir('[.name]','[.name]')", '[.name.name]','VMS' ], | |
232 | ||
233 | #[ "VMS->catdir('')", '[]' ], | |
234 | #[ "VMS->catdir('a:[.name]','b:[.name]')", '[.name.name]' ], | |
0994714a GS |
235 | |
236 | [ "VMS->abs2rel('node::volume:[t1.t2.t3]','[t1.t2.t3]')", '' ], | |
237 | [ "VMS->abs2rel('node::volume:[t1.t2.t4]','[t1.t2.t3]')", '[-.t4]' ], | |
238 | [ "VMS->abs2rel('[t1.t2.t3]','[t1.t2.t3]')", '' ], | |
239 | [ "VMS->abs2rel('[t1.t2.t3]file','[t1.t2.t3]')", 'file' ], | |
240 | [ "VMS->abs2rel('[t1.t2.t4]','[t1.t2.t3]')", '[-.t4]' ], | |
241 | [ "VMS->abs2rel('[t1.t2]file','[t1.t2.t3]')", '[-]file' ], | |
242 | [ "VMS->abs2rel('[t1.t2.t3.t4]','[t1.t2.t3]')", '[t4]' ], | |
243 | [ "VMS->abs2rel('[t4.t5.t6]','[t1.t2.t3]')", '[-.-.-.t4.t5.t6]' ], | |
244 | #[ "VMS->abs2rel('[]','[t1.t2.t3]')", '[-.-.-]' ], | |
245 | #[ "VMS->abs2rel('[..]','[t1.t2.t3]')", '[-.-.-]' ], | |
246 | #[ "VMS->abs2rel('[.]','[t1.t2.t3]')", '[-.-.-]' ], | |
247 | #[ "VMS->abs2rel('[..]','[t1.t2.t3]')", '[-.-.-]' ], | |
248 | #[ "VMS->abs2rel('a:[t1.t2.t4]','[t1.t2.t3]')", '[-.t4]' ], | |
249 | #[ "VMS->abs2rel('[a.-.b.c.-]','[t1.t2.t3]')", '[-.-.-.b]' ], | |
270d1e39 | 250 | |
0994714a GS |
251 | [ "VMS->rel2abs('[.t4]','[t1.t2.t3]')", '[t1.t2.t3.t4]' ], |
252 | [ "VMS->rel2abs('[.t4.t5]','[t1.t2.t3]')", '[t1.t2.t3.t4.t5]' ], | |
253 | [ "VMS->rel2abs('[]','[t1.t2.t3]')", '[t1.t2.t3]' ], | |
254 | [ "VMS->rel2abs('[-]','[t1.t2.t3]')", '[t1.t2.t3.-]' ], | |
255 | [ "VMS->rel2abs('[-.t4]','[t1.t2.t3]')", '[t1.t2.t3.-.t4]' ], | |
256 | [ "VMS->rel2abs('[t1]','[t1.t2.t3]')", '[t1]' ], | |
270d1e39 | 257 | |
0994714a GS |
258 | [ "OS2->catdir('A:/d1','B:/d2','d3','')", 'A:/d1/B:/d2/d3' ], |
259 | [ "OS2->catfile('a','b','c')", 'a/b/c' ], | |
260 | ||
261 | [ "Mac->splitpath('file')", ',,file' ], | |
262 | [ "Mac->splitpath(':file')", ',:,file' ], | |
263 | [ "Mac->splitpath(':d1',1)", ',:d1:,' ], | |
264 | [ "Mac->splitpath('d1',1)", 'd1:,,' ], | |
265 | [ "Mac->splitpath('d1:d2:d3:')", 'd1:,d2:d3:,' ], | |
266 | [ "Mac->splitpath('d1:d2:d3',1)", 'd1:,d2:d3:,' ], | |
267 | [ "Mac->splitpath(':d1:d2:d3:')", ',:d1:d2:d3:,' ], | |
268 | [ "Mac->splitpath(':d1:d2:d3:',1)", ',:d1:d2:d3:,' ], | |
269 | [ "Mac->splitpath('d1:d2:d3:file')", 'd1:,d2:d3:,file' ], | |
270 | [ "Mac->splitpath('d1:d2:d3',1)", 'd1:,d2:d3:,' ], | |
271 | ||
272 | [ "Mac->catdir('')", ':' ], | |
273 | [ "Mac->catdir('d1','d2','d3')", 'd1:d2:d3:' ], | |
274 | [ "Mac->catdir('d1','d2/','d3')", 'd1:d2/:d3:' ], | |
275 | [ "Mac->catdir('','d1','d2','d3')", ':d1:d2:d3:' ], | |
276 | [ "Mac->catdir('','','d2','d3')", '::d2:d3:' ], | |
277 | [ "Mac->catdir('','','','d3')", ':::d3:' ], | |
278 | [ "Mac->catdir(':name')", ':name:' ], | |
279 | [ "Mac->catdir(':name',':name')", ':name:name:' ], | |
280 | ||
281 | [ "Mac->catfile('a','b','c')", 'a:b:c' ], | |
282 | ||
283 | [ "Mac->canonpath('')", '' ], | |
284 | [ "Mac->canonpath(':')", ':' ], | |
285 | [ "Mac->canonpath('::')", '::' ], | |
286 | [ "Mac->canonpath('a::')", 'a::' ], | |
287 | [ "Mac->canonpath(':a::')", ':a::' ], | |
288 | ||
289 | [ "Mac->abs2rel('t1:t2:t3','t1:t2:t3')", ':' ], | |
290 | [ "Mac->abs2rel('t1:t2','t1:t2:t3')", '::' ], | |
291 | [ "Mac->abs2rel('t1:t4','t1:t2:t3')", ':::t4' ], | |
292 | [ "Mac->abs2rel('t1:t2:t4','t1:t2:t3')", '::t4' ], | |
293 | [ "Mac->abs2rel('t1:t2:t3:t4','t1:t2:t3')", ':t4' ], | |
294 | [ "Mac->abs2rel('t4:t5:t6','t1:t2:t3')", '::::t4:t5:t6' ], | |
295 | [ "Mac->abs2rel('t1','t1:t2:t3')", ':::' ], | |
296 | ||
297 | [ "Mac->rel2abs(':t4','t1:t2:t3')", 't1:t2:t3:t4' ], | |
298 | [ "Mac->rel2abs(':t4:t5','t1:t2:t3')", 't1:t2:t3:t4:t5' ], | |
299 | [ "Mac->rel2abs('','t1:t2:t3')", '' ], | |
300 | [ "Mac->rel2abs('::','t1:t2:t3')", 't1:t2:t3::' ], | |
301 | [ "Mac->rel2abs('::t4','t1:t2:t3')", 't1:t2:t3::t4' ], | |
302 | [ "Mac->rel2abs('t1','t1:t2:t3')", 't1' ], | |
303 | ) ; | |
304 | ||
305 | # Grab all of the plain routines from File::Spec | |
306 | use File::Spec @File::Spec::EXPORT_OK ; | |
307 | ||
308 | require File::Spec::Unix ; | |
309 | require File::Spec::Win32 ; | |
310 | ||
311 | eval { | |
312 | require VMS::Filespec ; | |
313 | } ; | |
314 | ||
d7bc03f0 GS |
315 | my $skip_exception = "Install VMS::Filespec (from vms/ext)" ; |
316 | ||
0994714a GS |
317 | if ( $@ ) { |
318 | # Not pretty, but it allows testing of things not implemented soley | |
319 | # on VMS. It might be better to change File::Spec::VMS to do this, | |
320 | # making it more usable when running on (say) Unix but working with | |
321 | # VMS paths. | |
178326fd | 322 | eval qq- |
d7bc03f0 GS |
323 | sub File::Spec::VMS::vmsify { die "$skip_exception" } |
324 | sub File::Spec::VMS::unixify { die "$skip_exception" } | |
325 | sub File::Spec::VMS::vmspath { die "$skip_exception" } | |
178326fd | 326 | - ; |
0994714a | 327 | $INC{"VMS/Filespec.pm"} = 1 ; |
270d1e39 | 328 | } |
0994714a | 329 | require File::Spec::VMS ; |
270d1e39 | 330 | |
0994714a GS |
331 | require File::Spec::OS2 ; |
332 | require File::Spec::Mac ; | |
270d1e39 | 333 | |
0994714a GS |
334 | print "1..", scalar( @tests ), "\n" ; |
335 | ||
336 | my $current_test= 1 ; | |
337 | ||
0994714a GS |
338 | # Test out the class methods |
339 | for ( @tests ) { | |
340 | tryfunc( @$_ ) ; | |
270d1e39 GS |
341 | } |
342 | ||
0994714a GS |
343 | |
344 | ||
345 | # | |
346 | # Tries a named function with the given args and compares the result against | |
347 | # an expected result. Works with functions that return scalars or arrays. | |
348 | # | |
349 | sub tryfunc { | |
350 | my $function = shift ; | |
351 | my $expected = shift ; | |
f6a53ef2 GS |
352 | my $platform = shift ; |
353 | ||
354 | if ($platform && $^O ne $platform) { | |
355 | print "ok $current_test # skipped: $function\n" ; | |
356 | ++$current_test ; | |
357 | return; | |
358 | } | |
0994714a GS |
359 | |
360 | $function =~ s#\\#\\\\#g ; | |
361 | ||
362 | my $got ; | |
363 | if ( $function =~ /^[^\$].*->/ ) { | |
364 | $got = eval( "join( ',', File::Spec::$function )" ) ; | |
365 | } | |
366 | else { | |
367 | $got = eval( "join( ',', $function )" ) ; | |
368 | } | |
369 | ||
370 | if ( $@ ) { | |
d7bc03f0 GS |
371 | if ( substr( $@, 0, length $skip_exception ) eq $skip_exception ) { |
372 | chomp $@ ; | |
373 | print "ok $current_test # skip $function: $@\n" ; | |
0994714a GS |
374 | } |
375 | else { | |
376 | chomp $@ ; | |
377 | print "not ok $current_test # $function: $@\n" ; | |
378 | } | |
379 | } | |
380 | elsif ( !defined( $got ) || $got ne $expected ) { | |
381 | print "not ok $current_test # $function: got '$got', expected '$expected'\n" ; | |
382 | } | |
383 | else { | |
384 | print "ok $current_test # $function\n" ; | |
385 | } | |
386 | ++$current_test ; | |
387 | } |