From 89e353b72826f7466f2f5b72e03ff063bd3e95a0 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Thu, 20 Jan 2022 00:34:33 +0100 Subject: Add a unit test in Cps.ml --- src/Cps.ml | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') 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 ])) + () -- cgit v1.2.3