testUnnamedCodeCountsThroughWhatRefersToIt
What ran that no name follows counts through what refers to it, by hash: double, unnamed, is in the code of
table, which reads it; a change to it re-hashes table, and so changes that code.
import { coveredRun, SOURCE } from "#codebase/tcmts/cli/suites/test"; import assert from "node:assert/strict"; export const testUnnamedCodeCountsThroughWhatRefersToIt = () => { const { cb, def, executedBy } = coveredRun(SOURCE); const named = cb.store.pathsOf.bind(cb.store); const ran: [string, string][] = [ ["main", "main"], ["double", "double"], ]; const before = executedBy(undefined, ran)!; cb.store.pathsOf = (h: string) => (h === def("double").hash ? [] : named(h)); const out = executedBy(undefined, ran)!; assert.ok(out && !("double" in out) && "table" in out); assert.notEqual(out.table, before.table); }