UNPKG

1.37 kBTypeScriptView Raw
1import type { Arbitrary } from '../check/arbitrary/definition/Arbitrary.js';
2import type { GeneratorValue } from './_internals/builders/GeneratorValueBuilder.js';
3export type { GeneratorValue as GeneratorValue };
4/**
5 * Generate values within the test execution itself by leveraging the strength of `gen`
6 *
7 * @example
8 * ```javascript
9 * fc.assert(
10 * fc.property(fc.gen(), gen => {
11 * const size = gen(fc.nat, {max: 10});
12 * const array = [];
13 * for (let index = 0 ; index !== size ; ++index) {
14 * array.push(gen(fc.integer));
15 * }
16 * // Here is an array!
17 * // Note: Prefer fc.array(fc.integer(), {maxLength: 10}) if you want to produce such array
18 * })
19 * )
20 * ```
21 *
22 * ⚠️ WARNING:
23 * While `gen` is easy to use, it may not shrink as well as tailored arbitraries based on `filter` or `map`.
24 *
25 * ⚠️ WARNING:
26 * Additionally it cannot run back the test properly when attempting to replay based on a seed and a path.
27 * You'll need to limit yourself to the seed and drop the path from the options if you attempt to replay something
28 * implying it. More precisely, you may keep the very first part of the path but have to drop anything after the
29 * first ":".
30 *
31 * ⚠️ WARNING:
32 * It also does not support custom examples.
33 *
34 * @remarks Since 3.8.0
35 * @public
36 */
37export declare function gen(): Arbitrary<GeneratorValue>;