Revise testing of Obj.reachable_words

Part of the test makes sense only if the runtime system supports
naked pointers and has a page table to distinguish major heap pointers
from out-of-heap pointers.

This part is split off in a new test, lib-obj/reachable_words_np.ml,
conditionalized on "naked_pointers".
master
Xavier Leroy 2020-06-14 11:26:04 +02:00
parent 133102cfc7
commit ccb7829ddc
2 changed files with 21 additions and 6 deletions

View File

@ -1,11 +1,6 @@
(* TEST
*)
let native =
match Sys.backend_type with
| Sys.Native -> true
| Sys.Bytecode -> false
| Sys.Other s -> print_endline s; assert false
let size x = Obj.reachable_words (Obj.repr x)
@ -22,7 +17,6 @@ type t =
let f () =
let x = Random.int 10 in
expect_size 0 42;
expect_size (if native then 0 else 3) (1, 2);
expect_size 2 [| x |];
expect_size 3 [| x; 0 |];

View File

@ -0,0 +1,21 @@
(* TEST
* naked_pointers
** bytecode
** native
*)
let native =
match Sys.backend_type with
| Sys.Native -> true
| Sys.Bytecode -> false
| Sys.Other s -> print_endline s; assert false
let size x = Obj.reachable_words (Obj.repr x)
let expect_size s x =
let i = size x in
if i <> s then
Printf.printf "size = %i; expected = %i\n%!" i s
let () =
expect_size (if native then 0 else 3) (1, 2)