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.
12 my ($state, $want) = @_;
13 delete $INC{'test_use_14937.pm'};
14 open my $fh, '<', 'README' or die "Can't open README: $!";
15 my $fileno = fileno $fh;
18 "file handle has correct numeric file descriptor $state");
20 like($fileno, qr/\A\d+\z/,
21 "file handle has a numeric file descriptor $state");
25 is($INC{'test_use_14937.pm'}, undef, "test_use_14937 isn't loaded $state");
26 require test_use_14937;
27 isnt($INC{'test_use_14937.pm'}, undef, "test_use_14937 is loaded $state");
29 open $fh, '<', 'README' or die "Can't open README: $!";
30 is(fileno $fh, $fileno,
31 "file handle has the same numeric file descriptor $state");
35 is(fileno STDIN, 0, 'STDIN is open on file descriptor 0');
36 test_require('(STDIN open)');
38 close STDIN or die "Can't close STDIN: $!";
40 is(fileno STDIN, undef, 'STDIN is closed');
41 test_require('(STDIN closed)', 0);