summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/File/stat.pm4
-rw-r--r--lib/File/stat.t19
2 files changed, 20 insertions, 3 deletions
diff --git a/lib/File/stat.pm b/lib/File/stat.pm
index a783e08cac..d4030334d8 100644
--- a/lib/File/stat.pm
+++ b/lib/File/stat.pm
@@ -84,7 +84,9 @@ else {
my ($s, $mode, $eff) = @_;
my $uid = $eff ? $> : $<;
- $^O ne "VMS" and $uid == 0 and return 1;
+ # If we're root on unix and we are not testing for exectable
+ # status, then all file tests are true.
+ $^O ne "VMS" and $uid == 0 and !($mode & 0111) and return 1;
my ($stmode, $stuid, $stgid) = @$s[2,4,5];
diff --git a/lib/File/stat.t b/lib/File/stat.t
index afeb446b13..40bd86bd19 100644
--- a/lib/File/stat.t
+++ b/lib/File/stat.t
@@ -21,7 +21,7 @@ BEGIN {
our $file = '../lib/File/stat.t';
if ( $Dmksymlinks ) {
$file = readlink $file;
- die "Can't readlink(TEST): $!" if ! defined $file;
+ die "Can't readlink(../lib/File/stat.t): $!" if ! defined $file;
}
our $hasst;
@@ -42,7 +42,7 @@ BEGIN {
our @stat = stat $file; # This is the function stat.
unless (@stat) { plan skip_all => "1..0 # Skip: no file $file"; exit 0 }
-plan tests => 19 + 24*2 + 3;
+plan tests => 19 + 24*2 + 4 + 3;
use_ok( 'File::stat' );
@@ -91,6 +91,21 @@ for (split //, "rwxoRWXOezsfdlpSbcugkMCA") {
}
}
+SKIP: {
+ my $file = '../perl';
+ -e $file && -x $file or skip "$file is not present and exectable", 4;
+ $^O eq "VMS" and skip "File::stat ignores VMS ACLs", 4;
+
+ my $stat = File::stat::stat( $file ); # This is the OO stat.
+ foreach (qw/x X/) {
+ my $rv = eval "-$_ \$stat";
+ ok( !$@, "-$_ overload succeeds" )
+ or diag( $@ );
+ is( $rv, eval "-$_ \$file", "correct -$_ overload" );
+ }
+}
+
+
for (split //, "tTB") {
eval "-$_ \$stat";
like( $@, qr/\Q-$_ is not implemented/, "-$_ overload fails" );