1# Before `make install' is performed this script should be runnable with 2# `make test'. After `make install' it should work as `perl t/File-VirtualPath.t' 3 4######################### We start with some black magic to print on failure. 5 6# Change 1..1 below to 1..last_test_to_print . 7# (It may become useful if the test is moved to ./t subdirectory.) 8 9BEGIN { $| = 1; print "1..136\n"; } 10END {print "not ok 1\n" unless $loaded;} 11use File::VirtualPath 1.011; 12$loaded = 1; 13print "ok 1\n"; 14use strict; 15use warnings; 16 17# Set this to 1 to see complete result text for each test 18my $verbose = shift( @ARGV ) ? 1 : 0; # set from command line 19 20######################### End of black magic. 21 22# Insert your test code below (better if it prints "ok 13" 23# (correspondingly "not ok 13") depending on the success of chunk 13 24# of the test code): 25 26###################################################################### 27# Here are some utility methods: 28 29my $test_num = 1; # same as the first test, above 30 31sub result { 32 $test_num++; 33 my ($worked, $detail) = @_; 34 $verbose or 35 $detail = substr( $detail, 0, 50 ). 36 (length( $detail ) > 47 ? "..." : ""); 37 print "@{[$worked ? '' : 'not ']}ok $test_num $detail\n"; 38} 39 40sub message { 41 my ($detail) = @_; 42 print "-- $detail\n"; 43} 44 45sub vis { 46 my ($str) = @_; 47 $str =~ s/\n/\\n/g; # make newlines visible 48 $str =~ s/\t/\\t/g; # make tabs visible 49 return( $str ); 50} 51 52sub serialize { 53 my ($input,$is_key) = @_; 54 return( join( '', 55 ref($input) eq 'HASH' ? 56 ( '{ ', ( map { 57 ( serialize( $_, 1 ), serialize( $input->{$_} ) ) 58 } sort keys %{$input} ), '}, ' ) 59 : ref($input) eq 'ARRAY' ? 60 ( '[ ', ( map { 61 ( serialize( $_ ) ) 62 } @{$input} ), '], ' ) 63 : defined($input) ? 64 "'$input'".($is_key ? ' => ' : ', ') 65 : "undef".($is_key ? ' => ' : ', ') 66 ) ); 67} 68 69###################################################################### 70 71message( "START TESTING File::VirtualPath" ); 72 73###################################################################### 74# testing new(), initialize(), and clone() 75 76{ 77 message( "testing new(), initialize(), and clone()" ); 78 79 my ($did, $should); 80 81 # make new with default values 82 83 my $fvp1 = File::VirtualPath->new(); 84 result( UNIVERSAL::isa( $fvp1, "File::VirtualPath" ), 85 "fvp1 = new() ret FVP obj" ); 86 87 $did = $fvp1->physical_root(); 88 $should = ""; 89 result( $did eq $should, "on init fvp1->physical_root() returns '$did'" ); 90 91 $did = $fvp1->physical_delimiter(); 92 $should = "/"; 93 result( $did eq $should, "on init fvp1->physical_delimiter() returns '$did'" ); 94 95 $did = $fvp1->path_delimiter(); 96 $should = "/"; 97 result( $did eq $should, "on init fvp1->path_delimiter() returns '$did'" ); 98 99 $did = serialize( scalar( $fvp1->path() ) ); 100 $should = "[ '', ], "; 101 result( $did eq $should, "on init fvp1->path() returns '$did'" ); 102 103 $did = $fvp1->current_path_level(); 104 result( $did == 0, "on init fvp1->current_path_level() returns '$did'" ); 105 106 # make new with provided values 107 108 my $fvp2 = File::VirtualPath->new( '/home/joe/aardvark', '/', ':', ':init' ); 109 result( UNIVERSAL::isa( $fvp2, "File::VirtualPath" ), 110 "fvp2 = new( '/home/joe/aardvark', '/', ':', ':init' ) ret FVP obj" ); 111 112 $did = $fvp2->physical_root(); 113 $should = "/home/joe/aardvark"; 114 result( $did eq $should, "on init fvp2->physical_root() returns '$did'" ); 115 116 $did = $fvp2->physical_delimiter(); 117 $should = "/"; 118 result( $did eq $should, "on init fvp2->physical_delimiter() returns '$did'" ); 119 120 $did = $fvp2->path_delimiter(); 121 $should = ":"; 122 result( $did eq $should, "on init fvp2->path_delimiter() returns '$did'" ); 123 124 $did = serialize( scalar( $fvp2->path() ) ); 125 $should = "[ '', 'init', ], "; 126 result( $did eq $should, "on init fvp2->path() returns '$did'" ); 127 128 $did = $fvp2->current_path_level(); 129 result( $did == 0, "on init fvp2->current_path_level() returns '$did'" ); 130 131 $did = $fvp2->current_path_level( 1 ); 132 result( $did == 1, "on set fvp2->current_path_level( 1 ) returns '$did'" ); 133 134 # now we test clone of default values 135 136 my $fvp3 = $fvp1->clone(); 137 result( UNIVERSAL::isa( $fvp3, "File::VirtualPath" ), 138 "fvp3 = fvp1->clone() ret FVP obj" ); 139 140 $did = $fvp3->physical_root(); 141 $should = ""; 142 result( $did eq $should, "on init fvp3->physical_root() returns '$did'" ); 143 144 $did = $fvp3->physical_delimiter(); 145 $should = "/"; 146 result( $did eq $should, "on init fvp3->physical_delimiter() returns '$did'" ); 147 148 $did = $fvp3->path_delimiter(); 149 $should = "/"; 150 result( $did eq $should, "on init fvp3->path_delimiter() returns '$did'" ); 151 152 $did = serialize( scalar( $fvp3->path() ) ); 153 $should = "[ '', ], "; 154 result( $did eq $should, "on init fvp3->path() returns '$did'" ); 155 156 $did = $fvp3->current_path_level(); 157 result( $did == 0, "on init fvp3->current_path_level() returns '$did'" ); 158 159 # now we test clone of provided values 160 161 my $fvp4 = $fvp2->clone(); 162 result( UNIVERSAL::isa( $fvp4, "File::VirtualPath" ), 163 "fvp4 = fvp2->clone() ret FVP obj" ); 164 165 $did = $fvp4->physical_root(); 166 $should = "/home/joe/aardvark"; 167 result( $did eq $should, "on init fvp4->physical_root() returns '$did'" ); 168 169 $did = $fvp4->physical_delimiter(); 170 $should = "/"; 171 result( $did eq $should, "on init fvp4->physical_delimiter() returns '$did'" ); 172 173 $did = $fvp4->path_delimiter(); 174 $should = ":"; 175 result( $did eq $should, "on init fvp4->path_delimiter() returns '$did'" ); 176 177 $did = serialize( scalar( $fvp4->path() ) ); 178 $should = "[ '', 'init', ], "; 179 result( $did eq $should, "on init fvp4->path() returns '$did'" ); 180 181 $did = $fvp4->current_path_level(); 182 result( $did == 1, "on init fvp4->current_path_level() returns '$did'" ); 183} 184 185###################################################################### 186# test the other methods 187 188{ 189 my ($fvp, $did, $should); 190 191 # first initialize data we will be reading from 192 193 $fvp = File::VirtualPath->new(); 194 195 message( "testing setter/getter methods on default object" ); 196 197 # first check the main setter/getter methods 198 199 $did = $fvp->physical_root( '/home/joe/aardvark' ); 200 $should = "/home/joe/aardvark"; 201 result( $did eq $should, "physical_root( '/home/joe/aardvark' ) returns '$did'" ); 202 203 $did = $fvp->physical_delimiter( '/' ); 204 $should = "/"; 205 result( $did eq $should, "physical_delimiter( '/' ) returns '$did'" ); 206 207 $did = $fvp->path_delimiter( ':' ); 208 $should = ":"; 209 result( $did eq $should, "path_delimiter( ':' ) returns '$did'" ); 210 211 $did = serialize( scalar( $fvp->path( '' ) ) ); 212 $should = "[ '', ], "; 213 result( $did eq $should, "path( '' ) returns '$did'" ); 214 215 $did = serialize( scalar( $fvp->path( '.' ) ) ); 216 $should = "[ '', ], "; 217 result( $did eq $should, "path( '.' ) returns '$did'" ); 218 219 $did = serialize( scalar( $fvp->path( ':.' ) ) ); 220 $should = "[ '', ], "; 221 result( $did eq $should, "path( ':.' ) returns '$did'" ); 222 223 $did = serialize( scalar( $fvp->path( 'init' ) ) ); 224 $should = "[ '', 'init', ], "; 225 result( $did eq $should, "path( 'init' ) returns '$did'" ); 226 227 $did = serialize( scalar( $fvp->path( ':init' ) ) ); 228 $should = "[ '', 'init', ], "; 229 result( $did eq $should, "path( ':init' ) returns '$did'" ); 230 231 $did = serialize( scalar( $fvp->path( '..' ) ) ); 232 $should = "[ '', ], "; 233 result( $did eq $should, "path( '..' ) returns '$did'" ); 234 235 $did = serialize( scalar( $fvp->path( ':..' ) ) ); 236 $should = "[ '', ], "; 237 result( $did eq $should, "path( ':..' ) returns '$did'" ); 238 239 $did = serialize( scalar( $fvp->path( '..:init' ) ) ); 240 $should = "[ '', 'init', ], "; 241 result( $did eq $should, "path( '..:init' ) returns '$did'" ); 242 243 $did = serialize( scalar( $fvp->path( 'init:..' ) ) ); 244 $should = "[ '', ], "; 245 result( $did eq $should, "path( 'init:..' ) returns '$did'" ); 246 247 $did = serialize( scalar( $fvp->path( ':..:init' ) ) ); 248 $should = "[ '', 'init', ], "; 249 result( $did eq $should, "path( ':..:init' ) returns '$did'" ); 250 251 $did = serialize( scalar( $fvp->path( ':init:..' ) ) ); 252 $should = "[ '', ], "; 253 result( $did eq $should, "path( ':init:..' ) returns '$did'" ); 254 255 $did = serialize( scalar( $fvp->path( ':..:init:' ) ) ); 256 $should = "[ '', 'init', ], "; 257 result( $did eq $should, "path( ':..:init:' ) returns '$did'" ); 258 259 $did = serialize( scalar( $fvp->path( ':init:..:' ) ) ); 260 $should = "[ '', ], "; 261 result( $did eq $should, "path( ':init:..:' ) returns '$did'" ); 262 263 $did = serialize( scalar( $fvp->path( 'one:two:#*:' ) ) ); 264 $should = "[ '', 'one', 'two', ], "; 265 result( $did eq $should, "path( 'one:two:#*:' ) returns '$did'" ); 266 267 $did = serialize( scalar( $fvp->path( 'one:two:#*:three' ) ) ); 268 $should = "[ '', 'one', 'two', 'three', ], "; 269 result( $did eq $should, "path( 'one:two:#*:three' ) returns '$did'" ); 270 271 $did = serialize( scalar( $fvp->path( [''] ) ) ); 272 $should = "[ '', ], "; 273 result( $did eq $should, "path( [''] ) returns '$did'" ); 274 275 $did = serialize( scalar( $fvp->path( ['.'] ) ) ); 276 $should = "[ '', ], "; 277 result( $did eq $should, "path( ['.'] ) returns '$did'" ); 278 279 $did = serialize( scalar( $fvp->path( ['', '.'] ) ) ); 280 $should = "[ '', ], "; 281 result( $did eq $should, "path( ['', '.'] ) returns '$did'" ); 282 283 $did = serialize( scalar( $fvp->path( ['init'] ) ) ); 284 $should = "[ '', 'init', ], "; 285 result( $did eq $should, "path( ['init'] ) returns '$did'" ); 286 287 $did = serialize( scalar( $fvp->path( ['', 'init'] ) ) ); 288 $should = "[ '', 'init', ], "; 289 result( $did eq $should, "path( ['', 'init'] ) returns '$did'" ); 290 291 $did = serialize( scalar( $fvp->path( ['..'] ) ) ); 292 $should = "[ '', ], "; 293 result( $did eq $should, "path( ['..'] ) returns '$did'" ); 294 295 $did = serialize( scalar( $fvp->path( ['', '..'] ) ) ); 296 $should = "[ '', ], "; 297 result( $did eq $should, "path( ['', '..'] ) returns '$did'" ); 298 299 $did = serialize( scalar( $fvp->path( ['..', 'init'] ) ) ); 300 $should = "[ '', 'init', ], "; 301 result( $did eq $should, "path( ['..', 'init'] ) returns '$did'" ); 302 303 $did = serialize( scalar( $fvp->path( ['init', '..'] ) ) ); 304 $should = "[ '', ], "; 305 result( $did eq $should, "path( ['init', '..'] ) returns '$did'" ); 306 307 $did = serialize( scalar( $fvp->path( ['', '..', 'init'] ) ) ); 308 $should = "[ '', 'init', ], "; 309 result( $did eq $should, "path( ['', '..', 'init'] ) returns '$did'" ); 310 311 $did = serialize( scalar( $fvp->path( ['', 'init', '..'] ) ) ); 312 $should = "[ '', ], "; 313 result( $did eq $should, "path( ['', 'init', '..'] ) returns '$did'" ); 314 315 $did = serialize( scalar( $fvp->path( ['', '..', 'init', ''] ) ) ); 316 $should = "[ '', 'init', ], "; 317 result( $did eq $should, "path( ['', '..', 'init', ''] ) returns '$did'" ); 318 319 $did = serialize( scalar( $fvp->path( ['', 'init', '..', ''] ) ) ); 320 $should = "[ '', ], "; 321 result( $did eq $should, "path( ['', 'init', '..', ''] ) returns '$did'" ); 322 323 $did = serialize( scalar( $fvp->path( ['one', 'two', '#*', ''] ) ) ); 324 $should = "[ '', 'one', 'two', ], "; 325 result( $did eq $should, "path( ['one', 'two', '#*', ''] ) returns '$did'" ); 326 327 $did = serialize( scalar( $fvp->path( ['one', 'two', '#*', 'three'] ) ) ); 328 $should = "[ '', 'one', 'two', 'three', ], "; 329 result( $did eq $should, "path( ['one', 'two', '#*', 'three'] ) returns '$did'" ); 330 331 $did = serialize( scalar( $fvp->path( ':starter' ) ) ); 332 $should = "[ '', 'starter', ], "; 333 result( $did eq $should, "path( ':starter' ) returns '$did'" ); 334 335 $did = $fvp->current_path_level( 1 ); 336 result( $did == 1, "current_path_level( 1 ) returns '$did'" ); 337 338 message( "testing child_path type methods on current object" ); 339 340 # first test child_path() itself 341 342 $did = serialize( scalar( $fvp->child_path( '' ) ) ); 343 $should = "[ '', 'starter', ], "; 344 result( $did eq $should, "child_path( '' ) returns '$did'" ); 345 346 $did = serialize( scalar( $fvp->child_path( '.' ) ) ); 347 $should = "[ '', 'starter', ], "; 348 result( $did eq $should, "child_path( '.' ) returns '$did'" ); 349 350 $did = serialize( scalar( $fvp->child_path( ':.' ) ) ); 351 $should = "[ '', ], "; 352 result( $did eq $should, "child_path( ':.' ) returns '$did'" ); 353 354 $did = serialize( scalar( $fvp->child_path( 'init' ) ) ); 355 $should = "[ '', 'starter', 'init', ], "; 356 result( $did eq $should, "child_path( 'init' ) returns '$did'" ); 357 358 $did = serialize( scalar( $fvp->child_path( ':init' ) ) ); 359 $should = "[ '', 'init', ], "; 360 result( $did eq $should, "child_path( ':init' ) returns '$did'" ); 361 362 $did = serialize( scalar( $fvp->child_path( '..' ) ) ); 363 $should = "[ '', ], "; 364 result( $did eq $should, "child_path( '..' ) returns '$did'" ); 365 366 $did = serialize( scalar( $fvp->child_path( ':..' ) ) ); 367 $should = "[ '', ], "; 368 result( $did eq $should, "child_path( ':..' ) returns '$did'" ); 369 370 $did = serialize( scalar( $fvp->child_path( '..:init' ) ) ); 371 $should = "[ '', 'init', ], "; 372 result( $did eq $should, "child_path( '..:init' ) returns '$did'" ); 373 374 $did = serialize( scalar( $fvp->child_path( 'init:..' ) ) ); 375 $should = "[ '', 'starter', ], "; 376 result( $did eq $should, "child_path( 'init:..' ) returns '$did'" ); 377 378 $did = serialize( scalar( $fvp->child_path( ':..:init' ) ) ); 379 $should = "[ '', 'init', ], "; 380 result( $did eq $should, "child_path( ':..:init' ) returns '$did'" ); 381 382 $did = serialize( scalar( $fvp->child_path( ':init:..' ) ) ); 383 $should = "[ '', ], "; 384 result( $did eq $should, "child_path( ':init:..' ) returns '$did'" ); 385 386 $did = serialize( scalar( $fvp->child_path( ':..:init:' ) ) ); 387 $should = "[ '', 'init', ], "; 388 result( $did eq $should, "child_path( ':..:init:' ) returns '$did'" ); 389 390 $did = serialize( scalar( $fvp->child_path( ':init:..:' ) ) ); 391 $should = "[ '', ], "; 392 result( $did eq $should, "child_path( ':init:..:' ) returns '$did'" ); 393 394 $did = serialize( scalar( $fvp->child_path( 'one:two:#*:' ) ) ); 395 $should = "[ '', 'starter', 'one', 'two', ], "; 396 result( $did eq $should, "child_path( 'one:two:#*:' ) returns '$did'" ); 397 398 $did = serialize( scalar( $fvp->child_path( 'one:two:#*:three' ) ) ); 399 $should = "[ '', 'starter', 'one', 'two', 'three', ], "; 400 result( $did eq $should, "child_path( 'one:two:#*:three' ) returns '$did'" ); 401 402 $did = serialize( scalar( $fvp->child_path( [''] ) ) ); 403 $should = "[ '', ], "; 404 result( $did eq $should, "child_path( [''] ) returns '$did'" ); 405 406 $did = serialize( scalar( $fvp->child_path( ['.'] ) ) ); 407 $should = "[ '', 'starter', ], "; 408 result( $did eq $should, "child_path( ['.'] ) returns '$did'" ); 409 410 $did = serialize( scalar( $fvp->child_path( ['', '.'] ) ) ); 411 $should = "[ '', ], "; 412 result( $did eq $should, "child_path( ['', '.'] ) returns '$did'" ); 413 414 $did = serialize( scalar( $fvp->child_path( ['init'] ) ) ); 415 $should = "[ '', 'starter', 'init', ], "; 416 result( $did eq $should, "child_path( ['init'] ) returns '$did'" ); 417 418 $did = serialize( scalar( $fvp->child_path( ['', 'init'] ) ) ); 419 $should = "[ '', 'init', ], "; 420 result( $did eq $should, "child_path( ['', 'init'] ) returns '$did'" ); 421 422 $did = serialize( scalar( $fvp->child_path( ['..'] ) ) ); 423 $should = "[ '', ], "; 424 result( $did eq $should, "child_path( ['..'] ) returns '$did'" ); 425 426 $did = serialize( scalar( $fvp->child_path( ['', '..'] ) ) ); 427 $should = "[ '', ], "; 428 result( $did eq $should, "child_path( ['', '..'] ) returns '$did'" ); 429 430 $did = serialize( scalar( $fvp->child_path( ['..', 'init'] ) ) ); 431 $should = "[ '', 'init', ], "; 432 result( $did eq $should, "child_path( ['..', 'init'] ) returns '$did'" ); 433 434 $did = serialize( scalar( $fvp->child_path( ['init', '..'] ) ) ); 435 $should = "[ '', 'starter', ], "; 436 result( $did eq $should, "child_path( ['init', '..'] ) returns '$did'" ); 437 438 $did = serialize( scalar( $fvp->child_path( ['', '..', 'init'] ) ) ); 439 $should = "[ '', 'init', ], "; 440 result( $did eq $should, "child_path( ['', '..', 'init'] ) returns '$did'" ); 441 442 $did = serialize( scalar( $fvp->child_path( ['', 'init', '..'] ) ) ); 443 $should = "[ '', ], "; 444 result( $did eq $should, "child_path( ['', 'init', '..'] ) returns '$did'" ); 445 446 $did = serialize( scalar( $fvp->child_path( ['', '..', 'init', ''] ) ) ); 447 $should = "[ '', 'init', ], "; 448 result( $did eq $should, "child_path( ['', '..', 'init', ''] ) returns '$did'" ); 449 450 $did = serialize( scalar( $fvp->child_path( ['', 'init', '..', ''] ) ) ); 451 $should = "[ '', ], "; 452 result( $did eq $should, "child_path( ['', 'init', '..', ''] ) returns '$did'" ); 453 454 $did = serialize( scalar( $fvp->child_path( ['one', 'two', '#*', ''] ) ) ); 455 $should = "[ '', 'starter', 'one', 'two', ], "; 456 result( $did eq $should, "child_path( ['one', 'two', '#*', ''] ) returns '$did'" ); 457 458 $did = serialize( scalar( $fvp->child_path( ['one', 'two', '#*', 'three'] ) ) ); 459 $should = "[ '', 'starter', 'one', 'two', 'three', ], "; 460 result( $did eq $should, "child_path( ['one', 'two', '#*', 'three'] ) returns '$did'" ); 461 462 # now test child_path_obj() 463 464 my $fvp2 = $fvp->child_path_obj( 'further' ); 465 result( UNIVERSAL::isa( $fvp2, "File::VirtualPath" ), 466 "fvp2 = child_path_obj( 'further' ) ret FVP obj" ); 467 468 $did = $fvp2->physical_root(); 469 $should = "/home/joe/aardvark"; 470 result( $did eq $should, "on init fvp2->physical_root() returns '$did'" ); 471 472 $did = $fvp2->physical_delimiter(); 473 $should = "/"; 474 result( $did eq $should, "on init fvp2->physical_delimiter() returns '$did'" ); 475 476 $did = $fvp2->path_delimiter(); 477 $should = ":"; 478 result( $did eq $should, "on init fvp2->path_delimiter() returns '$did'" ); 479 480 $did = serialize( scalar( $fvp2->path() ) ); 481 $should = "[ '', 'starter', 'further', ], "; 482 result( $did eq $should, "on init fvp2->path() returns '$did'" ); 483 484 $did = $fvp2->current_path_level(); 485 result( $did == 1, "on init fvp2->current_path_level() returns '$did'" ); 486 487 # now test chdir() briefly, since its trivial 488 489 $did = serialize( scalar( $fvp->chdir( ['inwego'] ) ) ); 490 $should = "[ '', 'starter', 'inwego', ], "; 491 result( $did eq $should, "chdir( ['inwego'] ) returns '$did'" ); 492 493 $did = serialize( scalar( $fvp->path() ) ); 494 $should = "[ '', 'starter', 'inwego', ], "; 495 result( $did eq $should, "path() returns '$did'" ); 496 497 $did = serialize( scalar( $fvp->chdir( ['..'] ) ) ); 498 $should = "[ '', 'starter', ], "; 499 result( $did eq $should, "chdir( ['..'] ) returns '$did'" ); 500 501 $did = serialize( scalar( $fvp->path() ) ); 502 $should = "[ '', 'starter', ], "; 503 result( $did eq $should, "path() returns '$did'" ); 504 505 message( "testing to_string type methods on current object" ); 506 507 $did = $fvp->path_string(); 508 $should = ":starter"; 509 result( $did eq $should, "path_string() returns '$did'" ); 510 511 $did = $fvp->physical_path_string(); 512 $should = "/home/joe/aardvark/starter"; 513 result( $did eq $should, "physical_path_string() returns '$did'" ); 514 515 $did = $fvp->path_string( 1 ); 516 $should = ":starter:"; 517 result( $did eq $should, "path_string( 1 ) returns '$did'" ); 518 519 $did = $fvp->physical_path_string( 1 ); 520 $should = "/home/joe/aardvark/starter/"; 521 result( $did eq $should, "physical_path_string( 1 ) returns '$did'" ); 522 523 $did = $fvp->child_path_string(); 524 $should = ":starter"; 525 result( $did eq $should, "child_path_string() returns '$did'" ); 526 527 $did = $fvp->physical_child_path_string(); 528 $should = "/home/joe/aardvark/starter"; 529 result( $did eq $should, "physical_child_path_string() returns '$did'" ); 530 531 $did = $fvp->child_path_string( 'myfile.pl' ); 532 $should = ":starter:myfile.pl"; 533 result( $did eq $should, "child_path_string( 'myfile.pl' ) returns '$did'" ); 534 535 $did = $fvp->physical_child_path_string( 'myfile.pl' ); 536 $should = "/home/joe/aardvark/starter/myfile.pl"; 537 result( $did eq $should, "physical_child_path_string( 'myfile.pl' ) returns '$did'" ); 538 539 $did = $fvp->child_path_string( 'myfile.pl', 1 ); 540 $should = ":starter:myfile.pl:"; 541 result( $did eq $should, "child_path_string( 'myfile.pl', 1 ) returns '$did'" ); 542 543 $did = $fvp->physical_child_path_string( 'myfile.pl', 1 ); 544 $should = "/home/joe/aardvark/starter/myfile.pl/"; 545 result( $did eq $should, "physical_child_path_string( 'myfile.pl', 1 ) returns '$did'" ); 546 547 $did = $fvp->child_path_string( undef, 1 ); 548 $should = ":starter:"; 549 result( $did eq $should, "child_path_string( undef, 1 ) returns '$did'" ); 550 551 $did = $fvp->physical_child_path_string( undef, 1 ); 552 $should = "/home/joe/aardvark/starter/"; 553 result( $did eq $should, "physical_child_path_string( undef, 1 ) returns '$did'" ); 554 555 message( "testing one-element type methods on current object" ); 556 557 $did = serialize( scalar( $fvp->path( 'one:two:three' ) ) ); 558 $should = "[ '', 'one', 'two', 'three', ], "; 559 result( $did eq $should, "path( 'one:two:three' ) returns '$did'" ); 560 561 $did = $fvp->path_element(); 562 $should = ""; 563 result( $did eq $should, "path_element() returns '$did'" ); 564 565 $did = $fvp->path_element( 0 ); 566 $should = ""; 567 result( $did eq $should, "path_element( 0 ) returns '$did'" ); 568 569 $did = $fvp->path_element( 1 ); 570 $should = "one"; 571 result( $did eq $should, "path_element( 1 ) returns '$did'" ); 572 573 $did = $fvp->path_element( -1 ); 574 $should = "three"; 575 result( $did eq $should, "path_element( -1 ) returns '$did'" ); 576 577 $did = $fvp->path_element( undef, 'four' ); 578 $should = "four"; 579 result( $did eq $should, "path_element( undef, 'four' ) returns '$did'" ); 580 581 $did = $fvp->path_element( 2, 'five' ); 582 $should = "five"; 583 result( $did eq $should, "path_element( 2, 'five' ) returns '$did'" ); 584 585 $did = $fvp->current_path_level( 0 ); 586 result( $did == 0, "current_path_level( 0 ) returns '$did'" ); 587 588 $did = $fvp->current_path_level(); 589 result( $did == 0, "current_path_level() returns '$did'" ); 590 591 $did = $fvp->current_path_element(); 592 $should = "four"; 593 result( $did eq $should, "current_path_element() returns '$did'" ); 594 595 $did = $fvp->inc_path_level(); 596 result( $did == 1, "inc_path_level() returns '$did'" ); 597 598 $did = $fvp->current_path_level(); 599 result( $did == 1, "current_path_level() returns '$did'" ); 600 601 $did = $fvp->current_path_element(); 602 $should = "one"; 603 result( $did eq $should, "current_path_element() returns '$did'" ); 604 605 $did = $fvp->inc_path_level(); 606 result( $did == 2, "inc_path_level() returns '$did'" ); 607 608 $did = $fvp->current_path_level(); 609 result( $did == 2, "current_path_level() returns '$did'" ); 610 611 $did = $fvp->current_path_element(); 612 $should = "five"; 613 result( $did eq $should, "current_path_element() returns '$did'" ); 614 615 $did = $fvp->current_path_element( 'six' ); 616 $should = "six"; 617 result( $did eq $should, "current_path_element( 'six' ) returns '$did'" ); 618 619 $did = $fvp->current_path_element(); 620 $should = "six"; 621 result( $did eq $should, "current_path_element() returns '$did'" ); 622 623 $did = $fvp->dec_path_level(); 624 result( $did == 1, "dec_path_level() returns '$did'" ); 625 626 $did = $fvp->current_path_level(); 627 result( $did == 1, "current_path_level() returns '$did'" ); 628 629 $did = $fvp->current_path_element(); 630 $should = "one"; 631 result( $did eq $should, "current_path_element() returns '$did'" ); 632 633 $did = $fvp->path_string(); 634 $should = "four:one:six:three"; 635 result( $did eq $should, "path_string() returns '$did'" ); 636 637 $did = $fvp->physical_path_string(); 638 $should = "/home/joe/aardvarkfour/one/six/three"; 639 result( $did eq $should, "physical_path_string() returns '$did'" ); 640} 641 642###################################################################### 643 644message( "DONE TESTING File::VirtualPath" ); 645 646###################################################################### 647 6481; 649