UNPKG

@unsplash/sum-types-fast-check

Version:
10 lines (9 loc) 325 B
import fc from "fast-check"; export const nullaryArb = fc.constant(null); export const getArb = (sum) => (arbs) => { const tags = Object.keys(arbs); const tagArb = fc.constantFrom(...tags); return (tagArb .chain(tag => arbs[tag].map(val => [tag, val])) .map(([tag, val]) => sum.mk[tag](val))); };