From d7edee0821eeff39d8f28f064d5e7a85fca6ad94 Mon Sep 17 00:00:00 2001 From: polwex Date: Mon, 6 Oct 2025 02:19:52 +0700 Subject: yeahyeah --- ocaml/README_COMPARISON.md | 58 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 ocaml/README_COMPARISON.md (limited to 'ocaml/README_COMPARISON.md') diff --git a/ocaml/README_COMPARISON.md b/ocaml/README_COMPARISON.md new file mode 100644 index 0000000..65a918d --- /dev/null +++ b/ocaml/README_COMPARISON.md @@ -0,0 +1,58 @@ +# Comparing C and OCaml Implementations + +## Quick Comparison + +To verify that the OCaml jam/cue implementation produces identical output to the C implementation: + +```bash +./compare_jam.sh +``` + +This script: +1. Builds and runs the C comparison program (`zig build jam-compare`) +2. Runs the OCaml comparison program (`dune exec test/jam_compare.exe`) +3. Compares the hex outputs byte-by-byte + +## Manual Comparison + +### C Side +```bash +cd vere +zig build jam-compare +``` + +### OCaml Side +```bash +cd ocaml +dune exec test/jam_compare.exe +``` + +Both programs output the jam encoding (in hex) for the same set of test nouns: +- Simple atoms: 0, 1, 2, 42, 255, 256 +- Simple cells: [1 2], [0 0], [42 43] +- Nested cells: [[1 2] 3], [1 [2 3]] +- Trees: [[1 2] [3 4]], [[[1 2] [3 4]] [[5 6] [7 8]]] + +## Example Output + +``` +0: 02 +1: 0c +2: 48 +42: 5015 +255: 20fe01 +256: 600002 +[1 2]: 3112 +[0 0]: 29 +[42 43]: 4155e80a +[[1 2] 3]: c54834 +[1 [2 3]]: 714834 +[[1 2] [3 4]]: c5c8d098 +[[[1 2] [3 4]] [[5 6] [7 8]]]: 15234363162e76f81004 +``` + +## Verification + +✅ The C and OCaml implementations produce **identical byte-for-byte** output for all test cases. + +This confirms that the OCaml implementation is a correct port of the C jam/cue serialization. -- cgit v1.2.3