How to use the fast-check.float function in fast-check

To help you get started, weโ€™ve selected a few fast-check examples, based on popular ways it is used in public projects.

github gcanti / fp-ts-laws / test / index.ts View on Github external
it('should test Ring laws', () => {
    const seed = 1552808164540
    laws.ring(fieldNumber, eqNumber, fc.float(), seed)
  })
})
github gcanti / fp-ts-laws / test / index.ts View on Github external
it('should test Ord laws', () => {
    laws.ord(ordNumber, fc.float())
  })
})
github gcanti / fp-ts-laws / test / index.ts View on Github external
it('should test Semiring laws', () => {
    const seed = 1552808164540
    laws.semiring(fieldNumber, eqNumber, fc.float(), seed)
  })
})
github gcanti / fp-ts-laws / test / index.ts View on Github external
it('should test Monoid laws', () => {
    laws.monoid(monoidSum, eqNumber, fc.float())
  })
})
github gcanti / fp-ts-laws / test / index.ts View on Github external
it('should test Eq laws', () => {
    laws.eq(eqNumber, fc.float())
  })
})
github giogonzo / fast-check-io-ts / src / index.ts View on Github external
export function getArbitrary<T extends HasArbitrary>(codec: T): fc.Arbitrary<t.TypeOf<T>> {
  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));