3 # Check that require doesn't leave the handle it uses open, if it happens that
4 # the handle it opens gets file descriptor 0. RT #37033.
13 my ($state, $want) = @_;
14 delete $INC{'test_use_14937.pm'};
15 open my $fh, '<', 'README' or die "Can't open README: $!";
16 my $fileno = fileno $fh;
19 "file handle has correct numeric file descriptor $state");
21 like($fileno, qr/\A\d+\z/,
22 "file handle has a numeric file descriptor $state");
26 is($INC{'test_use_14937.pm'}, undef, "test_use_14937 isn't loaded $state");
27 require test_use_14937;
28 isnt($INC{'test_use_14937.pm'}, undef, "test_use_14937 is loaded $state");
30 open $fh, '<', 'README' or die "Can't open README: $!";
31 is(fileno $fh, $fileno,
32 "file handle has the same numeric file descriptor $state");
36 is(fileno STDIN, 0, 'STDIN is open on file descriptor 0');
37 test_require('(STDIN open)');
39 close STDIN or die "Can't close STDIN: $!";
41 is(fileno STDIN, undef, 'STDIN is closed');
42 test_require('(STDIN closed)', 0);