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/README_COMPARISON.md | |
parent | c4b71435d9afdb67450f320f54fb7aa99dcae85e (diff) |
yeahyeah
Diffstat (limited to 'ocaml/README_COMPARISON.md')
-rw-r--r-- | ocaml/README_COMPARISON.md | 58 |
1 files changed, 58 insertions, 0 deletions
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. |