Files
xscapes/compose_test.go
donlucasandClaude Opus 5 5fa9d7e0b9 The balloon points at the companion, not at bare sand
Measured on the rendered frame at 124 columns: the pointer sat on
column 101, the companion's box began at 107 and its nearest eye at
112 -- eleven cells of empty beach between the `v` and the animal it
is supposed to come from.

The balloon was anchored to its own corner, two columns clear of the
companion's box. The unmirrored layout it was mirrored from OVERLAPS
the companion by design, and that overlap is what makes a speech
balloon read as speech; the mirror turned an overlap into a gap. It
missed at every width, in both facings, and for both animals -- the
cat by eleven columns mirrored and four unmirrored, the crab the same.
Nothing collides: the balloon's rows are ABOVE the companion's, never
beside them.

The anchor is now the companion's own head. Cat eyes sit at cells 2
and 6 of its twelve, at 9 and 5 once mirrored; the crab's at 4 and 7,
and the crab does not flip. `catEyeCells` is shared with the face so
the two cannot drift apart. The pointer's column is READ OFF the
balloon's rows rather than computed from the text width, because
MirrorTail moves it and a second copy of that arithmetic would rot.

layout.BubbleX is gone rather than corrected: it was the wrong anchor,
not a wrong number. Every draw path goes through drawScene, so the
live loop, the reel, the GIF clips and the mockups cannot disagree.

TestTheBalloonPointsAtTheCompanion reads the RENDERED cells -- both
the pointer and the eyes are glyphs plotted over half-cell
backgrounds, and a glyph the layer holds can still lose to the
resolver. Five widths x two facings x two animals; 19 of those 20
cases fail against the old anchor.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QBSuXaQWyL96QKp2jVhayR
2026-09-09 14:47:49 -07:00

35 lines
1.6 KiB
Go

package main
import "testing"
// The companion keeps a margin from the right edge that grows with the
// width, and never loses its face to the left edge when the pane is narrower
// than the sprite. His report at 124 columns: "too pushed to the side of the
// screen. a bit".
func TestTheCompanionKeepsItsDistanceFromTheEdge(t *testing.T) {
const catW = 13
for _, tc := range []struct{ w, wantRight int }{{124, 5}, {80, 4}, {40, 3}, {30, 2}} {
lay := compose(tc.w, catW, true)
right := tc.w - (lay.CatX + catW)
if right != tc.wantRight {
t.Errorf("w=%d: the companion sits %d columns from the right edge, want %d", tc.w, right, tc.wantRight)
}
// The sand is anchored to the companion's LEFTMOST reach, not to where
// it stands: it paces inward by PaceSpan, and the sand draws last and
// would otherwise be written through the strip it walks. Updated when
// pacing shipped; before that the two were the same column. The balloon
// used to be checked here too; it is no longer a property of the layout,
// because it hangs off the companion's HEAD -- see TestTheBalloonPointsAtTheCompanion.
if lay.SandTo != lay.CatX-1-lay.PaceSpan {
t.Errorf("w=%d: the sand (to %d) is not anchored to the companion's reach: it stands at %d and paces %d inward",
tc.w, lay.SandTo, lay.CatX, lay.PaceSpan)
}
if lay.PaceSpan < 1 {
t.Errorf("w=%d: PaceSpan is %d, so the companion cannot pace at all", tc.w, lay.PaceSpan)
}
}
if lay := compose(10, catW, true); lay.CatX != 0 {
t.Errorf("narrower than the sprite: the companion should pin to the left edge, got CatX %d", lay.CatX)
}
}