Skip to content

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.

ParameterTypeDefault value
rMetricResultundefined
tolnumber1e-9

string | null

an error message, or null if the contract holds.

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