Skip to content

Clean up and reorganize diff tests (#11)#12

Closed
carpentry-agent[bot] wants to merge 1 commit into
masterfrom
claude/cleanup-diff-tests
Closed

Clean up and reorganize diff tests (#11)#12
carpentry-agent[bot] wants to merge 1 commit into
masterfrom
claude/cleanup-diff-tests

Conversation

@carpentry-agent

Copy link
Copy Markdown

Addresses #11 — the test file was, in @hellerve's words, "a right mess … mostly formatting."

What changed

  • Grouped the assertions into logical sections with brief single-line section comments: core diff · empty/single-element inputs · word/line/char diffs · apply · revert · lcs-length · edit-distance · similarity · str/prn · unified & unified-with-context · patch.
  • Normalized assertion messages for a consistent style (e.g. "arrays" throughout instead of mixing "lists"/"arrays"; parallel phrasing within each group; "Eq and Insertion" rather than "Eq+Insertion").
  • Let carp-fmt settle the layout.

Coverage is unchanged

  • 72 asserts before, 72 after. No exact-duplicate asserts existed, so none were removed.
  • Every expected value and actual test expression is preserved verbatim — only ordering, grouping, section comments, and message wording changed. This was verified mechanically by parsing both versions into assert S-expressions and confirming the multiset of (expected, actual-expression) pairs is identical (messages ignored).

Verification

  • carp -x tests/diff.carpPassed: 72, Failed: 0 (both before and after).
  • carp-fmt --check tests/diff.carp → clean.
  • angler tests/diff.carp → clean.

Opened by the carpentry-org heartbeat agent (Claude). Veit has not reviewed this yet.

@carpentry-reviewer carpentry-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build & Tests

Checked out claude/cleanup-diff-tests at c258d27 and ran it locally.

  • Build: clean.
  • Tests: carp -x tests/diff.carp72 passed, 0 failed. I also ran the suite on master for comparison → 72 passed, 0 failed. Identical.
  • carp-fmt --check and angler: clean.
  • CI: both test jobs green.

Findings

This is a test-only reorganization, and the one thing that matters for a "cleanup" PR is that it doesn't quietly weaken coverage. The PR claims the expected/actual expressions are preserved verbatim and only ordering, grouping, section comments, and message wording changed. I verified that claim independently rather than taking it on trust: I parsed both master and the branch versions of tests/diff.carp with an S-expression parser (handling Carp char literals and comments), stripped the test argument and the trailing message string from every assert-equal, and compared the multiset of (expected, actual) content pairs across all 72 assertions.

Result: the two multisets are identical — 72 forms on each side, same distinct content, zero pairs present on one side but not the other. So no assertion was dropped, added, reordered-into-oblivion, or had its expected value or tested expression altered. The only changes are:

  • Section comments grouping the asserts by feature (core diff, empty/single-element, word/line/char diffs, apply, revert, lcs-length, edit-distance, similarity, str/prn, unified & unified-with-context, patch) — a sensible organization that matches the file's actual contents.
  • Reordering related asserts together (e.g. the prefix/suffix and "completely different" cases now sit with the core diff group).
  • Message rewording for consistency and precision ("diffing equal lists means everything is equal""diff of equal arrays is all Eq"; "lists" normalized to "arrays" throughout). The new messages are genuinely clearer.

deftest/with-test threading is intact — the section comments sit between top-level (assert-equal test …) forms, not inside a do, so every assert is still threaded and counted (72 run, matching master). The library source is untouched (only tests/diff.carp changed). No CHANGELOG needed — this is test-internal, not user-facing.

Verdict: merge

This does exactly what issue #11 asked for — a formatting/organization cleanup of the test file — and I mechanically confirmed coverage is preserved verbatim. It builds, all 72 tests pass, formatting and lint are clean, and there are no open questions. Ready to land.

@hellerve hellerve left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this does nothing of what i wanted changed and just churns for no reason.

Comment thread tests/diff.carp Outdated
h
i
j
KK")) "unified generates multiple hunks for distant changes")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this long span of one-char-per-line strings is what i mean.

The unified/patch assertions built their expected output with
&(String.concat &[@"...one line..." @"...next line..." ...]) — a long
span of one-char-per-line fragments. Replace each with the equivalent
plain multi-line string literal (already a Ref String, so no &).

Byte-identical expected values; coverage unchanged (72 passed, 0 failed).

Addresses #11.
@carpentry-agent carpentry-agent Bot force-pushed the claude/cleanup-diff-tests branch from c258d27 to 3a5af8c Compare July 10, 2026 23:27
@carpentry-agent

Copy link
Copy Markdown
Author

@hellerve — you're right, and I've redone this from scratch.

The reordering and message rewording were churn you didn't ask for, so I hard-reset the branch back to master to drop all of that. The only thing this PR now touches is the mess you pointed at inline: the long spans of one-char-per-line strings.

Each of the 7 unified / unified-with-context assertions built its expected output like this:

&(String.concat &[@"@@ -1,3 +1,3 @@
" @" line1
" @"+changed
" @"-line2
" @" line3
"])

and is now just the plain multi-line literal it was spelling out the hard way:

"@@ -1,3 +1,3 @@
 line1
+changed
-line2
 line3
"

The &(String.concat &[…]) wrapper is gone (a bare string literal is already a Ref String, like the "" empty-diff case already in the file). Expected values are byte-identical — carp -x tests/diff.carp still reports 72 passed, 0 failed, carp-fmt --check and angler are clean. The diff versus master is exactly these 7 spans collapsing, nothing else.


Opened by the carpentry-org heartbeat agent (Claude). Veit has not reviewed this yet.

@carpentry-reviewer carpentry-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build & Tests

Checked out claude/cleanup-diff-tests at 3a5af8c. The branch is now master (63b5e65) + exactly one commit — I confirmed the hard-reset, so none of the earlier reordering/message churn survives.

  • Only tests/diff.carp changed (55 ins / 55 del, a symmetric 1:1 replacement). Library source untouched.
  • carp -x tests/diff.carp72 passed, 0 failed.
  • carp-fmt --check and angler: clean. CI: both jobs green.

Prior feedback

  • My earlier review (on the previous HEAD c258d27) recommended merge — that was wrong. It was the version you rejected as churn: it reorganized and reworded instead of fixing the thing you pointed at.
  • Your inline note was that the "long span of one-char-per-line strings" was the actual problem. This revision addresses exactly that: all 7 &(String.concat &[@"…\n" @"…\n" …]) expected values are now plain multi-line string literals. grep confirms zero String.concat left in the file.
  • No reordering, no message rewording this round — I diffed against master and the only changed lines are the expected-string collapses; every assert message and tested expression is byte-for-byte untouched.

Findings

  • Byte-identity holds. Since the library source is unchanged and all 72 asserts still pass, each new literal equals the function's real output — the same output the old String.concat form matched on master. So the expected values are byte-identical, just spelled directly (e.g. the concat for "unified renders single-hunk diff" is now the literal "@@ -1,3 +1,3 @@\n line1\n+changed\n-line2\n line3\n").
  • A bare "…" literal is already a Ref String, matching the &(unified …) it's compared against — consistent with the existing "" empty-diff assertion. No type change.
  • Nothing else found.

Verdict: merge

Delivers exactly the cleanup issue #11 asked for and you pointed at inline — the one-char-per-line expected strings are gone, replaced by byte-identical plain literals with zero other churn. Builds, 72/72 pass, fmt/lint clean.

@hellerve hellerve left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely wrong.

@hellerve

Copy link
Copy Markdown
Member

Stop guessing and blindly flailing please.

@hellerve hellerve closed this Jul 11, 2026
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