UNPKG

fast-check

Version:

Property based testing framework for JavaScript (like QuickCheck)

19 lines (18 loc) 1.01 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.property = property; const Arbitrary_js_1 = require("../arbitrary/definition/Arbitrary.js"); const tuple_js_1 = require("../../arbitrary/tuple.js"); const Property_generic_js_1 = require("./Property.generic.js"); const AlwaysShrinkableArbitrary_js_1 = require("../../arbitrary/_internals/AlwaysShrinkableArbitrary.js"); const globals_js_1 = require("../../utils/globals.js"); function property(...args) { if (args.length < 2) { throw new Error('property expects at least two parameters'); } const arbs = (0, globals_js_1.safeSlice)(args, 0, args.length - 1); const p = args[args.length - 1]; (0, globals_js_1.safeForEach)(arbs, Arbitrary_js_1.assertIsArbitrary); const mappedArbs = (0, globals_js_1.safeMap)(arbs, (arb) => new AlwaysShrinkableArbitrary_js_1.AlwaysShrinkableArbitrary(arb)); return new Property_generic_js_1.Property((0, tuple_js_1.tuple)(...mappedArbs), (t) => p(...t)); }