blob: 65a918d2516f9c779100bc9466efdcdc6b4ff2d6 (
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
|
# 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.
|