summaryrefslogtreecommitdiff
path: root/ocaml/test/old/test_arms.ml
blob: 0847f6f7322efd3d5a8aa3253d2a41410490216b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
(* Test Different Arms
 *
 * Try calling different arms of the Arvo kernel
 *)

open Nock_lib

let test_arm arm_num kernel =
  Printf.printf "Testing arm %d: " arm_num;

  try
    let formula = Noun.cell (Noun.atom 9)
      (Noun.cell (Noun.atom arm_num)
        (Noun.cell (Noun.atom 0) (Noun.atom 1))) in

    let _result = Nock.nock_on kernel formula in
    Printf.printf "✓ Success!\n";
    true
  with e ->
    Printf.printf "✗ %s\n" (Printexc.to_string e);
    false

let test_arms env =
  Printf.printf "🔍 Testing Different Arms of Arvo\n\n";

  Eio.Switch.run @@ fun _sw ->
  let fs = Eio.Stdenv.fs env in

  (* Load ivory pill *)
  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
  | Ok () ->
      let kernel = State.get_arvo state in

      Printf.printf "Trying arms 2 through 10...\n\n";

      for arm = 2 to 10 do
        let _ = test_arm arm kernel in
        ()
      done;

      Printf.printf "\nNow trying specific formulas:\n\n";

      (* Try the actual C Vere poke formula from u3v_poke *)
      Printf.printf "C Vere style (simplified): ";
      try
        (* Subject is [now kernel] typically *)
        let now = Noun.atom 0 in
        let poke_subject = Noun.cell now kernel in

        (* Formula to replace sample and call *)
        (* [8 kernel-with-new-sample [9 2 [0 1]]] *)
        let formula = Noun.cell (Noun.atom 8)
          (Noun.cell kernel
            (Noun.cell (Noun.atom 9)
              (Noun.cell (Noun.atom 2)
                (Noun.cell (Noun.atom 0) (Noun.atom 1))))) in

        let _result = Nock.nock_on poke_subject formula in
        Printf.printf "✓ Success!\n"
      with e ->
        Printf.printf "✗ %s\n" (Printexc.to_string e)

let () =
  Printf.printf "\n";
  Printf.printf "═══════════════════════════════════════════════════════════\n";
  Printf.printf " Testing Arms of Arvo Kernel\n";
  Printf.printf "═══════════════════════════════════════════════════════════\n";
  Printf.printf "\n";

  Eio_main.run test_arms