diff options
author | polwex <polwex@sortug.com> | 2025-10-06 02:19:52 +0700 |
---|---|---|
committer | polwex <polwex@sortug.com> | 2025-10-06 02:19:52 +0700 |
commit | d7edee0821eeff39d8f28f064d5e7a85fca6ad94 (patch) | |
tree | 52257a59891e80ddc53b6f54895b9baec37b7a1f /ocaml/test/jam_compare.ml | |
parent | c4b71435d9afdb67450f320f54fb7aa99dcae85e (diff) |
yeahyeah
Diffstat (limited to 'ocaml/test/jam_compare.ml')
-rw-r--r-- | ocaml/test/jam_compare.ml | 36 |
1 files changed, 36 insertions, 0 deletions
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))) + ))) |