import { test } from "node:test"; import assert from "node:assert/strict"; import { existsSync, readFileSync } from "node:fs"; import { join } from "node:path"; import { toolsDir } from "./helpers.mjs"; import { parseArgs } from "../solve-spellgrid.mjs"; test("solve_spellgrid_parses_args", () => { assert.deepEqual(parseArgs([]), { level: "l1", dir: null, solver: [] }); assert.deepEqual(parseArgs(["l3", "--naive", "--max", "9", "--dir", "x", "--never-rule", "A IS B", "--all"]), { level: "l3", dir: "x", solver: ["--naive", "--max", "9", "--never-rule", "A IS B", "--all"], }); }); test("solve_spellgrid_solver_uses_only_the_harness", () => { // The solver is copied into a staged reference: it may import the harness and nothing else of the engine. const path = join(toolsDir, "solver", "solve.ts"); assert.ok(existsSync(path)); const imports = [...readFileSync(path, "utf8").matchAll(/from "([^"]+)"/g)].map((m) => m[1]); assert.deepEqual(imports.sort(), ["./src/harness", "node:fs"]); });