test: sanity test for flat_map

This commit is contained in:
Simon Cruanes 2023-12-15 22:36:21 -05:00
parent 8b53966dff
commit 7436727942
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4

View file

@ -124,6 +124,21 @@ eq
fold_flat_map (fun acc x -> acc + x, [ pf "%d" x; pf "a%d" x ]) 0 [ 1; 2; 3 ]) 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
Q.(list int) Q.(list int)
(fun l -> (fun l ->