summaryrefslogtreecommitdiff
path: root/ocaml/test/examine_core_head.ml
diff options
context:
space:
mode:
Diffstat (limited to 'ocaml/test/examine_core_head.ml')
-rw-r--r--ocaml/test/examine_core_head.ml38
1 files changed, 38 insertions, 0 deletions
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"
+ | _ -> ())
+ | _ -> ()
+ )