summaryrefslogtreecommitdiff
path: root/ext/Fcntl
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2010-10-18 15:04:32 +0200
committerNicholas Clark <nick@ccl4.org>2010-10-18 15:04:32 +0200
commitfb59364be1e5fdc818e4e1b5eba83f65ccfeb189 (patch)
tree6834137a7914b38c1399da382dfe8dde8a60e3a4 /ext/Fcntl
parentdf5a3819cf43fd65bb6db52619f7b36d3d11063f (diff)
downloadperl-fb59364be1e5fdc818e4e1b5eba83f65ccfeb189.tar.gz
Fix Fcntl::S_ISENFMT(), which could never have worked before.
S_ISENFMT() and S_ISWHT() were added in 2000 as part of commit ca6e1c26e8ac218f. 1a16747c2ea1992d (2 weeks later) intended to fix the copy/paste error in that previous commit which would prevent either from working. It did fix S_ISWHT(). However, there was a second error in the definition of S_ISEMFMT() which was never picked up - S_ENFMT(), not S_IFENFMT().
Diffstat (limited to 'ext/Fcntl')
-rw-r--r--ext/Fcntl/Fcntl.pm4
-rw-r--r--ext/Fcntl/t/mode.t68
2 files changed, 66 insertions, 6 deletions
diff --git a/ext/Fcntl/Fcntl.pm b/ext/Fcntl/Fcntl.pm
index e173c34785..58017f0ce0 100644
--- a/ext/Fcntl/Fcntl.pm
+++ b/ext/Fcntl/Fcntl.pm
@@ -61,7 +61,7 @@ our($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS, $AUTOLOAD);
require Exporter;
@ISA = qw(Exporter);
BEGIN {
- $VERSION = "1.07";
+ $VERSION = '1.08';
}
# Items to export into callers namespace by default
@@ -226,7 +226,7 @@ sub S_ISBLK { ( $_[0] & _S_IFMT() ) == S_IFBLK() }
sub S_ISCHR { ( $_[0] & _S_IFMT() ) == S_IFCHR() }
sub S_ISFIFO { ( $_[0] & _S_IFMT() ) == S_IFIFO() }
sub S_ISWHT { ( $_[0] & _S_IFMT() ) == S_IFWHT() }
-sub S_ISENFMT { ( $_[0] & _S_IFMT() ) == S_IFENFMT() }
+sub S_ISENFMT { ( $_[0] & _S_IFMT() ) == S_ENFMT() }
sub AUTOLOAD {
(my $constname = $AUTOLOAD) =~ s/.*:://;
diff --git a/ext/Fcntl/t/mode.t b/ext/Fcntl/t/mode.t
index 3114a0b775..b16601e5d9 100644
--- a/ext/Fcntl/t/mode.t
+++ b/ext/Fcntl/t/mode.t
@@ -1,11 +1,71 @@
#!./perl -w
-use Test::More tests => 2;
+use Test::More;
use File::Temp;
+use File::Spec;
+
use Fcntl qw(:mode);
my $tmpfile = File::Temp->new;
-my $mode = (stat "$tmpfile")[2];
-ok( S_ISREG($mode), " S_ISREG tmpfile");
-ok(!S_ISDIR($mode), "!S_ISDIR tmpfile");
+my @tests = (
+ ['REG', 'tmpfile', (stat "$tmpfile")[2]],
+ ['DIR', 'dir', (stat '.')[2]]
+ );
+
+$devnull = File::Spec->devnull();
+if (-c $devnull) {
+ push @tests, ['CHR', $devnull, (stat $devnull)[2]];
+}
+
+plan(tests => 9 * @tests);
+foreach (@tests) {
+ my ($type, $name, $mode) = @$_;
+
+ if ($type eq 'REG') {
+ ok( S_ISREG($mode), " S_ISREG $name");
+ } else {
+ ok(!S_ISREG($mode), "!S_ISREG $name");
+ }
+
+ if ($type eq 'DIR') {
+ ok( S_ISDIR($mode), " S_ISDIR $name");
+ } else {
+ ok(!S_ISDIR($mode), "!S_ISDIR $name");
+ }
+
+ SKIP: {
+ skip 'No S_IFCHR', 1 unless defined eval {S_IFCHR};
+ if ($type eq 'CHR') {
+ ok( S_ISCHR($mode), " S_ISCHR $name");
+ } else {
+ ok(!S_ISCHR($mode), "!S_ISCHR $name");
+ }
+ }
+
+ SKIP: {
+ skip 'No S_IFLNK', 1 unless defined eval {S_IFLNK};
+ ok(!S_ISLNK($mode), "!S_ISLNK $name");
+ }
+ SKIP: {
+ skip 'No S_IFSOCK', 1 unless defined eval {S_IFSOCK};
+ ok(!S_ISSOCK($mode), "!S_ISSOCK $name");
+ }
+ SKIP: {
+ skip 'No S_IFBLK', 1 unless defined eval {S_IFBLK};
+ ok(!S_ISBLK($mode), "!S_ISBLK $name");
+ }
+ SKIP: {
+ skip 'No S_IFFIFO', 1 unless defined eval {S_IFFIFO};
+ ok(!S_ISFIFO($mode), "!S_ISFIFO $name");
+ }
+ SKIP: {
+ skip 'No S_IFWHT', 1 unless defined eval {S_IFWHT};
+ ok(!S_ISWHT($mode), "!S_ISWHT $name");
+ }
+ SKIP: {
+ skip 'No S_ENFMT', 1 unless defined eval {S_ENFMT};
+ ok(!S_ISENFMT($mode), "!S_ISENFMT $name");
+ }
+}
+