game/rings.go had no test coverage at all: not one of the suite's tests touched wearing a ring, taking one off, choosing a hand, or the ring contribution to the hunger clock. New game/rings_test.go covers ringOn, pickRingHand, ringOff, gethand, ringEat and ringNum, plus the ring arm of things.c dropcheck (dropRing), which is what actually removes a worn ring. 17 tests, 44 subtests; package coverage 53.7% -> 56.2%. No game code changes. Every expected value is transcribed from the C reference on origin/c-master (rings.c, rogue.h, things.c) and quoted in the file, rather than from what the port currently returns. No divergence from C was found. ringEat is the reason this matters most: it feeds daemons.c's hunger clock, so a wrong entry is a slow, silent drift in when the hero starves. All fourteen ring kinds are pinned to C's uses[] table, both hands. The three C subtleties are handled explicitly: a negative uses[] entry is a one-in-n chance of a single unit and not a literal cost; R_DIGEST then flips the sign, so slow digestion returns 0 or -1; and ring_num's switch closes with the otherwise macro (rogue.h 53: break;default), so its four labels fall through to one sprintf and every other kind returns "" from a default arm. The chance rings are checked by snapshotting the generator, calling ringEat, and replaying C's own expression from the identical state, which pins the one-in-n denominator, the sign flip and the fact that exactly one rnd call is spent; a frequency check over 4000 trials backs it. The non-negative entries assert the opposite, that the generator is untouched, because C never reaches rnd on that path and a stray call there would desynchronise the game's RNG stream from C's. Scripted hand answers carry an abort tail (a space for the reprompt's --More--, then ESCAPE) so that a port which stopped accepting a key fails on its assertion instead of looping forever on the headless terminal's filler input. The "only one hand free" cases script the wrong hand key on purpose: a port that prompted anyway would consume it and land the ring on the wrong side. Mutation-proved with 23 mutations, each reverted, each failing its own test and only its own. All fourteen kinds are exercised; the eleven with no wear-time effect in C are documented at the foot of the file as deliberately not given a wear/remove test, and ring_off's unreachable "not wearing such a ring" arm is documented as unreachable.
21 KiB
21 KiB