summaryrefslogtreecommitdiff
path: root/testsuite/tests/tool-ocaml/t350-heapcheck.ml
blob: 3255cf9b842a2ae54b1f9d47cb063fd17ace620b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
(* TEST
 include tool-ocaml-lib;
 flags = "-w -a";
 ocaml_script_as_argument = "true";
 setup-ocaml-build-env;
 ocaml;
*)

open Lib;;
ignore (Gc.stat ());
let x = Array.make 20 "" in
let w = weak_create 20 in
for i = 0 to 19 do
  x.(i) <- String.make 20 's';
  weak_set w i (Some x.(i));
done;
Gc.full_major ();
for i = 0 to 19 do
  match weak_get w i with
  | None -> raise Not_found
  | _ -> ()
done;
for i = 0 to 19 do
  if i mod 2 = 0 then x.(i) <- ""
done;
Gc.full_major ();
for i = 0 to 19 do
  match weak_get w i with
  | None when i mod 2 = 0 -> ()
  | Some s when i mod 2 = 1 -> if s.[5] <> 's' then raise Not_found
  | _ -> raise Not_found
done
;;