Function: assertIntendedWarnings()
assertIntendedWarnings(
intendedWarnings,bareWarnings):void
Assert a freshly-generated quirk artifact actually round-trips to its intended warning(s), or
fail closed. This is the generator's self-check on the intended-warning contract: a
fixture whose bare parse does not produce exactly the declared code(s) is a mislabeled fixture - a
golden file that lies about the parser verdict it anchors - and must never be emitted. It is a
stronger guard than "the transform changed some bytes": a transform can mutate the wrong element (a
template a given document type does not key its warning on) and still change bytes while producing no
warning. Every format's generate*Quirk calls this after transforming, so the contract is enforced at
generation time, not merely at round-trip time.
It no longer takes the quirk name. That parameter existed for one reason - to be interpolated into the refusal - and a parameter whose only job is to reach a message is the exact shape this package is removing, so it is gone rather than merely unused. The refusal names neither code list either; both are caller-supplied, and the caller reads the comparison back off the arguments it holds.
Parameters
intendedWarnings
readonly string[]
The declared intended code(s).
bareWarnings
readonly string[]
The code(s) a bare parse of the generated artifact actually produced.
Returns
void
Throws
SynthError SYNTH_INTENDED_WARNING_MISMATCH when the bare parse did not produce exactly
the intended code(s).
Example
import { assertIntendedWarnings } from "@cosyte/synth";
assertIntendedWarnings(["UNKNOWN_SEGMENT"], ["UNKNOWN_SEGMENT"]); // ok