From 671c4264707ec8c81845059746632b00f2481d88 Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Thu, 20 Aug 2026 22:33:07 +0200 Subject: fix(render): a month answers to both spellings of its own name A week object carries month_name/month_num/month_abbr, because at that level a bare `name` would be ambiguous. An author who learned those names inside {{#weeks}} reaches for them one level up inside {{#months}} too -- where they resolved to nothing, and an unknown key renders as the empty string by design, so the result was a silently blank month heading rather than any error. Found by writing a template from scratch rather than copying a shipped one; every shipped template sidesteps it, which is why nothing caught it. The aliases are additive, so no existing template or golden changes. colitur-templates(5) now documents both spellings and says why they exist. --- test/test_view.ml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test/test_view.ml') diff --git a/test/test_view.ml b/test/test_view.ml index b2d302e..a542419 100644 --- a/test/test_view.ml +++ b/test/test_view.ml @@ -292,6 +292,25 @@ let test_vocabularies_localise () = Alcotest.(check string) "rite_name" "Missale Romanum, editio typica 1962" (as_str (get [ "rite_name" ] v)) +(* A month answers to BOTH spellings of its own name. The week objects nested + inside a month expose [month_name]/[month_num]/[month_abbr], so an author + who learned those names there reaches for them one level up too -- and an + unknown key renders as the EMPTY STRING by design, so the mistake produced + a silently blank heading rather than any error. Found by writing a template + from scratch; the shipped ones all sidestep it. *) +let test_month_answers_to_both_spellings () = + let v = view_named 2027 in + let jan = List.hd (as_list (get [ "months" ] v)) in + let same a b = + Alcotest.(check string) (a ^ " = " ^ b) (as_str (get [ a ] jan)) + (as_str (get [ b ] jan)) + in + same "name" "month_name"; + same "num" "month_num"; + Alcotest.(check string) "month_name" "Ianuarius" (as_str (get [ "month_name" ] jan)); + Alcotest.(check bool) "month_abbr is present and non-empty" true + (as_str (get [ "month_abbr" ] jan) <> "") + let suite = ( "View", [ Alcotest.test_case "year shape" `Quick test_year_shape; -- cgit v1.3