summaryrefslogtreecommitdiff
path: root/tests/test_runner/Utils.ml
diff options
context:
space:
mode:
authorGuillaume Boisseau2024-05-30 12:07:53 +0200
committerGitHub2024-05-30 12:07:53 +0200
commitd6367d464339764d407050bc2c104daf9d6f243c (patch)
treede2bba733416bb56162239592995f5b94a4a703d /tests/test_runner/Utils.ml
parent245699d636b320581131ed28e086cd96aa5d1cec (diff)
parent87d5a08f44b46657026a99c154bcec4a733f221d (diff)
Merge pull request #217 from AeneasVerif/document-tests
Diffstat (limited to '')
-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