summaryrefslogtreecommitdiff
path: root/ocaml/test/test_functional_bios.ml
diff options
context:
space:
mode:
authorpolwex <polwex@sortug.com>2025-10-06 14:35:41 +0700
committerpolwex <polwex@sortug.com>2025-10-06 14:35:41 +0700
commit256376afffe66faa239a6a6aaebb8f68a9c6cbe4 (patch)
tree52f2ea2ba9da38e7edf64bb810708526cdeb14f5 /ocaml/test/test_functional_bios.ml
parent4a6067863d415e0334b4b61254fab2bd879a6964 (diff)
very stuck
Diffstat (limited to 'ocaml/test/test_functional_bios.ml')
-rw-r--r--ocaml/test/test_functional_bios.ml132
1 files changed, 132 insertions, 0 deletions
diff --git a/ocaml/test/test_functional_bios.ml b/ocaml/test/test_functional_bios.ml
new file mode 100644
index 0000000..5679c3f
--- /dev/null
+++ b/ocaml/test/test_functional_bios.ml
@@ -0,0 +1,132 @@
+(* Test the functional BIOS formula [2 [0 3] [0 2]] on event list *)
+
+open Nock_lib
+
+let test_bios _env =
+ Printf.printf "šŸš€ Testing Functional BIOS Formula\n\n";
+
+ (* Load solid pill *)
+ Printf.printf "Loading solid pill...\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) ->
+ Printf.printf "Found events\n\n";
+
+ (* Build the functional BIOS formula: [2 [0 3] [0 2]] *)
+ Printf.printf "Building functional BIOS formula: [2 [0 3] [0 2]]\n";
+ let bios_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 "Formula: %s\n\n"
+ (match bios_formula with Noun.Cell _ -> "built" | _ -> "error");
+
+ (* Run the formula on the event list! *)
+ Printf.printf "Running formula on entire event list...\n";
+ Printf.printf "(This processes ALL 5 events at once!)\n\n";
+
+ let start = Unix.gettimeofday () in
+
+ begin try
+ let result = Nock.nock_on events bios_formula in
+ let elapsed = Unix.gettimeofday () -. start in
+
+ Printf.printf "āœ“ Formula succeeded in %.4fs!\n\n" elapsed;
+
+ (* Extract slot 7 from result *)
+ Printf.printf "Extracting slot 7 from result...\n";
+ begin try
+ let kernel = Noun.slot (Z.of_int 7) result in
+ Printf.printf "āœ“ Got kernel at slot 7!\n\n";
+
+ (* Check what slots this kernel has *)
+ Printf.printf "Checking kernel slots:\n";
+
+ begin try
+ let _poke23 = Noun.slot (Z.of_int 23) kernel in
+ Printf.printf " āœ“ Has slot 23 (larval poke)\n"
+ with _ ->
+ Printf.printf " āœ— No slot 23\n"
+ end;
+
+ begin try
+ let _poke42 = Noun.slot (Z.of_int 42) kernel in
+ Printf.printf " āœ“ Has slot 42 (adult poke)\n"
+ with _ ->
+ Printf.printf " āœ— No slot 42\n"
+ end;
+
+ Printf.printf "\nšŸŽ‰ FUNCTIONAL BIOS BOOT COMPLETE!\n\n";
+
+ (* Try a test poke on slot 42 *)
+ Printf.printf "Testing poke on slot 42...\n";
+
+ begin try
+ let poke_gate = Noun.slot (Z.of_int 42) kernel in
+
+ (* Build test event *)
+ 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 poke_arg = Noun.cell now ovum in
+
+ (* Slam *)
+ let battery = Noun.head poke_gate in
+ let context = Noun.tail (Noun.tail poke_gate) in
+ let new_core = Noun.cell battery (Noun.cell poke_arg context) in
+ let kick_formula = Noun.cell (Noun.atom 9)
+ (Noun.cell (Noun.atom 2)
+ (Noun.cell (Noun.atom 0) (Noun.atom 1))) in
+
+ let poke_result = Nock.nock_on new_core kick_formula in
+
+ begin match poke_result with
+ | Noun.Cell (_effects, _new_kernel) ->
+ Printf.printf " šŸŽŠ SLOT 42 POKE WORKS!\n\n";
+ Printf.printf "═══════════════════════════════════════════\n";
+ Printf.printf " ARVO IS FULLY BOOTED AND OPERATIONAL!\n";
+ Printf.printf "═══════════════════════════════════════════\n\n";
+ Printf.printf "This means we can now:\n";
+ Printf.printf " āœ… Run the functional BIOS formula\n";
+ Printf.printf " āœ… Extract the booted kernel\n";
+ Printf.printf " āœ… Poke events into Arvo\n";
+ Printf.printf " āœ… Build a complete Urbit runtime!\n"
+ | Noun.Atom _ ->
+ Printf.printf " Result is atom\n"
+ end
+
+ with
+ | Noun.Exit ->
+ Printf.printf " āœ— Poke failed (Nock Exit)\n"
+ | e ->
+ Printf.printf " āœ— Error: %s\n" (Printexc.to_string e)
+ end
+
+ with
+ | Not_found ->
+ Printf.printf "āœ— No slot 7 in result\n"
+ | e ->
+ Printf.printf "āœ— Error accessing slot 7: %s\n" (Printexc.to_string e)
+ end
+
+ with
+ | Noun.Exit ->
+ Printf.printf "āœ— Formula failed (Nock Exit)\n"
+ | e ->
+ Printf.printf "āœ— Error: %s\n" (Printexc.to_string e)
+ end
+
+ | Noun.Atom _ ->
+ Printf.printf "āœ— Pill is atom\n"
+
+let () =
+ Printf.printf "\n═══════════════════════════════════════════\n";
+ Printf.printf " Test Functional BIOS Formula\n";
+ Printf.printf "═══════════════════════════════════════════\n\n";
+ Eio_main.run test_bios