ocaml-containers/fuzz/ccsexp_csexp_reparse.ml
2021-02-02 22:48:08 -05:00

19 lines
531 B
OCaml

let gen_sexp =
let open! Crowbar in
let (>|=) = map in
fix
(fun self ->
choose [
((bytes :: [] : _ gens) >|= fun s -> `Atom s);
((list self :: []) >|= fun l -> `List l);
])
let () =
Crowbar.add_test ~name:"ccsexp_csexp_reparse" [ gen_sexp ]
(fun s ->
let str = CCSexp.Canonical.to_string s in
match CCSexp.Canonical.parse_string_list str with
| Ok [s2] -> assert (s = s2)
| Ok _ -> failwith "wrong number of sexps"
| Error e -> failwith e)