Skip to content

test: add syswrite/sysread edge case coverage#282

Draft
Koan-Bot wants to merge 1 commit intocpanel:masterfrom
atoomic:koan.atoomic/test-sysreadwrite-edge-cases
Draft

test: add syswrite/sysread edge case coverage#282
Koan-Bot wants to merge 1 commit intocpanel:masterfrom
atoomic:koan.atoomic/test-sysreadwrite-edge-cases

Conversation

@Koan-Bot
Copy link
Contributor

@Koan-Bot Koan-Bot commented Mar 3, 2026

What

Add comprehensive test coverage for edge cases in WRITE and READ tied methods in FileHandle.pm.

Why

These code paths were identified as untested during audit (session 96/97 coverage gaps):

  • syswrite: zero-length write, append mode, seek-past-EOF gap, float/negative/non-numeric len
  • sysread: non-numeric/negative/float len validation, undef buffer initialization, EBADF on write-only handle

How

Single test file (t/sysreadwrite_edge_cases.t) with 20 subtests covering both WRITE and READ tied method edge cases. Uses local $SIG{__WARN__} to capture expected warnings without triggering NoWarnings.

Testing

Syntax-checked locally. Full CI validation pending (tests can't run locally — missing Test2 deps).


🤖 Generated with Claude Code

Cover untested paths in FileHandle.pm WRITE and READ tied methods:

syswrite:
- zero-length write (len=0) returns 0, writes nothing
- O_APPEND mode always appends even after seek
- seek past EOF then write creates null-byte gap
- float len truncated to int (2.9 → 2)
- non-numeric len warns + EINVAL
- negative len warns + EINVAL
- empty buffer with len=0

sysread:
- non-numeric len warns + returns undef + EINVAL
- negative len warns + returns undef + EINVAL
- float len truncated to int (3.7 → 3)
- zero-length read returns 0
- undef buffer initialized to empty string
- undef buffer with offset pads null bytes
- write-only handle returns undef + EBADF
- read at EOF returns 0
- write then read in O_RDWR mode

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant