summaryrefslogtreecommitdiff
path: root/ocaml/test/check_formula.ml
diff options
context:
space:
mode:
authorpolwex <polwex@sortug.com>2025-10-07 00:35:49 +0700
committerpolwex <polwex@sortug.com>2025-10-07 00:35:49 +0700
commita9f0e90099468ac9e4e2edf22fe8987856c8b6f6 (patch)
tree3a35e818063a14b9778002d8ba98a6769c410b07 /ocaml/test/check_formula.ml
parentbe60f97a3965b70ff8e8e6d8d4326b13fa9acb56 (diff)
moar tests...
Diffstat (limited to 'ocaml/test/check_formula.ml')
-rw-r--r--ocaml/test/check_formula.ml28
1 files changed, 28 insertions, 0 deletions
diff --git a/ocaml/test/check_formula.ml b/ocaml/test/check_formula.ml
new file mode 100644
index 0000000..2935650
--- /dev/null
+++ b/ocaml/test/check_formula.ml
@@ -0,0 +1,28 @@
+(* Check what opcode is in the formula at slot 3 *)
+
+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 the formula at slot 3 *)
+ let formula = Noun.slot (Z.of_int 3) core in
+ Printf.printf "Formula (slot 3) mug: 0x%08lx\n" (Noun.mug formula);
+ Printf.printf "Formula 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 "Formula 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 "Formula starts with opcode: %d\n" (Z.to_int z)
+ | Noun.Cell _ ->
+ Printf.printf "Formula starts with CELL (distribution)\n"
+ | _ ->
+ Printf.printf "Formula head is large atom\n"
+ end
+ )