chore: scaffold tracks and tooling

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lucas WintherandClaude Opus 5.5 committed 2026-10-28 23:34:21 +01:00
1 parent 6dc5bdde9e
commit e150b7fefb
27 files changed
+282

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
package snake
import java.nio.file.{Files, Paths}
/** Loads shared fixtures from ../fixtures/<name>.json.
* Typed decoders (point, direction, status, action, state, opt) arrive with the model (Task 11). */
object Fixtures:
private val dir = Paths.get(sys.props.getOrElse("user.dir", ".")).resolve("..").resolve("fixtures").normalize
def load(name: String): ujson.Value =
ujson.read(Files.readString(dir.resolve(s"$name.json")))
/** The cases array of a fixture. */
def cases(name: String): Seq[ujson.Value] = load(name)("cases").arr.toSeq
/** Decode a nullable JSON value into an Option. */
def opt[A](v: ujson.Value)(f: ujson.Value => A): Option[A] =
if v.isNull then None else Some(f(v))