summaryrefslogtreecommitdiff
path: root/tests/test_runner/Utils.ml
diff options
context:
space:
mode:
authorNadrieril2024-05-28 12:18:52 +0200
committerGuillaume Boisseau2024-05-30 11:57:40 +0200
commitec03335a473ffdf9371210e8558c691ea69d212d (patch)
tree870c691f920c1152e7b36b9d5299c6dba7860c38 /tests/test_runner/Utils.ml
parent86d0789b5a303f43c0d9bfeff83f37d89750b5d6 (diff)
runner: Split up into multiple files
Diffstat (limited to 'tests/test_runner/Utils.ml')
-rw-r--r--tests/test_runner/Utils.ml12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/test_runner/Utils.ml b/tests/test_runner/Utils.ml
new file mode 100644
index 00000000..79be617c
--- /dev/null
+++ b/tests/test_runner/Utils.ml
@@ -0,0 +1,12 @@
+(*** Convenience functions *)
+
+let map_while (f : 'a -> 'b option) (input : 'a list) : 'b list =
+ let _, result =
+ List.fold_left
+ (fun (continue, out) a ->
+ if continue then
+ match f a with None -> (false, out) | Some b -> (true, b :: out)
+ else (continue, out))
+ (true, []) input
+ in
+ List.rev result