4 # Check that require doesn't leave the handle it uses open, if it happens that
5 # the handle it opens gets file descriptor 0. RT #37033.
11 my ($state, $want) = @_;
12 delete $INC{'test_use_14937.pm'};
13 open my $fh, '<', 'README' or die "Can't open README: $!";
14 my $fileno = fileno $fh;
17 "file handle has correct numeric file descriptor $state");
19 like($fileno, qr/\A\d+\z/,
20 "file handle has a numeric file descriptor $state");
24 is($INC{'test_use_14937.pm'}, undef, "test_use_14937 isn't loaded $state");
25 require test_use_14937;
26 isnt($INC{'test_use_14937.pm'}, undef, "test_use_14937 is loaded $state");
28 open $fh, '<', 'README' or die "Can't open README: $!";
29 is(fileno $fh, $fileno,
30 "file handle has the same numeric file descriptor $state");
34 is(fileno STDIN, 0, 'STDIN is open on file descriptor 0');
35 test_require('(STDIN open)');
37 close STDIN or die "Can't close STDIN: $!";
39 is(fileno STDIN, undef, 'STDIN is closed');
40 test_require('(STDIN closed)', 0);