From 03d414cb1847fa4bdf4b9d521d6d2c0a47766113 Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Tue, 11 Aug 2026 13:05:31 +0200 Subject: fix(record): derive headers and to_row from a single columns list Make alignment impossible: both headers and to_row are derived from a single list of (name, extractor) pairs, so reordering one without the other is impossible. CSV schema cannot silently mislabel columns. Add a meaningful test that pins the header names in order, not just length. This catches column reordering regressions. --- test/test_names.ml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'test/test_names.ml') diff --git a/test/test_names.ml b/test/test_names.ml index 3ddf79c..1649f9e 100644 --- a/test/test_names.ml +++ b/test/test_names.ml @@ -130,7 +130,13 @@ let test_record () = (* A day outside a numbered week renders week as the empty string, not "0". *) let r' = Rec.of_temporal ~rite:"ef" demo_vocab date { t with Tmp.week = None } in Alcotest.(check string) "no week" "" r'.Rec.week; - Alcotest.(check int) "row matches headers" (List.length Rec.headers) + (* Schema is pinned: headers and to_row derive from a single columns list, + so alignment cannot drift. Assert the column names in order. *) + Alcotest.(check (list string)) "headers schema" + [ "date"; "rite"; "season"; "week"; "weekday"; "slug"; "rank"; "colour"; "subject" ] + Rec.headers; + (* Row must be the same length and order as headers. *) + Alcotest.(check int) "row matches headers length" (List.length Rec.headers) (List.length (Rec.to_row r)) let suite = -- cgit v1.3