From a9f0e90099468ac9e4e2edf22fe8987856c8b6f6 Mon Sep 17 00:00:00 2001 From: polwex Date: Tue, 7 Oct 2025 00:35:49 +0700 Subject: moar tests... --- ocaml/test/examine_core_head.ml | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 ocaml/test/examine_core_head.ml (limited to 'ocaml/test/examine_core_head.ml') diff --git a/ocaml/test/examine_core_head.ml b/ocaml/test/examine_core_head.ml new file mode 100644 index 0000000..397bfbe --- /dev/null +++ b/ocaml/test/examine_core_head.ml @@ -0,0 +1,38 @@ +(* Examine the actual structure of the Arvo core *) + +open Nock_lib + +let rec show_structure depth max_depth noun = + if depth >= max_depth then "..." else + match noun with + | Noun.Atom { z; _ } -> + if Z.fits_int z then string_of_int (Z.to_int z) + else Z.to_string z + | Noun.Cell { h; t; _ } -> + "[" ^ show_structure (depth+1) max_depth h ^ " " ^ + show_structure (depth+1) max_depth t ^ "]" + +let () = + Eio_main.run (fun env -> + let fs = Eio.Stdenv.fs env in + let pill_bytes = Eio.Path.(load (fs / "ivory.pill")) |> Bytes.of_string in + let pill = Serial.cue pill_bytes in + let core = Noun.tail pill in + + Printf.printf "Core structure (head, depth 3):\n"; + let core_head = Noun.head core in + Printf.printf "%s\n" (show_structure 0 3 core_head); + + Printf.printf "\nCore head mug: 0x%08lx\n" (Noun.mug core_head); + + (* Check if it's [7 ...] *) + match core_head with + | Noun.Cell { h; _ } -> + (match h with + | Noun.Atom { z; _ } when Z.fits_int z -> + Printf.printf "Core head starts with atom: %d\n" (Z.to_int z) + | Noun.Cell _ -> + Printf.printf "Core head starts with cell\n" + | _ -> ()) + | _ -> () + ) -- cgit v1.2.3