This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Refactoring the /Can't return (?:array|hash) to scalar context/ croak
[perl5.git] / lib / DirHandle.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 require './test.pl';
15
16 plan(5);
17
18 $dot = new DirHandle ($^O eq 'MacOS' ? ':' : '.');
19
20 ok(defined($dot));
21
22 @a = sort <*>;
23 do { $first = $dot->read } while defined($first) && $first =~ /^\./;
24 ok(+(grep { $_ eq $first } @a));
25
26 @b = sort($first, (grep {/^[^.]/} $dot->read));
27 ok(+(join("\0", @a) eq join("\0", @b)));
28
29 $dot->rewind;
30 @c = sort grep {/^[^.]/} $dot->read;
31 cmp_ok(+(join("\0", @b), 'eq', join("\0", @c)));
32
33 $dot->close;
34 $dot->rewind;
35 ok(!defined($dot->read));