diff options
Diffstat (limited to 'ocaml/test/old/test_arvo_real_poke.ml')
-rw-r--r-- | ocaml/test/old/test_arvo_real_poke.ml | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/ocaml/test/old/test_arvo_real_poke.ml b/ocaml/test/old/test_arvo_real_poke.ml new file mode 100644 index 0000000..af707fe --- /dev/null +++ b/ocaml/test/old/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 |