Settle's fallback test fails without the structure check
Fable's final review of 58fd476, gate honesty. In TestSettleFallsBackToJoinWhenTheBytesWouldNotParse the kept bytes and Join's were the same, so it passed with the check removed. Mine now has two new neighbouring blocks with a wide seam before an unclosed fence: kept, that seam stays and the fence swallows theirs' block; Join's bytes differ. With the check removed the test fails (got the kept bytes, want Join's).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+14
−10
internal/mapa/markup/settle_test.go+14 −10
diff --git a/internal/mapa/markup/settle_test.go b/internal/mapa/markup/settle_test.go| index 6390cc8..966060d 100644 |
| --- a/internal/mapa/markup/settle_test.go |
| +++ b/internal/mapa/markup/settle_test.go |
| @@ -79,10 +79,14 @@ func TestSettleChangesOnlyMineBlocksAndTheirSeams(t *testing.T) { |
| } |
| // The structure check: a result that would not parse back to the |
| -// settled blocks falls back to Join. |
| +// settled blocks falls back to Join. Mine's two new blocks are |
| +// neighbours in mine, so keeping bytes would put mine's own wide seam |
| +// between them; and mine's unclosed fence, no longer last, would then |
| +// swallow theirs' block. Join's bytes differ from the kept ones, so the |
| +// test fails if the check is skipped (review: it passed without it). |
| func TestSettleFallsBackToJoinWhenTheBytesWouldNotParse(t *testing.T) { |
| base := "A.\n\nB." |
| - mine := "A.\n\n```\nmine code" |
| + mine := "A.\n\nX.\n\n\n\n```\nmine code" |
| theirs := "A.\n\nB, theirs." |
| hunks, clean := Merge3(base, mine, theirs) |
| if clean { |
| @@ -92,16 +96,16 @@ func TestSettleFallsBackToJoinWhenTheBytesWouldNotParse(t *testing.T) { |
| if !ok { |
| t.Fatal("a chosen conflict did not settle") |
| } |
| - want := Join([]Block{{Kind: Paragraph, Source: "A."}, |
| + settled := []Block{{Kind: Paragraph, Source: "A."}, |
| + {Kind: Paragraph, Source: "X."}, |
| {Kind: Code, Source: "```\nmine code"}, |
| - {Kind: Paragraph, Source: "B, theirs."}}) |
| - if got != want { |
| - t.Fatalf("got %q, want %q", got, want) |
| + {Kind: Paragraph, Source: "B, theirs."}} |
| + if want := Join(settled); got != want { |
| + t.Fatalf("got %q, want Join's %q", got, want) |
| } |
| - placedBlocks := Parse(mine) |
| - if sameStructure(Parse(got), append(placedBlocks, |
| - Block{Kind: Paragraph, Source: "B, theirs."})) { |
| - t.Fatal("the vacuous case: the joined body parses as settled") |
| + kept := "A.\n\nX.\n\n\n\n```\nmine code\n\nB, theirs." |
| + if sameStructure(Parse(kept), settled) || kept == got { |
| + t.Fatal("the vacuous case: the kept bytes parse as settled") |
| } |
| } |