From: Nicholas Clark Date: Tue, 13 Mar 2007 22:24:54 +0000 (+0000) Subject: Check that stat and -X on barewords favour the file handle over the X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6d6dd8fe2389854be819a87e95a54330b9102b90;p=p5sagit%2Fp5-mst-13.2.git Check that stat and -X on barewords favour the file handle over the directory handle for the ambiguous case. p4raw-id: //depot/perl@30571 --- diff --git a/t/op/stat.t b/t/op/stat.t index 7cb6b1b..2457b07 100755 --- a/t/op/stat.t +++ b/t/op/stat.t @@ -9,7 +9,7 @@ BEGIN { use Config; use File::Spec; -plan tests => 95; +plan tests => 101; my $Perl = which_perl(); @@ -480,11 +480,22 @@ ok(unlink($f), 'unlink tmp file'); } SKIP: { - skip "No dirfd()", 3 unless $Config{d_dirfd}; + skip "No dirfd()", 9 unless $Config{d_dirfd}; ok(opendir(DIR, "."), 'Can open "." dir') || diag "Can't open '.': $!"; ok(stat(DIR), "stat() on dirhandle works"); ok(-d -r _ , "chained -x's on dirhandle"); - closedir DIR; + ok(-d DIR, "-d on a dirhandle works"); + + # And now for the ambigious bareword case + ok(open(DIR, "TEST"), 'Can open "TEST" dir') + || diag "Can't open 'TEST': $!"; + my $size = (stat(DIR))[7]; + ok(defined $size, "stat() on bareword works"); + is($size, -s "TEST", "size returned by stat of bareword is for the file"); + ok(-f _, "ambiguous bareword uses file handle, not dir handle"); + ok(-f DIR); + closedir DIR or die $!; + close DIR or die $!; } {