Incomplete checkpoint, preserved after the implementing session hit a capacity limit partway through mutation verification. NOT reviewed and NOT gate-clean: make fmt has not been run, so fmt-check currently fails on ARCHITECTURE.md and TODO.md. Work still outstanding before this is fit for review: - run make fmt and fold the result in - finish mutation-proving each of the three behaviors - verify every message string byte-for-byte against the C sources - confirm TestSeedCompatItemTables passes with its golden untouched Refs #13.
44 lines
1.2 KiB
Go
44 lines
1.2 KiB
Go
//nolint:testpackage // white-box tests reach unexported state (approved 2026-07-07)
|
|
package game
|
|
|
|
// testTerm is a headless Terminal for tests: rendering is a no-op and
|
|
// input plays a script, then alternates space/newline so that --More--
|
|
// and [Press return] prompts never block.
|
|
type testTerm struct {
|
|
input []byte
|
|
pos int
|
|
tick int
|
|
// repaints counts forced full redraws. Rendering is a no-op here, so
|
|
// counting is the only way a headless test can tell that CTRL-R asked
|
|
// for a repaint rather than an ordinary refresh — the two are
|
|
// indistinguishable in the window contents, which is the whole reason
|
|
// the bug this replaces went unnoticed.
|
|
repaints int
|
|
}
|
|
|
|
func (t *testTerm) Render(*Window) {}
|
|
|
|
func (t *testTerm) Repaint() { t.repaints++ }
|
|
|
|
func (t *testTerm) Fini() {}
|
|
|
|
// Interrupt has nothing to wake: this terminal's ReadChar never blocks.
|
|
// The blocking case has its own fake, blockingTerm in autosave_test.go.
|
|
func (t *testTerm) Interrupt() {}
|
|
|
|
func (t *testTerm) ReadChar() (byte, bool) {
|
|
if t.pos < len(t.input) {
|
|
c := t.input[t.pos]
|
|
t.pos++
|
|
|
|
return c, true
|
|
}
|
|
|
|
t.tick++
|
|
if t.tick%2 == 0 {
|
|
return '\n', true
|
|
}
|
|
|
|
return ' ', true
|
|
}
|