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/check_slot2_opcode.ml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 ocaml/test/check_slot2_opcode.ml (limited to 'ocaml/test/check_slot2_opcode.ml') diff --git a/ocaml/test/check_slot2_opcode.ml b/ocaml/test/check_slot2_opcode.ml new file mode 100644 index 0000000..faca7e0 --- /dev/null +++ b/ocaml/test/check_slot2_opcode.ml @@ -0,0 +1,28 @@ +(* Check what opcode is in slot 2 (the formula after opcode 2) *) + +open Nock_lib + +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 + + (* Get slot 2 (this becomes the formula after opcode 2) *) + let formula = Noun.slot (Z.of_int 2) core in + Printf.printf "Slot 2 (becomes formula) mug: 0x%08lx\n" (Noun.mug formula); + Printf.printf "Slot 2 is: %s\n" (if Noun.is_cell formula then "cell" else "atom"); + + if Noun.is_cell formula then begin + let h = Noun.head formula in + Printf.printf "Slot 2 head is: %s\n" (if Noun.is_cell h then "cell" else "atom"); + match h with + | Noun.Atom { z; _ } when Z.fits_int z -> + Printf.printf "Slot 2 starts with opcode: %d\n" (Z.to_int z) + | Noun.Cell _ -> + Printf.printf "Slot 2 starts with CELL (distribution)\n" + | _ -> + Printf.printf "Slot 2 head is large atom\n" + end + ) -- cgit v1.2.3