Skip to content

fix: align unit tests with system Perl behavior#476

Merged
fglock merged 1 commit intomasterfrom
fix/unit-test-parity
Apr 9, 2026
Merged

fix: align unit tests with system Perl behavior#476
fglock merged 1 commit intomasterfrom
fix/unit-test-parity

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented Apr 9, 2026

Summary

Three fixes to align jperl behavior with system Perl, resolving unit test failures found via prove src/test/resources/unit:

  • $\ interpolation in double-quoted strings: Removed backslash from the non-interpolating characters set in StringDoubleQuoted.java so "$" is recognized as the output record separator variable, matching Perl's greedy variable capture
  • sysread on in-memory handles: Changed IOOperator.java to return undef with "Bad file descriptor" for sysread on PerlIO::scalar handles, matching system Perl behavior
  • IPC::Open3 stderr merging: Fixed IPCOpen3.java isUsableHandle() to check truthiness (not just definedness) of the error handle parameter. Per IPC::Open3 docs, a false $err (including "") means stderr merges with stdout

Test fixes

  • string_interpolation.t: expect "$\" to equal "" (not "")
  • sysread_syswrite.t: expect sysread on in-memory handle to return undef
  • ipc_open3.t: fix tests that used $err="" expecting separate stderr; use gensym for fileno test, expect merged output for empty-string tests

All three test files now produce identical pass/fail results on both system Perl and jperl.

Test plan

  • All 14 ipc_open3.t tests pass on both system Perl and jperl
  • string_interpolation.t passes on both
  • sysread_syswrite.t passes on both
  • make passes (build + all unit tests)
  • prove src/test/resources/unit - all tests successful

Generated with Devin

Three fixes for parity with system Perl:

1. $\ interpolation in double-quoted strings: Remove backslash from
   the non-interpolating characters set so "$\" is recognized as the
   output record separator variable, matching Perl's greedy capture.

2. sysread on in-memory handles: Return undef with "Bad file
   descriptor" error instead of reading data, matching Perl behavior
   where sysread/syswrite don't work on in-memory (PerlIO::scalar)
   handles.

3. IPC::Open3 stderr merging: Check truthiness (not just definedness)
   of the error handle parameter. Per IPC::Open3 docs, a false $err
   (including "") means stderr merges with stdout.

Test fixes:
- string_interpolation.t: expect "$\\" to equal "\" (not "")
- sysread_syswrite.t: expect sysread on in-memory handle to return undef
- ipc_open3.t: fix tests that used $err="" expecting separate stderr;
  use gensym for fileno test, expect merged output for empty-string tests

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@fglock fglock force-pushed the fix/unit-test-parity branch from 8794a55 to 98796ea Compare April 9, 2026 19:35
@fglock fglock merged commit 8459cab into master Apr 9, 2026
2 checks passed
@fglock fglock deleted the fix/unit-test-parity branch April 9, 2026 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant