xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/lib/DirHandle.t (revision 0:68f95e015346)
1*0Sstevel@tonic-gate#!./perl
2*0Sstevel@tonic-gate
3*0Sstevel@tonic-gateBEGIN {
4*0Sstevel@tonic-gate    chdir 't' if -d 't';
5*0Sstevel@tonic-gate    @INC = '../lib';
6*0Sstevel@tonic-gate    require Config; import Config;
7*0Sstevel@tonic-gate    if (not $Config{'d_readdir'}) {
8*0Sstevel@tonic-gate	print "1..0\n";
9*0Sstevel@tonic-gate	exit 0;
10*0Sstevel@tonic-gate    }
11*0Sstevel@tonic-gate}
12*0Sstevel@tonic-gate
13*0Sstevel@tonic-gateuse DirHandle;
14*0Sstevel@tonic-gaterequire './test.pl';
15*0Sstevel@tonic-gate
16*0Sstevel@tonic-gateplan(5);
17*0Sstevel@tonic-gate
18*0Sstevel@tonic-gate$dot = new DirHandle ($^O eq 'MacOS' ? ':' : '.');
19*0Sstevel@tonic-gate
20*0Sstevel@tonic-gateok(defined($dot));
21*0Sstevel@tonic-gate
22*0Sstevel@tonic-gate@a = sort <*>;
23*0Sstevel@tonic-gatedo { $first = $dot->read } while defined($first) && $first =~ /^\./;
24*0Sstevel@tonic-gateok(+(grep { $_ eq $first } @a));
25*0Sstevel@tonic-gate
26*0Sstevel@tonic-gate@b = sort($first, (grep {/^[^.]/} $dot->read));
27*0Sstevel@tonic-gateok(+(join("\0", @a) eq join("\0", @b)));
28*0Sstevel@tonic-gate
29*0Sstevel@tonic-gate$dot->rewind;
30*0Sstevel@tonic-gate@c = sort grep {/^[^.]/} $dot->read;
31*0Sstevel@tonic-gatecmp_ok(+(join("\0", @b), 'eq', join("\0", @c)));
32*0Sstevel@tonic-gate
33*0Sstevel@tonic-gate$dot->close;
34*0Sstevel@tonic-gate$dot->rewind;
35*0Sstevel@tonic-gateok(!defined($dot->read));
36