Skip to content

Commit

Permalink
Lwt_sequence: add test for fold_r with multiple removal function (ocs…
Browse files Browse the repository at this point in the history
  • Loading branch information
cedlemo committed Jan 11, 2018
1 parent 87829d0 commit 3a8d210
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/core/test_lwt_sequence.ml
Original file line number Diff line number Diff line change
Expand Up @@ -389,4 +389,21 @@ let suite = suite "lwt_sequence" [
let data = [|-3; -2; -1; 10; 2; 3|] in
test_iter Lwt_sequence.iter_l data s
end;

test "fold_r with multiple removal" begin fun () ->
let s = filled_sequence () in
let acc = Lwt_sequence.fold_r
(fun v e ->
(if v = (-1) then
let n = Lwt_sequence.find_node_r (fun v' -> v' = 1) s in
let _ = Lwt_sequence.remove n in
let n = Lwt_sequence.find_node_r (fun v' -> v' = (-2)) s in
let _ = Lwt_sequence.remove n in
let n = Lwt_sequence.find_node_r (fun v' -> v' = (-1)) s in
ignore(Lwt_sequence.remove n)
);
v * e
) s 1 in
Lwt.return (acc = 18)
end;
]

0 comments on commit 3a8d210

Please sign in to comment.