Skip to content

Commit

Permalink
Fix Lwt_react tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aantron committed Dec 15, 2019
1 parent 6a02f42 commit 835ed46
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 8 additions & 2 deletions test/react/test_lwt_event.ml
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,11 @@ let suite = suite "lwt_event" [
push 0;
push 1;

Lwt_main.run (Lwt_unix.sleep 2.5);
return (!l = [2;2;0]));
Lwt_unix.sleep 2.5 >>= fun () ->
let result = !l = [2; 2; 0] in
if not result then
List.iter (Printf.eprintf "%i ") !l;
return result);


test "of_stream"
Expand Down Expand Up @@ -90,10 +93,13 @@ let suite = suite "lwt_event" [
push 0;
push 2; (* overwrites previous 0 *)
Lwt_condition.signal cond ();
Lwt.pause () >>= fun () ->
push 3;
Lwt_condition.signal cond ();
Lwt.pause () >>= fun () ->
push 4;
Lwt_condition.signal cond ();
Lwt.pause () >>= fun () ->
return (!l = [4; 3; 2; 1]));

test "with_finaliser lifetime" begin fun () ->
Expand Down
4 changes: 4 additions & 0 deletions test/react/test_lwt_signal.ml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@ let suite = suite "lwt_signal" [
let e = React.E.map (fun x -> l := x :: !l) (React.S.changes s') in
ignore e;
Lwt_condition.signal cond ();
Lwt.pause () >>= fun () ->
push 1;
push 0;
push 2; (* overwrites previous 0 *)
Lwt_condition.signal cond ();
Lwt.pause () >>= fun () ->
push 3;
Lwt_condition.signal cond ();
Lwt.pause () >>= fun () ->
push 4;
Lwt_condition.signal cond ();
Lwt.pause () >>= fun () ->
return (!l = [4; 3; 2; 1]));

test "limit race condition" begin fun () ->
Expand Down

0 comments on commit 835ed46

Please sign in to comment.