11 use vars qw($fh @fh %fh);
13 eval 'opendir(NOSUCH, "no/such/directory");';
18 opendir(OP, "op") or die "can't opendir: $!";
19 # should auto-closedir() here
22 is(opendir(OP, "op"), 1);
23 my @D = grep(/^[^\.].*\.t$/i, readdir(OP));
28 open my $man, '<', '../MANIFEST' or die "Can't open ../MANIFEST: $!";
30 ++$expect if m!^t/op/[^/]+\t!;
34 my ($min, $max) = ($expect - 10, $expect + 10);
35 within(scalar @D, $expect, 10, 'counting op/*.t');
38 my @G = sort <op/*.t>;
39 if ($G[0] =~ m#.*\](\w+\.t)#i) {
40 # grep is to convert filespecs returned from glob under VMS to format
41 # identical to that returned by readdir
42 @G = grep(s#.*\](\w+\.t).*#op/$1#i,<op/*.t>);
44 while (@R && @G && $G[0] eq 'op/'.$R[0]) {
48 is(scalar @R, 0, 'readdir results all accounted for');
49 is(scalar @G, 0, 'glob results all accounted for');
51 is(opendir($fh, "op"), 1);
53 is(opendir($fh[0], "op"), 1);
54 is(ref $fh[0], 'GLOB');
55 is(opendir($fh{abc}, "op"), 1);
56 is(ref $fh{abc}, 'GLOB');
57 isnt("$fh", "$fh[0]");
58 isnt("$fh", "$fh{abc}");
60 # See that perl does not segfault upon readdir($x=".");
61 # http://rt.perl.org/rt3/Ticket/Display.html?id=68182
62 fresh_perl_like(<<'EOP', qr/^no crash/, {}, 'RT #68182');
65 my @files = readdir($x);
72 # test that readdir doesn't modify errno on successfully reaching the end of the list
73 # in scalar context, POSIX requires that readdir() not modify errno on end-of-directory
75 ok(opendir(OP, "op"), "opendir op");
77 while (defined(my $f = readdir OP)) {
79 if $f =~ /^[^\.].*\.t$/i;
83 is(@s, @D, "should be the same number of files, scalar or list")
84 or skip "mismatch on file count - presumably a readdir error", 1;
85 is($errno, 0, "errno preserved");