Skip to content

Instantly share code, notes, and snippets.

@dubzzz
Created July 2, 2020 17:25
Show Gist options
  • Save dubzzz/b3b223778aabd66d3c64390085bce46e to your computer and use it in GitHub Desktop.
Save dubzzz/b3b223778aabd66d3c64390085bce46e to your computer and use it in GitHub Desktop.
miniFc.assert = (property, { seed = Date.now() } = {}) => {
let rng = prand.xoroshiro128plus(seed);
for (let runId = 0 ; runId !== 100 ; ++runId) {
const valueUnderTest = property.generate(new Random(rng));
if (!property.run(valueUnderTest)) {
throw new Error(`Property failed after ${runId + 1} runs with value ${JSON.stringify(valueUnderTest)} (seed: ${seed})`);
}
rng = rng.jump();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment