fspec
Usage: fspec([options])
Takes :args :ret and (optional) :fn kwargs whose values are preds and returns a spec whose conform/explain take a fn and validates it using generative testing. The conformed value is always the fn itself.
See 'fdef' for a single operation that creates an fspec and registers it, as well as a full description of :args, :ret and :fn
fspecs can generate functions that validate the arguments and fabricate a return value compliant with the :ret spec, ignoring the :fn spec if present.
Optionally takes :gen generator-fn, which must be a fn of no args that returns a test.check generator.
Example:
const s = require('speculaas');
const {isInteger} = s.utils;
const adder = x => y => x + y;
s.fdef(adder, {
args: s.cat(':x', isInteger),
ret: s.fspec({
args: s.cat(':y', isInteger),
ret: isInteger
}),
fn: f => f.args[':x'] === f.ret(0)
});
s.test.check(adder);
// {sym: 'adder', result: true, ...}