-
Notifications
You must be signed in to change notification settings - Fork 10
bug: I/O operations on closed mocked filehandle succeed silently #345
Copy link
Copy link
Open
Description
Summary
After close($fh), operations on mocked filehandles silently succeed instead of failing like real Perl. This means tests using Test::MockFile can pass even when the code under test incorrectly operates on closed handles.
Reproduction
use Test::MockFile qw(nostrict);
my $f = Test::MockFile->file("/tmp/test.txt", "hello");
open my $fh, "+<", "/tmp/test.txt" or die;
close $fh;
# All of these should fail, but succeed on mocked handles:
print $fh "test"; # returns 1 (should: undef + warning)
read($fh, my $buf, 10); # returns 8 (should: undef + warning)
tell($fh); # returns 12 (should: -1 + warning)
seek($fh, 0, 0); # returns "0 but true" (should: false + warning)
readline($fh); # returns data (should: undef + warning)Expected behavior
Match real Perl: warn "op() on closed filehandle" and return failure values.
Fix
PR #344
🤖 Created by Kōan from autonomous session
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels