aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-08-20 22:33:07 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-08-20 22:33:07 +0200
commit671c4264707ec8c81845059746632b00f2481d88 (patch)
tree790100dcc0077532d9446478e51d4cd40209c1c6 /test
parent1988d350242b47aa52aa07904c495e7e2c0eba82 (diff)
downloadcolitur-671c4264707ec8c81845059746632b00f2481d88.tar.gz
colitur-671c4264707ec8c81845059746632b00f2481d88.zip
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.
Diffstat (limited to 'test')
-rw-r--r--test/test_view.ml19
1 files changed, 19 insertions, 0 deletions
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;