diff options
author | polwex <polwex@sortug.com> | 2025-10-06 23:18:59 +0700 |
---|---|---|
committer | polwex <polwex@sortug.com> | 2025-10-06 23:18:59 +0700 |
commit | 5de3f7a3ad7b0cf63b4a6cbddfc1e26359dea161 (patch) | |
tree | b55b2258123149bed40bd89bbaa58e7da54f3a26 /ocaml/test/inspect_event4_detail.ml | |
parent | fdab65f6dac4ba85ed4749f61970660d1132d453 (diff) |
cleaned up tests
Diffstat (limited to 'ocaml/test/inspect_event4_detail.ml')
-rw-r--r-- | ocaml/test/inspect_event4_detail.ml | 132 |
1 files changed, 0 insertions, 132 deletions
diff --git a/ocaml/test/inspect_event4_detail.ml b/ocaml/test/inspect_event4_detail.ml deleted file mode 100644 index 4f4f30a..0000000 --- a/ocaml/test/inspect_event4_detail.ml +++ /dev/null @@ -1,132 +0,0 @@ -(* Inspect Event 4 in detail *) - -open Nock_lib - -let to_atom_if_small noun = - match noun with - | Noun.Atom a -> - if Z.numbits a <= 32 then - Printf.sprintf "Atom(%s / 0x%s)" (Z.to_string a) (Z.format "x" a) - else - Printf.sprintf "Atom(large, %d bits)" (Z.numbits a) - | Noun.Cell _ -> "Cell" - -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 _env = - 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 - - (* Event 3 *) - Printf.printf "=== EVENT 3 ===\n\n"; - begin match List.nth_opt event_list 3 with - | Some (Noun.Cell (wire, card)) -> - Printf.printf "Event 3: [wire card]\n\n"; - - Printf.printf "Wire:\n"; - Printf.printf " %s\n" (to_atom_if_small wire); - - (* If wire is a cell (path), show first few elements *) - begin match wire with - | Noun.Cell (w1, rest1) -> - Printf.printf " Head: %s\n" (to_atom_if_small w1); - begin match rest1 with - | Noun.Cell (w2, rest2) -> - Printf.printf " [1]: %s\n" (to_atom_if_small w2); - begin match rest2 with - | Noun.Cell (w3, _) -> - Printf.printf " [2]: %s\n" (to_atom_if_small w3) - | Noun.Atom a -> - Printf.printf " Tail: Atom(%s)\n" (Z.to_string a) - end - | Noun.Atom a -> - Printf.printf " Tail: Atom(%s)\n" (Z.to_string a) - end - | Noun.Atom _ -> () - end; - - Printf.printf "\nCard:\n"; - begin match card with - | Noun.Cell (term, data) -> - Printf.printf " [term data]\n"; - Printf.printf " Term: %s\n" (to_atom_if_small term); - (* Try to convert term to ASCII *) - begin match term with - | Noun.Atom a when Z.numbits a <= 32 -> - let bytes = Z.to_bits a in - Printf.printf " Term ASCII: '%s'\n" bytes - | _ -> () - end; - Printf.printf " Data: %s\n" (to_atom_if_small data) - | Noun.Atom a -> - Printf.printf " Atom: %s\n" (Z.to_string a) - end - - | _ -> Printf.printf "Event 3 not found or wrong format\n" - end; - - Printf.printf "\n═══════════════════════════════════════\n\n"; - - (* Event 4 *) - Printf.printf "=== EVENT 4 ===\n\n"; - begin match List.nth_opt event_list 4 with - | Some (Noun.Cell (wire, card)) -> - Printf.printf "Event 4: [wire card]\n\n"; - - Printf.printf "Wire:\n"; - Printf.printf " %s\n" (to_atom_if_small wire); - - begin match wire with - | Noun.Cell (w1, rest1) -> - Printf.printf " Head: %s\n" (to_atom_if_small w1); - begin match rest1 with - | Noun.Cell (w2, rest2) -> - Printf.printf " [1]: %s\n" (to_atom_if_small w2); - begin match rest2 with - | Noun.Cell (w3, _) -> - Printf.printf " [2]: %s\n" (to_atom_if_small w3) - | Noun.Atom a -> - Printf.printf " Tail: Atom(%s)\n" (Z.to_string a) - end - | Noun.Atom a -> - Printf.printf " Tail: Atom(%s)\n" (Z.to_string a) - end - | Noun.Atom _ -> () - end; - - Printf.printf "\nCard:\n"; - begin match card with - | Noun.Cell (term, data) -> - Printf.printf " [term data]\n"; - Printf.printf " Term: %s\n" (to_atom_if_small term); - (* Try to convert term to ASCII *) - begin match term with - | Noun.Atom a when Z.numbits a <= 32 -> - let bytes = Z.to_bits a in - Printf.printf " Term ASCII: '%s'\n" bytes - | _ -> () - end; - Printf.printf " Data: %s\n" (to_atom_if_small data) - | Noun.Atom a -> - Printf.printf " Atom: %s\n" (Z.to_string a) - end - - | _ -> Printf.printf "Event 4 not found or wrong format\n" - end - - | Noun.Atom _ -> - Printf.printf "Pill is atom\n" - -let () = - Printf.printf "\n═══════════════════════════════════════\n"; - Printf.printf " Inspect Events 3 and 4 in Detail\n"; - Printf.printf "═══════════════════════════════════════\n\n"; - Eio_main.run inspect |