Skip to content

Commit

Permalink
Test calls to input_byte after close_in
Browse files Browse the repository at this point in the history
Add a test demonstrating issue ocaml#11878
  • Loading branch information
shym committed Jan 27, 2023
1 parent 62fd897 commit b19ebb0
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions testsuite/tests/lib-channels/close_in.ml
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)

0 comments on commit b19ebb0

Please sign in to comment.