checkContract
function checkContract(r, tol?): string | null;Defined in: core/result.ts:68
Verify a result against its declared contract. Used by the test suite for every metric, including any added later.
Parameters
Section titled “Parameters”| Parameter | Type | Default value |
|---|---|---|
r | MetricResult | undefined |
tol | number | 1e-9 |
Returns
Section titled “Returns”string | null
an error message, or null if the contract holds.
Example
Section titled “Example”import { analyze, stress, checkContract } from "@saehrimnir/sickle";
// Verifies that `local` really relates to `value` the way `localKind` claims.const a = analyze(data, projection);checkContract(stress(a.moments)); // stress is a "share": its local sums to 1