For tied file handle calls, use PUSH* when we know that the stack has space.
[p5sagit/p5-mst-13.2.git] / lib / DirHandle.t
CommitLineData
c07a80fd 1#!./perl
2
3BEGIN {
4 chdir 't' if -d 't';
20822f61 5 @INC = '../lib';
c07a80fd 6 require Config; import Config;
1b4456a8 7 if (not $Config{'d_readdir'}) {
c07a80fd 8 print "1..0\n";
9 exit 0;
10 }
11}
12
13use DirHandle;
a3163838 14require './test.pl';
c07a80fd 15
a3163838 16plan(5);
c07a80fd 17
ffe4764e 18# Fetching the list of files in two different ways and expecting them
19# to be the same is a race condition when tests are running in parallel.
20# So go somewhere quieter.
21my $chdir;
22if ($ENV{PERL_CORE} && -d 'uni') {
23 chdir 'uni';
24 $chdir++;
25};
26
95e8664e 27$dot = new DirHandle ($^O eq 'MacOS' ? ':' : '.');
28
a3163838 29ok(defined($dot));
c07a80fd 30
1b4456a8 31@a = sort <*>;
c07a80fd 32do { $first = $dot->read } while defined($first) && $first =~ /^\./;
a3163838 33ok(+(grep { $_ eq $first } @a));
c07a80fd 34
35@b = sort($first, (grep {/^[^.]/} $dot->read));
a3163838 36ok(+(join("\0", @a) eq join("\0", @b)));
c07a80fd 37
38$dot->rewind;
39@c = sort grep {/^[^.]/} $dot->read;
a3163838 40cmp_ok(+(join("\0", @b), 'eq', join("\0", @c)));
c07a80fd 41
42$dot->close;
43$dot->rewind;
a3163838 44ok(!defined($dot->read));
ffe4764e 45
46if ($chdir) {
47 chdir "..";
48}