From 9df429005da88685f1de5e6d7786837875d8d398 Mon Sep 17 00:00:00 2001
From: Jan Midtgaard <mail@janmidtgaard.dk>
Date: Wed, 9 Jul 2025 12:25:39 +0200
Subject: [PATCH] Patch CBor roundtrip property to hold for nan's too

---
 tests/core/t_cbor.ml | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/tests/core/t_cbor.ml b/tests/core/t_cbor.ml
index 17527159b..bf45f6c34 100644
--- a/tests/core/t_cbor.ml
+++ b/tests/core/t_cbor.ml
@@ -101,10 +101,25 @@ let rec shrink (c : Cbor.t) : Cbor.t Q.Iter.t =
 
 let arb = Q.make ~shrink ~print:Cbor.to_string_diagnostic gen_c;;
 
+let rec eq_c c c' = match c,c' with
+  | `Null, `Null
+  | `Undefined, `Undefined -> true
+  | `Simple i, `Simple i' -> Int.equal i i'
+  | `Bool b, `Bool b' -> Bool.equal b b'
+  | `Int i, `Int i' -> Int64.equal i i'
+  | `Float f, `Float f' -> Float.equal f f'
+  | `Bytes s, `Bytes s' -> String.equal s s'
+  | `Text t, `Text t' -> String.equal t t'
+  | `Array a, `Array a' -> List.equal eq_c a a'
+  | `Map m, `Map m' ->
+    List.equal (fun (t0,t1) (t0',t1') -> eq_c t0 t0' && eq_c t1 t1') m m'
+  | `Tag (i,t), `Tag (i',t') -> Int.equal i i' && eq_c t t'
+  | _ -> false;;
+
 q ~count:1_000 ~long_factor:10 arb @@ fun c ->
 let s = Cbor.encode c in
 let c' = Cbor.decode_exn s in
-if not (c = c') then
+if not (eq_c c c') then
   Q.Test.fail_reportf "@[<hv2>roundtrip failed:@ from %a@ to %a@]"
     Cbor.pp_diagnostic c Cbor.pp_diagnostic c';
 true
