// fast-check under the repository's seed and budget convention // (robot-docs/testing.md#seeds-and-budgets): ALBEDO_PROPERTY_SEED unset runs // the gate's fixed seed, "random" a fresh one, and an integer that seed; // ALBEDO_PROPERTY_CASES sets the runs per property, else the property's own // gate budget. fast-check prints the seed and the shrunk counterexample. import fc from 'fast-check'; export { fc }; const GATE_SEED = 1; function seed() { const value = process.env.ALBEDO_PROPERTY_SEED; if (value === undefined || value === '') return GATE_SEED; if (value === 'random') return Math.floor(Math.random() * 2 ** 31); const parsed = Number(value); if (!Number.isSafeInteger(parsed) || parsed <= 0) { throw new Error( `ALBEDO_PROPERTY_SEED must be unset, "random", or a positive integer, not ${value}`, ); } return parsed; } /** Run a fast-check property; gateCases is its budget when the cases are unset. */ export function check(property, gateCases = 100) { const cases = process.env.ALBEDO_PROPERTY_CASES; return fc.assert(property, { seed: seed(), numRuns: cases ? Number(cases) : gateCases, }); }