testComputedConstantChangingStateCountsWhenTheStateDoes

tcmts.cli.suites.test.testComputedConstantChangingStateCountsWhenTheStateDoes · #go5qp2r7 · term

What computing a constant could change is part of what ran when what ran refers to it: registered pushes to registry, which main reads, so it counts though nothing refers to it (as unused doesn't); configured changes options, and counts only when what ran reads that.

import { quietLoad } from "#codebase/tcmts/cli/suites";
import { coveredRun, SOURCE } from "#codebase/tcmts/cli/suites/test";
import assert from "node:assert/strict";

export const testComputedConstantChangingStateCountsWhenTheStateDoes = () => {
  const { cb, def, run } = coveredRun(SOURCE);
  assert.deepEqual(quietLoad(cb, def("registered")), [def("registry").hash]);
  const ran = run(["main", "main"], ["double", "double"], ["register", "register"]);
  assert.ok(ran.includes("registry"));
  assert.ok(ran.includes("registered"));
  assert.ok(!ran.includes("unused"));
  assert.deepEqual(quietLoad(cb, def("configured")), [def("options").hash]);
  assert.ok(!ran.includes("configured"));
  assert.ok(run(["main", "main"], ["option", "option"]).includes("configured"));
}

uses