diff options
author | polwex <polwex@sortug.com> | 2025-10-07 00:35:49 +0700 |
---|---|---|
committer | polwex <polwex@sortug.com> | 2025-10-07 00:35:49 +0700 |
commit | a9f0e90099468ac9e4e2edf22fe8987856c8b6f6 (patch) | |
tree | 3a35e818063a14b9778002d8ba98a6769c410b07 /ocaml/test/check_lifecycle_formula.ml | |
parent | be60f97a3965b70ff8e8e6d8d4326b13fa9acb56 (diff) |
moar tests...
Diffstat (limited to 'ocaml/test/check_lifecycle_formula.ml')
-rw-r--r-- | ocaml/test/check_lifecycle_formula.ml | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/ocaml/test/check_lifecycle_formula.ml b/ocaml/test/check_lifecycle_formula.ml new file mode 100644 index 0000000..6e4e72d --- /dev/null +++ b/ocaml/test/check_lifecycle_formula.ml @@ -0,0 +1,45 @@ +(* Check the actual lifecycle formula structure *) + +open Nock_lib + +let () = + let formula = Noun.cell + (Noun.atom 2) + (Noun.cell + (Noun.cell (Noun.atom 0) (Noun.atom 3)) + (Noun.cell (Noun.atom 0) (Noun.atom 2))) + in + + Printf.printf "Lifecycle formula: [2 [0 3] [0 2]]\n"; + Printf.printf "Formula is cell: %b\n" (Noun.is_cell formula); + + let h = Noun.head formula in + let t = Noun.tail formula in + + Printf.printf "Head (opcode): "; + (match h with + | Noun.Atom { z; _ } -> Printf.printf "atom %s\n" (Z.to_string z) + | Noun.Cell _ -> Printf.printf "cell\n"); + + Printf.printf "Tail (gal): cell\n"; + + let b_gal = Noun.head t in (* [0 3] *) + let c_gal = Noun.tail t in (* [0 2] *) + + Printf.printf "b_gal ([0 3]): "; + (match b_gal with + | Noun.Atom _ -> Printf.printf "atom\n" + | Noun.Cell { h; t; _ } -> + Printf.printf "cell ["; + (match h with Noun.Atom { z; _ } -> Printf.printf "%s " (Z.to_string z) | _ -> ()); + (match t with Noun.Atom { z; _ } -> Printf.printf "%s" (Z.to_string z) | _ -> ()); + Printf.printf "]\n"); + + Printf.printf "c_gal ([0 2]): "; + (match c_gal with + | Noun.Atom _ -> Printf.printf "atom\n" + | Noun.Cell { h; t; _ } -> + Printf.printf "cell ["; + (match h with Noun.Atom { z; _ } -> Printf.printf "%s " (Z.to_string z) | _ -> ()); + (match t with Noun.Atom { z; _ } -> Printf.printf "%s" (Z.to_string z) | _ -> ()); + Printf.printf "]\n") |