Skip to content

Comments

feat: add read(), write(), and append() helper methods#209

Open
Koan-Bot wants to merge 1 commit intocpanel:masterfrom
atoomic:koan.atoomic/implement-read-write-helpers
Open

feat: add read(), write(), and append() helper methods#209
Koan-Bot wants to merge 1 commit intocpanel:masterfrom
atoomic:koan.atoomic/implement-read-write-helpers

Conversation

@Koan-Bot
Copy link
Contributor

@Koan-Bot Koan-Bot commented Feb 23, 2026

Summary

Adds three convenience methods to Test::MockFile objects for directly manipulating mocked file contents (#111):

  • read() — returns file contents. Scalar context slurps; list context splits into lines respecting $/
  • write(@args) — sets contents (concatenates args), updates mtime/ctime, returns $self for chaining
  • append(@args) — appends to contents, creates file if non-existent, returns $self for chaining

All three die on directories and symlinks. write/append bring non-existent files into existence.

Closes #111

Test plan

  • 30 tests in t/read_write_helpers.t
  • CI matrix (Perl 5.14–5.42)

🤖 Generated with Claude Code

@atoomic atoomic marked this pull request as ready for review February 23, 2026 04:25
@atoomic atoomic requested a review from toddr February 23, 2026 05:43
Convenience methods to read/modify mocked file contents without
going through the tied filehandle layer. read() supports scalar
(slurp) and list (line-split respecting $/) contexts. write() and
append() update mtime/ctime and return $self for chaining.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Koan-Bot Koan-Bot force-pushed the koan.atoomic/implement-read-write-helpers branch from 356d85e to e80e426 Compare February 24, 2026 21:31
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.

Consider providing read and write helper for mocked files

2 participants