How to use the fast-check.array 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.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github devexperts / swagger-codegen-ts / src / language / typescript / common / data / __tests__ / serialized-type.spec.ts View on Github external
import { serializedDependency } from '../serialized-dependency';
import { $refArbitrary } from '../../../../../utils/__tests__/ref.spec';
import { getRelativePath } from '../../../../../utils/ref';
import { pipe } from 'fp-ts/lib/pipeable';
import { arbitrary, nonEmptyArray } from '../../../../../utils/fast-check';
import { none, some } from 'fp-ts/lib/Option';
import { getIOName, getTypeName, UNSAFE_PROPERTY_PATTERN } from '../../utils';
import { when } from '../../../../../utils/string';
import { head } from 'fp-ts/lib/NonEmptyArray';

const serializedDependencyArbitrary = tuple(string(), string()).map(([name, path]) => serializedDependency(name, path));

export const serializedTypeArbitrary = tuple(
	string(),
	string(),
	array(serializedDependencyArbitrary),
	pipe(array($refArbitrary)),
).map(([type, io, dependencies, refs]) => serializedType(type, io, dependencies, refs));

const name = oneof(string(), constant(undefined));

describe('SerializedType', () => {
	it('getSerializedArrayType', () => {
		assert(
			property(serializedTypeArbitrary, name, (s, name) => {
				expect(pipe(s, getSerializedArrayType(name))).toEqual(
					serializedType(
						`Array<${s.type}>`,
						`array(${s.io}${when(name !== undefined, `, '${name}'`)})`,
						[...s.dependencies, serializedDependency('array', 'io-ts')],
						s.refs,
					),
github CJex / regulex / test / KitSpec.ts View on Github external
const listOfCharRange = (max = 40) => C.array(charRangeGen(), 1, max);
github gcanti / fp-ts / test / property-test / NonEmptyArray2v.ts View on Github external
export function nonEmptyArray<a>(arb: fc.Arbitrary</a><a>): fc.Arbitrary&gt; {
  return fc.array(arb, 1, 100) as any
}
</a>
github bitauth / bitcoin-ts / src / lib / utils / hex.spec.ts View on Github external
const fcUint8Array = (minLength: number, maxLength: number) =>
  fc
    .array(fc.integer(0, maxUint8Number), minLength, maxLength)
    .map(a => Uint8Array.from(a));
github bitauth / bitcoin-ts / src / lib / crypto / secp256k1.spec.ts View on Github external
const fcUint8Array = (minLength: number, maxLength: number) =>
  fc
    .array(fc.integer(0, 255), minLength, maxLength)
    .map(a => Uint8Array.from(a));
const fcUint8Array32 = () => fcUint8Array(32, 32);
github bitauth / bitcoin-ts / src / lib / utils / utf8.spec.ts View on Github external
const fcUint8Array = (minLength: number, maxLength: number) =>
  fc
    .array(fc.integer(0, maxUint8Number), minLength, maxLength)
    .map(a => Uint8Array.from(a));