summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSon Ho2022-01-20 00:34:33 +0100
committerSon Ho2022-01-20 00:34:33 +0100
commit89e353b72826f7466f2f5b72e03ff063bd3e95a0 (patch)
tree7b2d8fb0f9a399d7c06940a5c78909b803d56be2
parent437cf6d3571f6bdaa7222ea937d019390c6217cf (diff)
Add a unit test in Cps.ml
-rw-r--r--src/Cps.ml8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/Cps.ml b/src/Cps.ml
index ef8fc8ee..040360c1 100644
--- a/src/Cps.ml
+++ b/src/Cps.ml
@@ -89,3 +89,11 @@ let fold_left_apply_continuation (f : 'a -> ('b -> 'c -> 'd) -> 'c -> 'd)
comp (f x) (fun cf v -> eval_list inputs cf (v :: outputs)) cf ctx
in
eval_list inputs cf []
+
+(** Unit test/example for [fold_left_apply_continuation] *)
+let _ =
+ fold_left_apply_continuation
+ (fun x cf () -> cf (10 + x) ())
+ [ 0; 1; 2; 3; 4 ]
+ (fun values () -> assert (values = [ 10; 11; 12; 13; 14 ]))
+ ()