From d7edee0821eeff39d8f28f064d5e7a85fca6ad94 Mon Sep 17 00:00:00 2001 From: polwex Date: Mon, 6 Oct 2025 02:19:52 +0700 Subject: yeahyeah --- ocaml/test/jam_compare.ml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 ocaml/test/jam_compare.ml (limited to 'ocaml/test/jam_compare.ml') diff --git a/ocaml/test/jam_compare.ml b/ocaml/test/jam_compare.ml new file mode 100644 index 0000000..bdbc306 --- /dev/null +++ b/ocaml/test/jam_compare.ml @@ -0,0 +1,36 @@ +open Nock_lib.Noun +open Nock_lib.Serial + +let () = + Printf.printf "# OCaml jam outputs (hex)\n"; + + (* Simple atoms *) + Printf.printf "0: %s\n" (bytes_to_hex (jam (atom 0))); + Printf.printf "1: %s\n" (bytes_to_hex (jam (atom 1))); + Printf.printf "2: %s\n" (bytes_to_hex (jam (atom 2))); + Printf.printf "42: %s\n" (bytes_to_hex (jam (atom 42))); + Printf.printf "255: %s\n" (bytes_to_hex (jam (atom 255))); + Printf.printf "256: %s\n" (bytes_to_hex (jam (atom 256))); + + (* Simple cells *) + Printf.printf "[1 2]: %s\n" (bytes_to_hex (jam (cell (atom 1) (atom 2)))); + Printf.printf "[0 0]: %s\n" (bytes_to_hex (jam (cell (atom 0) (atom 0)))); + Printf.printf "[42 43]: %s\n" (bytes_to_hex (jam (cell (atom 42) (atom 43)))); + + (* Nested cells *) + Printf.printf "[[1 2] 3]: %s\n" + (bytes_to_hex (jam (cell (cell (atom 1) (atom 2)) (atom 3)))); + Printf.printf "[1 [2 3]]: %s\n" + (bytes_to_hex (jam (cell (atom 1) (cell (atom 2) (atom 3))))); + + (* Balanced tree *) + Printf.printf "[[1 2] [3 4]]: %s\n" + (bytes_to_hex (jam (cell (cell (atom 1) (atom 2)) (cell (atom 3) (atom 4))))); + + (* Larger tree *) + Printf.printf "[[[1 2] [3 4]] [[5 6] [7 8]]]: %s\n" + (bytes_to_hex (jam ( + cell + (cell (cell (atom 1) (atom 2)) (cell (atom 3) (atom 4))) + (cell (cell (atom 5) (atom 6)) (cell (atom 7) (atom 8))) + ))) -- cgit v1.2.3