1(* A very simple communication module using buffers. It should help detecting
2   advanced character reading by Scanf when using stdin. *)
3
4let send_flush send ob oc t =
5  send ob t;
6  Buffer.output_buffer oc ob;
7  Buffer.clear ob;
8  flush oc
9;;
10
11(* The correct sending format for the test should be "%S\n",
12   but to avoid problems when Scanf ask too early for the next character,
13   "%S\n\n" is fine. *)
14let send_string = send_flush (fun ob -> Printf.bprintf ob "%S\n");;
15
16(* The correct reading format for the test should be "%S\n",
17   but to avoid problems when Scanf ask too early for the next character,
18   " %S\n" is fine. *)
19let receive_string ib = Scanf.bscanf ib "%S\n" (fun s -> s);;
20