I don't think we can reproduce the following behaviors with labelled parameters:
let rec spec_to_scenario :
type fn r. rand:Random.State.t -> (fn, r) Spec.t -> fn -> (fn, r) t =
fun ~rand spec f ->
match spec with
| Arrow ({ gen; _ }, Result _) -> (
let x = Gen.generate1 ~rand gen in
try
let f = f x in
Cons (x, Res (Ok f))
with e -> Cons (x, Res (Error (Printexc.to_string e))))
| Arrow ({ gen; _ }, spec) ->
let x = Gen.generate1 ~rand gen in
let f = f x in
Cons (x, spec_to_scenario ~rand spec f)
| Result _ -> Res (Ok f)
The only solution we currently have is to write:
let f ~x ~y = x + y
let test =
let open Osnap in
let small_int =
Spec.
{
gen = QCheck.Gen.small_int;
printer = Some string_of_int;
encoding = None;
}
in
let spec = Spec.(small_int ^> small_int ^>> Result.int) in
let path = ".osnap/exponentiation" in
Test.make ~spec ~path ~count:5 ~name:"exponentiation" (fun x y -> f ~x ~y)
I don't think we can reproduce the following behaviors with labelled parameters:
The only solution we currently have is to write: