summaryrefslogtreecommitdiff
path: root/ext/Fcntl/t/mode.t
diff options
context:
space:
mode:
Diffstat (limited to 'ext/Fcntl/t/mode.t')
-rw-r--r--ext/Fcntl/t/mode.t68
1 files changed, 64 insertions, 4 deletions
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");
+ }
+}
+