feat(course): audit fixes and twelve extensions (Modules 7b, 12, 13)

Audit pass:
- Frame rule counts frames since the last move, so every step lasts
  exactly movesEvery(score) frames, also right after a speed-up
- clampTime + MAX_GAP_MS: a hidden tab no longer replays the whole gap
- Pong Restart keeps held keys
- Fact corrections (mulberry32 output coverage, Haskell IO, uniform)
- New fixture cases from a mutation analysis

Extensions (all three tracks, shared fixtures, course text):
- Turn queue (Exercise 10.6), persisted high score (10.7),
  replay viewer (10.8), play() end-to-end helper (9.5)
- Optional State (4.7) and optional Module 7b, stack-safe IO
- Module 12, property-based testing with generators, shrinking,
  invariants and a model-based oracle
- Module 13, Conway's Life with a Click event
- JS type checking via jsconfig, JSDoc and types.d.ts
- Maintainer tools: scripts/mutate.mjs, scripts/typecheck-js.sh,
  Playwright end-to-end suite (e2e/, scripts/e2e.sh)

Docs: docs/contract.md is the canonical contract; specs and build log
under docs/superpowers.

Verified: JS 728, Scala 689, F# 691 unit tests; stubs and progression
M01-M13 and M07b; 176 end-to-end tests on Chromium and WebKit.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Lucas WintherandClaude Fable 5.2 committed 2026-11-11 12:05:29 +01:00
1 parent 876f5aabb1
commit edd57f0148
253 files changed
+21753 -503

No files matched your search

+24 -5
View File
@@ -2,12 +2,15 @@ package snake
import scala.collection.mutable.ListBuffer
/** A fake platform: records every call and lets the test fire events by hand. */
class FakePlatform(seed: Long = 42) extends Platform:
/** A fake platform: records every call and lets the test fire events by hand. `best` answers loadBest (m10). */
class FakePlatform(seed: Long = 42, best: Int = 0) extends Platform:
val calls: ListBuffer[List[Any]] = ListBuffer.empty
private var onTime: Long => Unit = _ => ()
private var onDown: String => Unit = _ => ()
private var onUp: String => Unit = _ => ()
private var onClickCb: (Int, Int) => Unit = (_, _) => ()
// Which callbacks the runtime registered, by name: "click", "down", "time", "up" (m13).
private var handlers: Set[String] = Set.empty
def fillRect(x: Int, y: Int, w: Int, h: Int, color: String): Unit = calls += List("fillRect", x, y, w, h, color)
def fillText(x: Int, y: Int, text: String, color: String, size: Int, align: String): Unit =
@@ -15,13 +18,29 @@ class FakePlatform(seed: Long = 42) extends Platform:
def randomSeed(): Long =
calls += List("randomSeed")
seed
def startClock(cb: Long => Unit): Unit = onTime = cb
def onKeyDown(cb: String => Unit): Unit = onDown = cb
def onKeyUp(cb: String => Unit): Unit = onUp = cb
def loadBest(): Int =
calls += List("loadBest")
best
def saveBest(score: Int): Unit = calls += List("saveBest", score)
def startClock(cb: Long => Unit): Unit =
onTime = cb
handlers += "time"
def onKeyDown(cb: String => Unit): Unit =
onDown = cb
handlers += "down"
def onKeyUp(cb: String => Unit): Unit =
onUp = cb
handlers += "up"
// m13: a runtime from Module 9 does not register this yet; nothing in m09-m12 fires a click.
def onClick(cb: (Int, Int) => Unit): Unit =
onClickCb = cb
handlers += "click"
def fireTime(t: Long): Unit = onTime(t)
def fireKey(key: String): Unit = onDown(key)
def fireKeyUp(key: String): Unit = onUp(key)
def fireClick(x: Int, y: Int): Unit = onClickCb(x, y)
def registered: List[String] = handlers.toList.sorted
class M09RuntimeSuite extends munit.FunSuite:
// The m09 program (classicMain) ticks every 150 ms; the shipped `main` uses speedActions after m10.