From 7436727942ad86c6a23da446597065b3d9a82c17 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Fri, 15 Dec 2023 22:36:21 -0500 Subject: [PATCH] test: sanity test for flat_map --- tests/core/t_list.ml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/core/t_list.ml b/tests/core/t_list.ml index bea8fc3d..8cee6945 100644 --- a/tests/core/t_list.ml +++ b/tests/core/t_list.ml @@ -124,6 +124,21 @@ eq fold_flat_map (fun acc x -> acc + x, [ pf "%d" x; pf "a%d" x ]) 0 [ 1; 2; 3 ]) ;; +t @@ fun () -> +let r = Atomic.make 0 in +let f x = + let n = Atomic.fetch_and_add r 1 in + [ n, x ] +in + +let l = CCList.flat_map f [ "a"; "b"; "c" ] in +assert_equal + ~printer:Q.Print.(list @@ pair int string) + [ 0, "a"; 1, "b"; 2, "c" ] + l; +true +;; + q Q.(list int) (fun l ->