diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-08-20 19:05:13 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-08-20 19:05:13 +0200 |
| commit | 7dbd16cdf5880c0006dffacd09214ee607050b64 (patch) | |
| tree | 01e1ee37a2be97a0b06fad70de975d8007beb702 /test/test_lang.ml | |
| parent | 1aeca948c2a2a82bffaaec65077140aa05f7b3f4 (diff) | |
| parent | 1da70dc7ac03fe33fb92b172a0e26932764170d6 (diff) | |
| download | colitur-7dbd16cdf5880c0006dffacd09214ee607050b64.tar.gz colitur-7dbd16cdf5880c0006dffacd09214ee607050b64.zip | |
Merge branch 'citations-and-sigla'
Citations are parsed into structure and re-rendered, so book names,
abbreviations, punctuation style and numbering tradition become files a
user edits rather than strings frozen in the data.
New lib/citation (Book, Parse, Render, Sigla); [bible] and [sigla]
sections in language files; lang/traditions.ini for numbering; three
config keys and CLI flags. --raw emits every citation byte-for-byte as
stored, bypassing the whole pipeline, so output stays diffable against
lectio and the raw view does not depend on the parser being correct.
Diffstat (limited to 'test/test_lang.ml')
| -rw-r--r-- | test/test_lang.ml | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/test/test_lang.ml b/test/test_lang.ml index c9b7f1a..59bb9a0 100644 --- a/test/test_lang.ml +++ b/test/test_lang.ml @@ -104,6 +104,48 @@ let test_duplicate_key_within_section_last_wins () = let t = ok (L.of_string "[meta]\nlang = la\n[celebration]\na = FIRST\na = SECOND\n") in Alcotest.(check string) "later line's value wins" "SECOND" (L.celebration t "a") +(* Task 6: [bible] and [sigla] used to be two more section names [of_string] + never looked for -- a tenth (or eleventh) section a file author writes was + silently ignored, not rejected. Verified directly against a checked-out + scratch executable before this change: [Lang.keys] on a table built from + text containing a [bible] section came back with zero entries, no error + either. *) +let test_bible_section_is_read () = + let text = "[meta]\nlang = xx\n[bible]\nluke.abbr = Lc\nluke.full = Ewangelia\n" in + match L.of_string text with + | Error e -> Alcotest.failf "parse: %s" e + | Ok t -> + Alcotest.(check string) "abbr" "Lc" (L.bible t "luke.abbr"); + Alcotest.(check string) "full" "Ewangelia" (L.bible t "luke.full"); + (* the TOTAL contract: a miss returns the key *) + Alcotest.(check string) "miss" "mark.abbr" (L.bible t "mark.abbr") + +let test_sigla_section_is_read () = + let text = "[meta]\nlang = xx\n[sigla]\nbook = full\npart_sep = \"; \"\n" in + match L.of_string text with + | Error e -> Alcotest.failf "parse: %s" e + | Ok t -> + let f = L.sigla_fields t in + Alcotest.(check (option string)) "book" (Some "full") (List.assoc_opt "book" f); + (* the quotes survive Lang; Render.style_of_fields strips them *) + Alcotest.(check (option string)) "sep" (Some "\"; \"") (List.assoc_opt "part_sep" f) + +(* The deliberate asymmetry: [bible] joins [keys] (lang --check's reference + set, so a translation missing every book name is reported as incomplete); + [sigla] does not (it is five settings with working defaults, not names a + translator owes -- putting it in [keys] would make --check demand five + settings from every language file). Pinned so a later change here is a + deliberate one, not a drive-by. *) +let test_check_demands_bible_not_sigla () = + let text = "[meta]\nlang = xx\n[bible]\nluke.abbr = Lc\n[sigla]\nbook = full\n" in + match L.of_string text with + | Error e -> Alcotest.failf "parse: %s" e + | Ok t -> + let ks = L.keys t in + Alcotest.(check bool) "bible in keys" true (List.mem_assoc "bible.luke.abbr" ks); + Alcotest.(check bool) "sigla not in keys" false + (List.exists (fun (k, _) -> String.length k > 6 && String.sub k 0 6 = "sigla.") ks) + let suite = ( "Lang", [ Alcotest.test_case "meta" `Quick test_meta; @@ -117,4 +159,8 @@ let suite = Alcotest.test_case "duplicate key across sections: last wins" `Quick test_duplicate_key_across_sections_last_wins; Alcotest.test_case "duplicate key within section: last wins" `Quick - test_duplicate_key_within_section_last_wins ] ) + test_duplicate_key_within_section_last_wins; + Alcotest.test_case "bible section is read" `Quick test_bible_section_is_read; + Alcotest.test_case "sigla section is read" `Quick test_sigla_section_is_read; + Alcotest.test_case "check demands bible not sigla" `Quick + test_check_demands_bible_not_sigla ] ) |
