aboutsummaryrefslogtreecommitdiff
path: root/test/test_emit.ml
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_emit.ml')
-rw-r--r--test/test_emit.ml37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/test_emit.ml b/test/test_emit.ml
index bd9cadc..988e68e 100644
--- a/test/test_emit.ml
+++ b/test/test_emit.ml
@@ -105,6 +105,42 @@ let test_csv_does_not_widen_for_a_third_citation () =
(List.hd lines);
Alcotest.(check int) "row still 16 fields" 16 (List.length (parse_csv_row (List.nth lines 1)))
+(* Fix 1 (cli-flags-report, 2026-08-27): a NON-"ef" rite DOES widen the CSV
+ header with a 17th column, "second", between "first" and "gospel" --
+ exactly the deliberate, disclosed change [Emit_csv.columns]'s own header
+ comment predicted the day OF was admitted to `emit` would need. Built
+ directly against a synthetic [Template.value] rather than a real
+ [View.of_days] call: [Emit_csv] only ever reads the view's own "rite"
+ string and per-day string keys, never a [Vocab.t] or a real
+ [Liturgical_day.t], so this exercises the identical gating
+ [test_csv_does_not_widen_for_a_third_citation] above proves EF never
+ takes, in isolation from the calendar/view layers (which carry no real
+ OF test fixtures in this file). *)
+let synthetic_of_day () =
+ let module T = Colitur_render.Template in
+ T.Obj
+ [ ("iso", T.Str "2026-11-29"); ("season", T.Str "advent"); ("season_name", T.Str "Tempus Adventus");
+ ("week", T.Str "1"); ("slug", T.Str "of-advent-sunday-1"); ("name", T.Str "of-advent-sunday-1");
+ ("weekday", T.Str "Dominica"); ("rank", T.Str "sollemnitas"); ("rank_name", T.Str "sollemnitas");
+ ("colour", T.Str "violet"); ("colour_name", T.Str "violaceus"); ("subject", T.Str "temporal");
+ ("first", T.Str "Isai 63:16b-17, 19b; 64:2-7"); ("second", T.Str "1 Cor 1:3-9");
+ ("gospel", T.Str "Marc 13:33-37"); ("comms", T.List []) ]
+
+let synthetic_of_view () =
+ let module T = Colitur_render.Template in
+ T.Obj [ ("rite", T.Str "of"); ("year", T.Str "2026"); ("days", T.List [ synthetic_of_day () ]) ]
+
+let test_csv_widens_for_a_non_ef_rite () =
+ let out = Csv.year (synthetic_of_view ()) in
+ let lines = String.split_on_char '\n' out |> List.filter (fun l -> l <> "") in
+ Alcotest.(check string) "header widened with second"
+ "date,rite,season,season_name,week,slug,name,weekday,rank,rank_name,colour,colour_name,subject,first,second,gospel,comms"
+ (List.hd lines);
+ let row = List.nth lines 1 in
+ Alcotest.(check int) "row has 17 fields" 17 (List.length (parse_csv_row row));
+ Alcotest.(check bool) "second reading appears in the row" true
+ (contains ~needle:"1 Cor 1:3-9" row)
+
let test_json_parses_back () =
let out = Json.year (view_2027 ()) in
Alcotest.(check bool) "starts as an object" true (out.[0] = '{');
@@ -149,6 +185,7 @@ let suite =
Alcotest.test_case "csv quotes commas" `Quick test_csv_quotes_commas;
Alcotest.test_case "csv does not widen for a third citation" `Quick
test_csv_does_not_widen_for_a_third_citation;
+ Alcotest.test_case "csv widens for a non-ef rite" `Quick test_csv_widens_for_a_non_ef_rite;
Alcotest.test_case "json parses back" `Quick test_json_parses_back;
Alcotest.test_case "json escapes" `Quick test_json_escapes;
Alcotest.test_case "json passes utf8 through" `Quick test_utf8_passes_through_json ] )