Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should test Ring laws', () => {
const seed = 1552808164540
laws.ring(fieldNumber, eqNumber, fc.float(), seed)
})
})
it('should test Ord laws', () => {
laws.ord(ordNumber, fc.float())
})
})
it('should test Semiring laws', () => {
const seed = 1552808164540
laws.semiring(fieldNumber, eqNumber, fc.float(), seed)
})
})
it('should test Monoid laws', () => {
laws.monoid(monoidSum, eqNumber, fc.float())
})
})
it('should test Eq laws', () => {
laws.eq(eqNumber, fc.float())
})
})
export function getArbitrary(codec: T): fc.Arbitrary> {
const type: HasArbitrary = codec as any;
switch (type._tag) {
case 'UnknownType':
return fc.anything();
case 'UndefinedType':
case 'VoidType':
return fc.constant(undefined) as any;
case 'NullType':
return fc.constant(null) as any;
case 'StringType':
return fc.string() as any;
case 'NumberType':
return fc.float() as any;
case 'BooleanType':
return fc.boolean() as any;
case 'KeyofType':
return fc.oneof(...keys(type.keys).map(fc.constant)) as any;
case 'LiteralType':
return fc.constant(type.value);
case 'ArrayType':
return fc.array(getArbitrary(type.type)) as any;
case 'DictionaryType':
return fc.dictionary(getArbitrary(type.domain), getArbitrary(type.codomain)) as any;
case 'InterfaceType':
case 'PartialType':
case 'ExactType':
return fc.record(record.map(getProps(type), getArbitrary as any) as any) as any;
case 'TupleType':
return (fc.tuple as any)(...type.types.map(getArbitrary));