@@ -549,6 +549,15 @@ let catch_tests = suite "catch" [
549549 state_is (Lwt.Return Exception) p
550550 end;
551551
552+ test "rejected (raise)" begin fun () ->
553+ let p =
554+ Lwt.catch
555+ (fun () -> raise Exception)
556+ (fun exn -> Lwt.return exn)
557+ in
558+ state_is (Lwt.Return Exception) p
559+ end;
560+
552561 (* This is an analog of the "bind quirk," see
553562
554563 https://github.com/ocsigen/lwt/issues/329 *)
@@ -696,7 +705,7 @@ let backtrace_catch_tests = suite "backtrace_catch" [
696705 test "rejected" begin fun () ->
697706 let p =
698707 Lwt.backtrace_catch add_loc
699- (fun () -> Lwt.fail Exception)
708+ (fun () -> raise Exception)
700709 (fun exn -> Lwt.return exn)
701710 in
702711 state_is (Lwt.Return Exception) p
@@ -789,7 +798,7 @@ let try_bind_tests = suite "try_bind" [
789798 test "rejected" begin fun () ->
790799 let p =
791800 Lwt.try_bind
792- (fun () -> Lwt.fail Exception)
801+ (fun () -> raise Exception)
793802 (fun _ -> Lwt.return Exit)
794803 (fun exn -> Lwt.return exn)
795804 in
@@ -810,7 +819,7 @@ let try_bind_tests = suite "try_bind" [
810819 test "rejected, h raises" begin fun () ->
811820 try
812821 ignore @@ Lwt.try_bind
813- (fun () -> Lwt.fail Exit)
822+ (fun () -> raise Exit)
814823 (fun _ -> Lwt.return_unit)
815824 (fun _ -> raise Exception);
816825 Lwt.return_false
@@ -961,7 +970,7 @@ let backtrace_try_bind_tests = suite "backtrace_try_bind" [
961970 test "rejected" begin fun () ->
962971 let p =
963972 Lwt.backtrace_try_bind add_loc
964- (fun () -> Lwt.fail Exception)
973+ (fun () -> raise Exception)
965974 (fun _ -> Lwt.return Exit)
966975 (fun exn -> Lwt.return exn)
967976 in
@@ -1132,7 +1141,7 @@ let finalize_tests = suite "finalize" [
11321141 test "rejected, f' raises" begin fun () ->
11331142 try
11341143 ignore @@ Lwt.finalize
1135- (fun () -> Lwt.fail Exit)
1144+ (fun () -> raise Exit)
11361145 (fun () -> raise Exception);
11371146 Lwt.return_false
11381147 with Exception ->
@@ -1169,7 +1178,7 @@ let finalize_tests = suite "finalize" [
11691178 let p =
11701179 Lwt.finalize
11711180 (fun () -> p)
1172- (fun () -> Lwt.fail Exception)
1181+ (fun () -> raise Exception)
11731182 in
11741183 Lwt.wakeup r ();
11751184 state_is (Lwt.Fail Exception) p
@@ -1232,7 +1241,7 @@ let finalize_tests = suite "finalize" [
12321241 let p =
12331242 Lwt.finalize
12341243 (fun () -> p)
1235- (fun () -> Lwt.fail Exception)
1244+ (fun () -> raise Exception)
12361245 in
12371246 Lwt.wakeup_exn r Exit;
12381247 state_is (Lwt.Fail Exception) p
@@ -1347,7 +1356,7 @@ let backtrace_finalize_tests = suite "backtrace_finalize" [
13471356 let f'_ran = ref false in
13481357 let p =
13491358 Lwt.backtrace_finalize add_loc
1350- (fun () -> Lwt.fail Exception)
1359+ (fun () -> raise Exception)
13511360 (fun () -> f'_ran := true; Lwt.return_unit)
13521361 in
13531362 Lwt.bind (state_is (Lwt.Fail Exception) p) (fun correct ->
@@ -1367,7 +1376,7 @@ let backtrace_finalize_tests = suite "backtrace_finalize" [
13671376 test "rejected, f' raises" begin fun () ->
13681377 try
13691378 ignore @@ Lwt.backtrace_finalize add_loc
1370- (fun () -> Lwt.fail Exit)
1379+ (fun () -> raise Exit)
13711380 (fun () -> raise Exception);
13721381 Lwt.return_false
13731382 with Exception ->
@@ -1404,7 +1413,7 @@ let backtrace_finalize_tests = suite "backtrace_finalize" [
14041413 let p =
14051414 Lwt.backtrace_finalize add_loc
14061415 (fun () -> p)
1407- (fun () -> Lwt.fail Exception)
1416+ (fun () -> raise Exception)
14081417 in
14091418 Lwt.wakeup r ();
14101419 state_is (Lwt.Fail Exception) p
@@ -1439,7 +1448,7 @@ let backtrace_finalize_tests = suite "backtrace_finalize" [
14391448 let p =
14401449 Lwt.backtrace_finalize add_loc
14411450 (fun () -> p)
1442- (fun () -> Lwt.fail Exception)
1451+ (fun () -> raise Exception)
14431452 in
14441453 Lwt.wakeup_exn r Exit;
14451454 state_is (Lwt.Fail Exception) p
@@ -1803,7 +1812,7 @@ let async_tests = suite "async" [
18031812 let saw = ref None in
18041813 let restore =
18051814 set_async_exception_hook (fun exn -> saw := Some exn) in
1806- Lwt.async (fun () -> Lwt.fail Exception);
1815+ Lwt.async (fun () -> raise Exception);
18071816 later (fun () ->
18081817 restore ();
18091818 !saw = Some Exception)
@@ -1852,7 +1861,7 @@ let dont_wait_tests = suite "dont_wait" [
18521861 test "rejected" begin fun () ->
18531862 let saw = ref None in
18541863 Lwt.dont_wait
1855- (fun () -> Lwt.fail Exception)
1864+ (fun () -> raise Exception)
18561865 (fun exn -> saw := Some exn);
18571866 later (fun () -> !saw = Some Exception)
18581867 end;
@@ -3371,7 +3380,7 @@ let cancel_catch_tests = suite "cancel catch" [
33713380 test "task, pending, canceled, on_cancel, forwarded" begin fun () ->
33723381 let on_cancel_2_ran = ref false in
33733382 let p, _ = Lwt.task () in
3374- let p' = Lwt.catch (fun () -> p) Lwt.fail in
3383+ let p' = Lwt.catch (fun () -> p) Lwt.reraise in
33753384 Lwt.on_cancel p' (fun () -> on_cancel_2_ran := true);
33763385 Lwt.cancel p';
33773386 Lwt.return
@@ -3895,7 +3904,7 @@ let storage_tests = suite "storage" [
38953904 Lwt.with_value key (Some 42) (fun () ->
38963905 let p' =
38973906 Lwt.with_value key (Some 1337) (fun () ->
3898- Lwt.try_bind (fun () -> p) f Lwt.fail )
3907+ Lwt.try_bind (fun () -> p) f Lwt.reraise )
38993908 in
39003909 Lwt.wakeup r ();
39013910 Lwt.return
0 commit comments