aboutsummaryrefslogtreecommitdiff
path: root/lib/fixture.ml
diff options
context:
space:
mode:
authorMarc Coquand <marc@mccd.space>2023-12-26 10:08:23 -0600
committerMarc Coquand <marc@mccd.space>2023-12-26 10:08:23 -0600
commitd96e1839eb800bf26bcc38272072d98af69f5d83 (patch)
tree1570f7f47ba4e39acf4caebfce6eaf4a6575bc97 /lib/fixture.ml
parent2bb4215b957d912058d490c16ee64320e3724037 (diff)
downloadfixgen-d96e1839eb800bf26bcc38272072d98af69f5d83.tar.gz
fixgen-d96e1839eb800bf26bcc38272072d98af69f5d83.tar.bz2
fixgen-d96e1839eb800bf26bcc38272072d98af69f5d83.zip
Support const keyword
Diffstat (limited to 'lib/fixture.ml')
-rw-r--r--lib/fixture.ml5
1 files changed, 3 insertions, 2 deletions
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 *)