From d96e1839eb800bf26bcc38272072d98af69f5d83 Mon Sep 17 00:00:00 2001 From: Marc Coquand Date: Tue, 26 Dec 2023 10:08:23 -0600 Subject: Support const keyword --- lib/fixture.ml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/fixture.ml') diff --git a/lib/fixture.ml b/lib/fixture.ml index 25f6a8f..2b17a02 100644 --- a/lib/fixture.ml +++ b/lib/fixture.ml @@ -22,12 +22,12 @@ let names = let random_name () = List.nth names (Random.int (List.length names)) let%test "random_name" = List.mem (random_name ()) names -(* TODO: Support names *) type t = | Name of string | Uuidv4 of string | Foreign of (string * string list) | Int of string * int * int + | Const of string * string (* (Name, foreign ids to pick from) *) let add_name name fixtures = Name name :: fixtures @@ -46,6 +46,7 @@ let generate_fixture fixture = | Name _ -> random_name () | Uuidv4 _ -> Uuidm.v `V4 |> Uuidm.to_string | Foreign (_, reference) -> random_value_in_list reference + | Const (_, value) -> value | Int (_, min, max) -> Random.int (max - min) + min |> string_of_int @@ -58,10 +59,10 @@ let id_of_fixture fixture = | Name id -> id | Uuidv4 id -> id | Foreign (id, _) -> id + | Const (id, _) -> id | Int (id, _, _) -> id -(* TODO: Support const *) (* TODO: Support email *) (* TODO: Support list *) -- cgit v1.2.3