-
Notifications
You must be signed in to change notification settings - Fork 177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
change close semantics for fixed-length sources #239
Closed
Closed
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -294,62 +294,48 @@ let suite = suite "lwt_stream" [ | |
|
||
test "is_closed" | ||
(fun () -> | ||
let st = Lwt_stream.of_list [1; 2] in | ||
let b1 = not (Lwt_stream.is_closed st) in | ||
ignore (Lwt_stream.peek st); | ||
let b2 = not (Lwt_stream.is_closed st) in | ||
ignore (Lwt_stream.junk st); | ||
ignore (Lwt_stream.peek st); | ||
let b3 = not (Lwt_stream.is_closed st) in | ||
ignore (Lwt_stream.junk st); | ||
ignore (Lwt_stream.peek st); | ||
let b4 = Lwt_stream.is_closed st in | ||
Lwt.return (b1 && b2 && b3 && b4)); | ||
let b1 = Lwt_stream.(is_closed (of_list [])) in | ||
let b2 = Lwt_stream.(is_closed (of_list [1;2;3])) in | ||
let b3 = Lwt_stream.(is_closed (of_array [||])) in | ||
let b4 = Lwt_stream.(is_closed (of_array [|1;2;3;|])) in | ||
let b5 = Lwt_stream.(is_closed (of_string "")) in | ||
let b6 = Lwt_stream.(is_closed (of_string "123")) in | ||
let b7 = Lwt_stream.(is_closed (from_direct (fun () -> Some 1))) in | ||
let b8 = Lwt_stream.(is_closed (from_direct (fun () -> None))) in | ||
return (b1 && b2 && b3 && b4 && b5 && b6 && not b7 && not b8)); | ||
|
||
test "closed" | ||
(fun () -> | ||
let st = Lwt_stream.of_list [1; 2] in | ||
let st = Lwt_stream.from_direct ( | ||
let value = ref (Some 1) in | ||
fun () -> let r = !value in value := None; r) | ||
in | ||
let b = ref false in | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this should be removed. I think |
||
let is_closed_in_notification = ref false in | ||
Lwt.async (fun () -> | ||
Lwt_stream.closed st >|= fun () -> | ||
b := true; | ||
is_closed_in_notification := Lwt_stream.is_closed st); | ||
Lwt.async (fun () -> Lwt_stream.closed st >|= fun () -> b := true); | ||
ignore (Lwt_stream.peek st); | ||
let b1 = !b = false in | ||
ignore (Lwt_stream.junk st); | ||
ignore (Lwt_stream.peek st); | ||
let b2 = !b = false in | ||
ignore (Lwt_stream.junk st); | ||
ignore (Lwt_stream.peek st); | ||
let b3 = !b = true in | ||
Lwt.return (b1 && b2 && b3 && !is_closed_in_notification)); | ||
let b2 = !b = true in | ||
let b3 = Lwt_stream.is_closed st in | ||
return (b1 && b2 && b3)); | ||
|
||
test "on_termination" | ||
(fun () -> | ||
let st = Lwt_stream.of_list [1; 2] in | ||
let st = Lwt_stream.from_direct ( | ||
let value = ref (Some 1) in | ||
fun () -> let r = !value in value := None; r) | ||
in | ||
let b = ref false in | ||
Lwt_stream.on_termination st (fun () -> b := true); | ||
ignore (Lwt_stream.peek st); | ||
let b1 = !b = false in | ||
ignore (Lwt_stream.junk st); | ||
ignore (Lwt_stream.peek st); | ||
let b2 = !b = false in | ||
ignore (Lwt_stream.junk st); | ||
ignore (Lwt_stream.peek st); | ||
let b3 = !b = true in | ||
let b2 = !b = true in | ||
let b3 = Lwt_stream.is_closed st in | ||
Lwt.return (b1 && b2 && b3)); | ||
|
||
test "on_termination when closed" | ||
(fun () -> | ||
let st = Lwt_stream.of_list [] in | ||
let b = ref false in | ||
let b1 = not (Lwt_stream.is_closed st) in | ||
ignore (Lwt_stream.junk st); | ||
let b2 = Lwt_stream.is_closed st in | ||
Lwt_stream.on_termination st (fun () -> b := true); | ||
Lwt.return (b1 && b2 && !b)); | ||
|
||
test "choose_exhausted" | ||
(fun () -> | ||
Lwt_stream.(to_list (choose [of_list []])) >|= fun _ -> true); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing this no longer tests, is that streams for which
is_closed
isfalse
can be turned into streams for which it istrue
, by reading them.