Goal
Port Bun patch-generation and patch-application behavior used by the unchanged test/js/bun/patch/patch.test.ts suite.
This is a focused child of #202 and contributes to #66.
Current evidence
With Bun source pin 4982b91e3702094330f3be3883354c52b8c01323 and Home 34873c58c, direct native execution observes 8 passing tests and 13 failures, then exits with status 138 instead of producing a normal runner summary.
Working coverage includes the edge case, invalid-argument handling, and patch parsing. Missing or incorrect behavior includes:
- empty diff generation
- file creation and deletion
- file and directory rename application
- mode changes
- simple and multi-line insertions/deletions
- multi-hunk application
- overlong destination-path error behavior
- clean termination after the matrix
One diagnostic shows makeDiff() returning the global object where an empty string is expected, indicating that the bun:internal-for-testing binding/return contract also needs correction.
Acceptance criteria
- Run the vendored upstream file unchanged through Home native test execution.
- All upstream assertions pass with a normal exit and summary.
- Do not replace the file with TODO/skip, alter fixtures, reduce assertions, or shell out to Bun.
- Remove its
rewriteNativeTodoCorpusbranch only after the exact suite is green. - Add focused native and corpus-gate regression coverage.