summaryrefslogtreecommitdiff
path: root/ocaml/test/old/inspect_boot_events.ml
diff options
context:
space:
mode:
authorpolwex <polwex@sortug.com>2025-10-06 23:18:59 +0700
committerpolwex <polwex@sortug.com>2025-10-06 23:18:59 +0700
commit5de3f7a3ad7b0cf63b4a6cbddfc1e26359dea161 (patch)
treeb55b2258123149bed40bd89bbaa58e7da54f3a26 /ocaml/test/old/inspect_boot_events.ml
parentfdab65f6dac4ba85ed4749f61970660d1132d453 (diff)
cleaned up tests
Diffstat (limited to 'ocaml/test/old/inspect_boot_events.ml')
-rw-r--r--ocaml/test/old/inspect_boot_events.ml48
1 files changed, 48 insertions, 0 deletions
diff --git a/ocaml/test/old/inspect_boot_events.ml b/ocaml/test/old/inspect_boot_events.ml
new file mode 100644
index 0000000..0a7ba92
--- /dev/null
+++ b/ocaml/test/old/inspect_boot_events.ml
@@ -0,0 +1,48 @@
+(* Inspect the structure of boot events *)
+
+open Nock_lib
+
+let rec inspect_noun prefix noun depth =
+ let indent = String.make (depth * 2) ' ' in
+ match noun with
+ | Noun.Atom a ->
+ if Z.numbits a <= 32 then
+ Printf.printf "%s%sAtom: %s (0x%s)\n" indent prefix
+ (Z.to_string a) (Z.format "x" a)
+ else
+ Printf.printf "%s%sAtom: large (%d bits)\n" indent prefix (Z.numbits a)
+ | Noun.Cell (h, t) ->
+ Printf.printf "%s%sCell:\n" indent prefix;
+ inspect_noun "head: " h (depth + 1);
+ inspect_noun "tail: " t (depth + 1)
+
+let rec to_list acc noun =
+ match noun with
+ | Noun.Atom _ -> List.rev acc
+ | Noun.Cell (item, rest) -> to_list (item :: acc) rest
+
+let inspect_events _env =
+ Printf.printf "Loading solid pill...\n";
+ let in_channel = open_in_bin "solid.noun" in
+ let pill = (Marshal.from_channel in_channel : Noun.noun) in
+ close_in in_channel;
+
+ match pill with
+ | Noun.Cell (_tag, events) ->
+ let event_list = to_list [] events in
+ Printf.printf "Found %d events\n\n" (List.length event_list);
+
+ List.iteri (fun i event ->
+ Printf.printf "═════ EVENT %d ═════\n" i;
+ inspect_noun "" event 0;
+ Printf.printf "\n"
+ ) event_list
+
+ | Noun.Atom _ ->
+ Printf.printf "✗ Pill is an atom\n"
+
+let () =
+ Printf.printf "\n═══════════════════════════════════════════\n";
+ Printf.printf " Inspect Boot Events Structure\n";
+ Printf.printf "═══════════════════════════════════════════\n\n";
+ Eio_main.run inspect_events