summaryrefslogtreecommitdiff
path: root/ocaml/test/test_arvo_real_poke.ml
diff options
context:
space:
mode:
authorpolwex <polwex@sortug.com>2025-10-06 12:24:42 +0700
committerpolwex <polwex@sortug.com>2025-10-06 12:24:42 +0700
commitf1de939b8cc592a8d56e62ce36902740a88a7e01 (patch)
treebaf026dc2bdf9fa5bfaed12b9d271871549bc67e /ocaml/test/test_arvo_real_poke.ml
parent0ca55c93a7c21f81c8f21048889d1c9608a961c7 (diff)
ehehe
Diffstat (limited to 'ocaml/test/test_arvo_real_poke.ml')
-rw-r--r--ocaml/test/test_arvo_real_poke.ml103
1 files changed, 103 insertions, 0 deletions
diff --git a/ocaml/test/test_arvo_real_poke.ml b/ocaml/test/test_arvo_real_poke.ml
new file mode 100644
index 0000000..af707fe
--- /dev/null
+++ b/ocaml/test/test_arvo_real_poke.ml
@@ -0,0 +1,103 @@
+(* Test REAL Arvo poke - actually call into the kernel *)
+
+open Nock_lib
+
+let test_real_poke env =
+ Printf.printf "šŸš€ Testing Real Arvo Poke\n\n";
+
+ Eio.Switch.run @@ fun _sw ->
+ let fs = Eio.Stdenv.fs env in
+
+ (* Load ivory pill *)
+ Printf.printf "Loading ivory pill...\n%!";
+ let state = State.create () in
+
+ match Boot.boot_from_file ~fs state "ivory.pill" with
+ | Error msg ->
+ Printf.printf "āœ— Failed to load pill: %s\n%!" msg;
+ failwith "Pill load failed"
+
+ | Ok () ->
+ Printf.printf "āœ“ Ivory kernel loaded!\n\n";
+
+ (* Get the kernel *)
+ let kernel = state.roc in
+
+ (* Try to find the poke gate at slot 23 (traditional Arvo location) *)
+ Printf.printf "Looking for poke gate...\n";
+
+ try
+ (* Try slot 23 *)
+ let gate = Noun.slot (Z.of_int 23) kernel in
+ Printf.printf "āœ“ Found gate at slot 23\n\n";
+
+ (* Create test event: [wire card] *)
+ let event = Noun.cell
+ (Noun.atom 0) (* wire *)
+ (Noun.cell (Noun.atom 1) (Noun.atom 42)) (* card *)
+ in
+
+ Printf.printf "Calling Arvo with event [0 [1 42]]...\n";
+
+ (* Try the standard gate call formula: [9 2 [0 2] [0 3]]
+ * This means:
+ * - 9 2: call gate at axis 2 (of the subject)
+ * - [0 2]: get sample (event) at axis 2
+ * - [0 3]: get context (gate) at axis 3
+ *
+ * Subject is: [event gate]
+ *)
+ let subject = Noun.cell event gate in
+ let formula = Noun.cell
+ (Noun.atom 9)
+ (Noun.cell
+ (Noun.atom 2)
+ (Noun.cell
+ (Noun.cell (Noun.atom 0) (Noun.atom 2))
+ (Noun.cell (Noun.atom 0) (Noun.atom 3))))
+ in
+
+ Printf.printf "Running nock...\n";
+ let result = Nock.nock_on subject formula in
+ Printf.printf "āœ“ Poke succeeded!\n\n";
+
+ (* Check result structure *)
+ begin match result with
+ | Noun.Cell (effects, new_kernel) ->
+ Printf.printf "Result is a cell: [effects new_kernel]\n";
+ Printf.printf "Effects: %s\n"
+ (match effects with
+ | Noun.Atom _ -> "atom"
+ | Noun.Cell _ -> "cell");
+ Printf.printf "New kernel: %s\n"
+ (match new_kernel with
+ | Noun.Atom _ -> "atom"
+ | Noun.Cell _ -> "cell");
+ Printf.printf "\nšŸŽ‰ ARVO POKE SUCCESSFUL!\n"
+
+ | Noun.Atom _ ->
+ Printf.printf "Result is an atom (unexpected)\n"
+ end
+
+ with Noun.Exit ->
+ Printf.printf "āœ— Nock execution failed (Exit)\n";
+ Printf.printf "Slot 23 might not be the right location\n\n";
+
+ (* Try to explore the kernel structure *)
+ Printf.printf "Let me explore the kernel structure...\n";
+ for i = 2 to 30 do
+ try
+ let slot_val = Noun.slot (Z.of_int i) kernel in
+ let is_cell = match slot_val with Noun.Cell _ -> "cell" | Noun.Atom _ -> "atom" in
+ Printf.printf " Slot %d: %s\n" i is_cell
+ with _ -> ()
+ done
+
+let () =
+ Printf.printf "\n";
+ Printf.printf "═══════════════════════════════════════════════════════════\n";
+ Printf.printf " Testing REAL Arvo Poke (Actually Call Into Kernel)\n";
+ Printf.printf "═══════════════════════════════════════════════════════════\n";
+ Printf.printf "\n";
+
+ Eio_main.run test_real_poke