summaryrefslogtreecommitdiff
path: root/ext/IO
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2003-06-17 18:12:26 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2003-06-17 18:12:26 +0000
commit15bb75ac03814e0ff7197c6bddcd5eab334d5864 (patch)
treea6ee624be588b8c7c38e018af0442ae0e470973d /ext/IO
parenta97fb7de1c49a8414fac8dd85b621cd0459704e2 (diff)
downloadperl-15bb75ac03814e0ff7197c6bddcd5eab334d5864.tar.gz
io_dir.t tweak from Craig Berry.
p4raw-id: //depot/perl@19806
Diffstat (limited to 'ext/IO')
-rwxr-xr-xext/IO/lib/IO/t/io_dir.t30
1 files changed, 18 insertions, 12 deletions
diff --git a/ext/IO/lib/IO/t/io_dir.t b/ext/IO/lib/IO/t/io_dir.t
index 75979a3816..f4d2164232 100755
--- a/ext/IO/lib/IO/t/io_dir.t
+++ b/ext/IO/lib/IO/t/io_dir.t
@@ -17,27 +17,35 @@ select(STDOUT); $| = 1;
use IO::Dir qw(DIR_UNLINK);
+my $tcount = 0;
+
+sub ok {
+ $tcount++;
+ my $not = $_[0] ? '' : 'not ';
+ print "${not}ok $tcount\n";
+}
+
print "1..10\n";
my $DIR = $^O eq 'MacOS' ? ":" : ".";
$dot = new IO::Dir $DIR;
-print defined($dot) ? "ok" : "not ok", " 1\n";
+ok(defined($dot));
@a = sort <*>;
do { $first = $dot->read } while defined($first) && $first =~ /^\./;
-print +(grep { $_ eq $first } @a) ? "ok" : "not ok", " 2\n";
+ok(+(grep { $_ eq $first } @a));
@b = sort($first, (grep {/^[^.]/} $dot->read));
-print +(join("\0", @a) eq join("\0", @b)) ? "ok" : "not ok", " 3\n";
+ok(+(join("\0", @a) eq join("\0", @b)));
$dot->rewind;
@c = sort grep {/^[^.]/} $dot->read;
-print +(join("\0", @b) eq join("\0", @c)) ? "ok" : "not ok", " 4\n";
+ok(+(join("\0", @b) eq join("\0", @c)));
$dot->close;
$dot->rewind;
-print defined($dot->read) ? "not ok" : "ok", " 5\n";
+ok(!defined($dot->read));
open(FH,'>X') || die "Can't create x";
print FH "X";
@@ -47,22 +55,20 @@ tie %dir, IO::Dir, $DIR;
my @files = keys %dir;
# I hope we do not have an empty dir :-)
-print @files ? "ok" : "not ok", " 6\n";
+ok(scalar @files);
my $stat = $dir{'X'};
-print defined($stat) && UNIVERSAL::isa($stat,'File::stat') && $stat->size == 1
- ? "ok" : "not ok", " 7\n";
+ok(defined($stat) && UNIVERSAL::isa($stat,'File::stat') && $stat->size == 1);
delete $dir{'X'};
-print -f 'X' ? "ok" : "not ok", " 8\n";
+ok(-f 'X');
tie %dirx, IO::Dir, $DIR, DIR_UNLINK;
my $statx = $dirx{'X'};
-print defined($statx) && UNIVERSAL::isa($statx,'File::stat') && $statx->size == 1
- ? "ok" : "not ok", " 9\n";
+ok(defined($statx) && UNIVERSAL::isa($statx,'File::stat') && $statx->size == 1);
delete $dirx{'X'};
-print -f 'X' ? "not ok" : "ok", " 10\n";
+ok(!(-f 'X'));