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