Initial commit
This commit is contained in:
commit
b3a51a4115
10336 changed files with 2381973 additions and 0 deletions
19
node_modules/fast-check/lib/esm/arbitrary/option.js
generated
vendored
Normal file
19
node_modules/fast-check/lib/esm/arbitrary/option.js
generated
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import { constant } from './constant.js';
|
||||
import { FrequencyArbitrary } from './_internals/FrequencyArbitrary.js';
|
||||
import { safeHasOwnProperty } from '../utils/globals.js';
|
||||
export function option(arb, constraints = {}) {
|
||||
const freq = constraints.freq == null ? 5 : constraints.freq;
|
||||
const nilValue = safeHasOwnProperty(constraints, 'nil') ? constraints.nil : null;
|
||||
const nilArb = constant(nilValue);
|
||||
const weightedArbs = [
|
||||
{ arbitrary: nilArb, weight: 1, fallbackValue: { default: nilValue } },
|
||||
{ arbitrary: arb, weight: freq },
|
||||
];
|
||||
const frequencyConstraints = {
|
||||
withCrossShrink: true,
|
||||
depthSize: constraints.depthSize,
|
||||
maxDepth: constraints.maxDepth,
|
||||
depthIdentifier: constraints.depthIdentifier,
|
||||
};
|
||||
return FrequencyArbitrary.from(weightedArbs, frequencyConstraints, 'fc.option');
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue