forked from ocaml/ocaml
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test calls to input_byte after close_in
Add a test demonstrating issue ocaml#11878
- Loading branch information
Showing
1 changed file
with
22 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
(* TEST *) | ||
|
||
(* The number of bytes we’ll rewind after closing; a value | ||
between 1 and IO_BUFFER_SIZE *) | ||
let nb_bytes = 3 | ||
|
||
let () = | ||
let ic = open_in_bin Sys.argv.(0) in | ||
seek_in ic nb_bytes; | ||
close_in ic; | ||
seek_in ic 0; | ||
for _ = 1 to nb_bytes do | ||
(* the bytes we get here were never initialised *) | ||
ignore (input_byte ic) | ||
done; | ||
assert ( | ||
try | ||
ignore (input_byte ic); | ||
false | ||
with | ||
| Sys_error _ -> true | ||
| _ -> false) |