Initial import from FreeBSD RELENG_4:
[dragonfly.git] / contrib / perl5 / t / lib / dirhand.t
1 #!./perl
2
3 BEGIN {
4     chdir 't' if -d 't';
5     @INC = '../lib';
6     require Config; import Config;
7     if (not $Config{'d_readdir'}) {
8         print "1..0\n";
9         exit 0;
10     }
11 }
12
13 use DirHandle;
14
15 print "1..5\n";
16
17 $dot = new DirHandle ".";
18 print defined($dot) ? "ok" : "not ok", " 1\n";
19
20 @a = sort <*>;
21 do { $first = $dot->read } while defined($first) && $first =~ /^\./;
22 print +(grep { $_ eq $first } @a) ? "ok" : "not ok", " 2\n";
23
24 @b = sort($first, (grep {/^[^.]/} $dot->read));
25 print +(join("\0", @a) eq join("\0", @b)) ? "ok" : "not ok", " 3\n";
26
27 $dot->rewind;
28 @c = sort grep {/^[^.]/} $dot->read;
29 print +(join("\0", @b) eq join("\0", @c)) ? "ok" : "not ok", " 4\n";
30
31 $dot->close;
32 $dot->rewind;
33 print defined($dot->read) ? "not ok" : "ok", " 5\n";