Skip to content

Commit c025d8a

Browse files
Add tests for run_in_main_no_wait
1 parent 47daebf commit c025d8a

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/unix/test_lwt_unix.ml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,6 +1063,36 @@ let lwt_preemptive_tests = [
10631063
Lwt_preemptive.detach f () >>= fun x ->
10641064
Lwt.return (x = 42)
10651065
end;
1066+
test "run_in_main_no_wait" begin fun () ->
1067+
let p, r = Lwt.wait () in
1068+
let f () =
1069+
Lwt_preemptive.run_in_main_no_wait (fun () ->
1070+
Lwt.pause () >>= fun () ->
1071+
Lwt.pause () >>= fun () ->
1072+
Lwt.wakeup r 42;
1073+
Lwt.return ())
1074+
in
1075+
Lwt_preemptive.detach f () >>= fun () ->
1076+
p >>= fun x ->
1077+
Lwt.return (x = 42)
1078+
end;
1079+
test "run_in_main_with_dont_wait" begin fun () ->
1080+
let p, r = Lwt.wait () in
1081+
let f () =
1082+
Lwt_preemptive.run_in_main (fun () ->
1083+
Lwt.dont_wait
1084+
(fun () ->
1085+
Lwt.pause () >>= fun () ->
1086+
Lwt.pause () >>= fun () ->
1087+
Lwt.wakeup r 42;
1088+
Lwt.return ())
1089+
(function _ -> Stdlib.exit 2);
1090+
Lwt.return ())
1091+
in
1092+
Lwt_preemptive.detach f () >>= fun () ->
1093+
p >>= fun x ->
1094+
Lwt.return (x = 42)
1095+
end;
10661096
]
10671097

10681098
let getlogin_works =

0 commit comments

Comments
 (0)