File: in_channel_length.ml

package info (click to toggle)
js-of-ocaml 6.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 37,932 kB
  • sloc: ml: 135,957; javascript: 58,364; ansic: 437; makefile: 422; sh: 12; perl: 4
file content (20 lines) | stat: -rw-r--r-- 463 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
(* TEST *)

let len = 15000
let rounds = 10

let () =
  let oc = open_out "in_channel_length_data.txt" in
  for i = 1 to rounds do
    Printf.fprintf oc "%s\n%!" (String.make len 'x');
  done;
  close_out oc;
  let ic = open_in "in_channel_length_data.txt" in
  let l1 = in_channel_length ic in
  for i = 1 to rounds do
    let s = input_line ic in
    assert (String.length s = len);
    let l = in_channel_length ic in
    assert (l = l1)
  done;
  close_in ic