Change 14819 by jhi@alpha on 2002/02/21 21:06:54
Subject: [PATCH lib/File/stat.t, lib/File/stat.pm] Find Filehandles Fully (was
Re: [ID 20020221.004] [PATCH] File/stat.pm , Perl 5.6.1)
From: chromatic <[EMAIL PROTECTED]>
Date: Thu, 21 Feb 2002 14:17:35 -0700
Message-ID: <[EMAIL PROTECTED]>
Affected files ...
.... //depot/perl/lib/File/stat.pm#14 edit
.... //depot/perl/lib/File/stat.t#6 edit
Differences ...
==== //depot/perl/lib/File/stat.pm#14 (text) ====
Index: perl/lib/File/stat.pm
--- perl/lib/File/stat.pm.~1~ Thu Feb 21 14:15:05 2002
+++ perl/lib/File/stat.pm Thu Feb 21 14:15:05 2002
@@ -53,7 +53,7 @@
local $!;
no strict 'refs';
require Symbol;
- $fh = \*{Symbol::qualify($arg)};
+ $fh = \*{ Symbol::qualify( $arg, caller() )};
return unless defined fileno $fh;
}
return populate(CORE::stat $fh);
==== //depot/perl/lib/File/stat.t#6 (text) ====
Index: perl/lib/File/stat.t
--- perl/lib/File/stat.t.~1~ Thu Feb 21 14:15:05 2002
+++ perl/lib/File/stat.t Thu Feb 21 14:15:05 2002
@@ -16,10 +16,10 @@
$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' );
@@ -56,6 +56,20 @@
is( $stat->blocks, $stat[12], "number of blocks in position 12" );
+SKIP: {
+ local *STAT;
+ skip(2, "Could not open file: $!") 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;
+
+ main::is( "@$stat", "@$stat2", '... and must match normal stat' );
+}
+
local $!;
$stat = stat '/notafile';
isn't( $!, '', 'should populate $!, given invalid file' );
End of Patch.