diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-08-20 15:03:02 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-08-20 15:03:02 +0200 |
| commit | f8c746736fe269ef6e0c4377f58bbb6b1f2fc07a (patch) | |
| tree | 9ad5953c567831652696520536afdc02ad378fdf /test/test_citation_coverage.ml | |
| parent | 56e36188c6afc208b96b15b9a1d3d62bbbe2f705 (diff) | |
| download | colitur-f8c746736fe269ef6e0c4377f58bbb6b1f2fc07a.tar.gz colitur-f8c746736fe269ef6e0c4377f58bbb6b1f2fc07a.zip | |
test(citation): assert every emitted citation parses
Walks 1970-2070 and parses every citation the engine emits. Nothing
validated citation spellings before this, which is why seven books
carried two spellings unnoticed.
Mutation-proved: removing the 'Isa.' spelling from the book table
reddens this test naming that citation.
Diffstat (limited to 'test/test_citation_coverage.ml')
| -rw-r--r-- | test/test_citation_coverage.ml | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/test/test_citation_coverage.ml b/test/test_citation_coverage.ml new file mode 100644 index 0000000..31d49eb --- /dev/null +++ b/test/test_citation_coverage.ml @@ -0,0 +1,43 @@ +(* SPDX-License-Identifier: AGPL-3.0-or-later *) + +(* Every citation the engine can emit must parse. This is the check that + would have caught the seven duplicate book spellings -- nothing validated + them before. + + Same shape as test_lang_coverage.ml, which this file deliberately mirrors: + a miss there is a slug with no name, a miss here is a citation the parser + cannot read. *) + +module P = Colitur_citation.Parse + +let test_every_citation_parses () = + let layer = + match Test_support.load_ef_layer () with + | Ok l -> l + | Error e -> Alcotest.failf "%s" e + in + let ctx = Test_support.ef_context () in + let bad = Hashtbl.create 64 in + for y = 1970 to 2070 do + Array.iter + (fun (d : (Rite_ef.Vocab_ef.season, Rite_ef.Vocab_ef.rank) Colitur_kernel.Liturgical_day.t) -> + List.iter + (fun (c : Colitur_kernel.Citation.t) -> + let r = c.Colitur_kernel.Citation.reference in + match P.parse r with + | Ok _ -> () + | Error e -> if not (Hashtbl.mem bad r) then Hashtbl.add bad r e) + d.Colitur_kernel.Liturgical_day.citations) + (Colitur_kernel.Calendar.year ctx layer y) + done; + if Hashtbl.length bad > 0 then begin + Hashtbl.iter (fun r e -> Printf.eprintf "UNPARSED %S: %s\n" r e) bad; + Alcotest.failf "%d citation(s) did not parse" (Hashtbl.length bad) + end + +(* This project has ONE test executable. Every test_<module>.ml exposes a + [suite] value and test_colitur.ml aggregates them -- do NOT call + Alcotest.run here. Marked `Slow like test_lang_coverage's own year walk. *) +let suite = + ( "citation-coverage", + [ Alcotest.test_case "every citation parses" `Slow test_every_citation_parses ] ) |
