This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Mark all .t and .pm files as non executable
[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 # 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.
21 my $chdir;
22 if ($ENV{PERL_CORE} && -d 'uni') {
23   chdir 'uni';
24   $chdir++;
25 };
26
27 $dot = new DirHandle ($^O eq 'MacOS' ? ':' : '.');
28
29 ok(defined($dot));
30
31 @a = sort <*>;
32 do { $first = $dot->read } while defined($first) && $first =~ /^\./;
33 ok(+(grep { $_ eq $first } @a));
34
35 @b = sort($first, (grep {/^[^.]/} $dot->read));
36 ok(+(join("\0", @a) eq join("\0", @b)));
37
38 $dot->rewind;
39 @c = sort grep {/^[^.]/} $dot->read;
40 cmp_ok(+(join("\0", @b), 'eq', join("\0", @c)));
41
42 $dot->close;
43 $dot->rewind;
44 ok(!defined($dot->read));
45
46 if ($chdir) {
47   chdir "..";
48 }