Upgrade to PathTools 3.10
[p5sagit/p5-mst-13.2.git] / lib / File / stat.t
index 8215f45..2359453 100644 (file)
@@ -16,10 +16,10 @@ BEGIN {
     $hasst = 0 unless $Config{'i_sysstat'} eq 'define';
     unless ($hasst) { plan skip_all => "no sys/stat.h"; exit 0 }
     our @stat = stat "TEST"; # This is the function stat.
-    unless (@stat) { print "1..0 # Skip: no file TEST\n"; exit 0 }
+    unless (@stat) { plan skip_all => "1..0 # Skip: no file TEST"; exit 0 }
 }
 
-plan tests => 16;
+plan tests => 19;
 
 use_ok( 'File::stat' );
 
@@ -30,7 +30,7 @@ is( $stat->dev, $stat[0], "device number in position 0" );
 
 # On OS/2 (fake) ino is not constant, it is incremented each time
 SKIP: {
-       skip(1, 'inode number is not constant on OS/2') if $^O eq 'os2';
+       skip('inode number is not constant on OS/2', 1) if $^O eq 'os2';
        is( $stat->ino, $stat[1], "inode number in position 1" );
 }
 
@@ -56,6 +56,31 @@ is( $stat->blksize, $stat[11], "IO block size in position 11" );
 
 is( $stat->blocks, $stat[12], "number of blocks in position 12" );
 
+SKIP: {
+       local *STAT;
+       skip("Could not open file: $!", 2) unless open(STAT, 'TEST');
+       ok( File::stat::stat('STAT'), '... should be able to find filehandle' );
+
+       package foo;
+       local *STAT = *main::STAT;
+       main::ok( my $stat2 = File::stat::stat('STAT'), 
+               '... and filehandle in another package' );
+       close STAT;
+
+#      VOS open() updates atime; ignore this error (posix-975).
+       my $stat3 = $stat2;
+       if ($^O eq 'vos') {
+               $$stat3[8] = $$stat[8];
+       }
+
+       main::skip("Win32: different stat-info on filehandle", 1) if $^O eq 'MSWin32';
+       main::skip("dos: inode number is fake on dos", 1) if $^O eq 'dos';
+
+       main::skip("OS/2: inode number is not constant on os/2", 1) if $^O eq 'os2';
+
+       main::is( "@$stat", "@$stat3", '... and must match normal stat' );
+}
+
 local $!;
 $stat = stat '/notafile';
 isn't( $!, '', 'should populate $!, given invalid file' );