Fork me on GitHub

Is it possible to express the following in spec: f accepts a function g from string? to int? and it is also possible to generate random instances of g?


I wondered about this after playing with Quickcheck in Haskell, which can do this


@borkdude (s/fdef f :args (s/cat :g (s/fspec :args (s/cat :str string?) :ret int?)))


@luxbock Looks good. How about the generational aspect?


Gen of fspec is a function that uses its ret generator


How would I register (and then use) specs that were generated dynamically? I think I’m at the stage where I need to start property testing spec-provider. To do this I need to generate random data (possible), infer specs for them (that’s what the lib does) and then validate that all the random data are valid for those inferred specs.


Well you can either call s/def and register your specs or you can just call conform on the specs directly without registering, which works for a lot of stuff