diff options
author | polwex <polwex@sortug.com> | 2025-10-06 23:18:59 +0700 |
---|---|---|
committer | polwex <polwex@sortug.com> | 2025-10-06 23:18:59 +0700 |
commit | 5de3f7a3ad7b0cf63b4a6cbddfc1e26359dea161 (patch) | |
tree | b55b2258123149bed40bd89bbaa58e7da54f3a26 /ocaml/test/test_slam_directly.ml | |
parent | fdab65f6dac4ba85ed4749f61970660d1132d453 (diff) |
cleaned up tests
Diffstat (limited to 'ocaml/test/test_slam_directly.ml')
-rw-r--r-- | ocaml/test/test_slam_directly.ml | 108 |
1 files changed, 0 insertions, 108 deletions
diff --git a/ocaml/test/test_slam_directly.ml b/ocaml/test/test_slam_directly.ml deleted file mode 100644 index d7248f5..0000000 --- a/ocaml/test/test_slam_directly.ml +++ /dev/null @@ -1,108 +0,0 @@ -(* Test slamming poke gates directly *) - -open Nock_lib - -let slam_on gate event = - (* C Vere slam_on: [battery [new-sample context]] *) - let battery = Noun.head gate in - let context = Noun.tail (Noun.tail gate) in (* slot 7 *) - let new_core = Noun.cell battery (Noun.cell event context) in - - (* Kick arm 2: [9 2 0 1] *) - let kick_formula = Noun.cell (Noun.atom 9) - (Noun.cell (Noun.atom 2) - (Noun.cell (Noun.atom 0) (Noun.atom 1))) in - - Nock.nock_on new_core kick_formula - -let rec to_list acc noun = - match noun with - | Noun.Atom _ -> List.rev acc - | Noun.Cell (item, rest) -> to_list (item :: acc) rest - -let test_slam _env = - Printf.printf "Testing direct slam on poke gates...\n\n"; - - let in_channel = open_in_bin "solid.noun" in - let pill = (Marshal.from_channel in_channel : Noun.noun) in - close_in in_channel; - - match pill with - | Noun.Cell (_tag, events) -> - let event_list = to_list [] events in - - begin match List.nth_opt event_list 1 with - | Some kernel -> - (* Build test event: [now ovum] where ovum = [wire card] *) - Printf.printf "Building test event...\n"; - let wire = Noun.atom 0 in - let card = Noun.cell (Noun.atom 1953719668) (Noun.atom 42) in - let ovum = Noun.cell wire card in - let now = Noun.atom 0 in - let event = Noun.cell now ovum in - Printf.printf " Event: [0 [0 [1953719668 42]]]\n\n"; - - (* Try slot 23 *) - Printf.printf "=== Testing Slot 23 ===\n"; - begin try - let poke_gate = Noun.slot (Z.of_int 23) kernel in - Printf.printf "Slamming slot 23 gate...\n"; - - let start = Unix.gettimeofday () in - let result = slam_on poke_gate event in - let elapsed = Unix.gettimeofday () -. start in - - Printf.printf "ā Slam succeeded in %.4fs!\n\n" elapsed; - - begin match result with - | Noun.Cell (_effects, _new_kernel) -> - Printf.printf "š SLOT 23 WORKS! Result is [effects new-kernel]\n\n" - | Noun.Atom _ -> - Printf.printf "Result is atom (unexpected)\n\n" - end - - with - | Noun.Exit -> - Printf.printf "ā Slam failed (Nock Exit)\n\n" - | e -> - Printf.printf "ā Error: %s\n\n" (Printexc.to_string e) - end; - - (* Try slot 42 *) - Printf.printf "=== Testing Slot 42 ===\n"; - begin try - let poke_gate = Noun.slot (Z.of_int 42) kernel in - Printf.printf "Slamming slot 42 gate...\n"; - - let start = Unix.gettimeofday () in - let result = slam_on poke_gate event in - let elapsed = Unix.gettimeofday () -. start in - - Printf.printf "ā Slam succeeded in %.4fs!\n\n" elapsed; - - begin match result with - | Noun.Cell (_effects, _new_kernel) -> - Printf.printf "š SLOT 42 WORKS! Result is [effects new-kernel]\n\n" - | Noun.Atom _ -> - Printf.printf "Result is atom (unexpected)\n\n" - end - - with - | Noun.Exit -> - Printf.printf "ā Slam failed (Nock Exit)\n\n" - | e -> - Printf.printf "ā Error: %s\n\n" (Printexc.to_string e) - end - - | None -> - Printf.printf "No event 1\n" - end - - | Noun.Atom _ -> - Printf.printf "Pill is atom\n" - -let () = - Printf.printf "\nāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā\n"; - Printf.printf " Test Direct Slam on Poke Gates\n"; - Printf.printf "āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā\n\n"; - Eio_main.run test_slam |