@@ -31,6 +31,20 @@ module Test = struct
3131 let str_loc (self :t ) : string =
3232 Printf. sprintf " (test :file '%s' :n %d)" self.__FILE__ self.n
3333
34+
35+ [@@@ ifge 4.08 ]
36+
37+ let get_state (r :_ QCheck.TestResult.t ) : _ QCheck.TestResult.state =
38+ QCheck.TestResult. get_state r
39+
40+ [@@@ else_]
41+
42+ (* must have qcheck < 0.17 *)
43+ let get_state (r :_ QCheck.TestResult.t ) : _ QCheck.TestResult.state =
44+ r.state
45+
46+ [@@@ endif]
47+
3448 let run ~seed (self :t ) : _ result =
3549 match
3650 match self.run with
@@ -50,7 +64,7 @@ module Test = struct
5064
5165 (* create a random state from the seed *)
5266 let rand =
53- let bits = String. to_seq seed |> Seq . map Char. code |> CCArray. of_seq in
67+ let bits = CCString. to_list seed |> List . map Char. code |> Array. of_list in
5468 Random.State. make bits
5569 in
5670
@@ -70,17 +84,17 @@ module Test = struct
7084
7185 let res = Q.Test. check_cell ~rand cell in
7286
73- begin match Q.TestResult. get_state res with
74- | QCheck2 .TestResult.Success -> Ok ()
75- | QCheck2 .TestResult.Failed { instances } ->
87+ begin match get_state res with
88+ | QCheck .TestResult.Success -> Ok ()
89+ | QCheck .TestResult.Failed { instances } ->
7690 let msg = Format. asprintf " @[<v2>failed on instances:@ %a@]"
7791 (Fmt. list ~sep: (Fmt. return " ;@ " ) pp_cex) instances
7892 in
7993 Error msg
80- | QCheck2 .TestResult.Failed_other {msg} ->
94+ | QCheck .TestResult.Failed_other {msg} ->
8195 let msg = spf " failed: %s" msg in
8296 Error msg
83- | QCheck2 .TestResult.Error {instance; exn; backtrace} ->
97+ | QCheck .TestResult.Error {instance; exn; backtrace} ->
8498 let msg = Format. asprintf " @[<v2>raised %s@ on instance %a@ :backtrace %s@]"
8599 (Printexc. to_string exn ) pp_cex instance backtrace
86100 in
@@ -166,12 +180,14 @@ let make ~__FILE__ () : (module S) =
166180 end ) in
167181 (module M )
168182
183+ let getenv_opt s = try Some (Sys. getenv s) with _ -> None
184+
169185let run_all ?seed :seed_hex ~descr (l:Test.t list list) : unit =
170186 let start = Unix. gettimeofday() in
171187
172188 (* generate or parse seed *)
173189
174- let seed_hex = match seed_hex, Sys. getenv_opt " SEED" with
190+ let seed_hex = match seed_hex, getenv_opt " SEED" with
175191 | Some s , _ -> s
176192 | None , Some s -> s
177193 | None , None ->
0 commit comments