summaryrefslogtreecommitdiff
path: root/test/test_citation.ml
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-08-20 15:44:29 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-08-20 15:44:29 +0200
commit987175105ead0ea78b960c0e638a81c6fd2384cf (patch)
tree15411786075824f2f7c4154fc23493d225963080 /test/test_citation.ml
parentec70286daa72fd2a2a78a1cbab0fe2c268e5c743 (diff)
downloadcolitur-987175105ead0ea78b960c0e638a81c6fd2384cf.tar.gz
colitur-987175105ead0ea78b960c0e638a81c6fd2384cf.zip
feat(citation): the Sigla facade, total by construction
format never raises and returns an unparseable citation unchanged, so a gap degrades to today's behaviour rather than to a crash. The coverage test asserts separately that no shipped citation takes that path. verbatim is what --raw uses: an identity name table would still reformat punctuation and renumber, which would break byte-exact diffing against lectio. The existing citation-coverage walk (1970-2070) now also drives a round-trip check in the same pass: parse -> render -> parse must reach the same structure, using Book.default_spelling for names (Book.to_string returns the internal id, which is not a registered token and cannot be read back). Proved with a mutation: changing the default style's part_sep to a separator the parser does not accept reddened the round-trip case on 31 multi-part citations and nothing else; reverted.
Diffstat (limited to 'test/test_citation.ml')
-rw-r--r--test/test_citation.ml21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/test_citation.ml b/test/test_citation.ml
index 9405d39..25fc260 100644
--- a/test/test_citation.ml
+++ b/test/test_citation.ml
@@ -359,3 +359,24 @@ let render_suite =
Alcotest.test_case "roman_numeral: table values" `Quick test_roman_numeral_values;
Alcotest.test_case "roman_numeral: non-positive" `Quick
test_roman_numeral_non_positive ] )
+
+module S = Colitur_citation.Sigla
+
+let test_verbatim_is_identity () =
+ List.iter
+ (fun c -> Alcotest.(check s) c c (S.format S.verbatim c))
+ [ "3 Kgs. 19:3-8"; "Isa. 1:16-19"; "not a citation at all" ]
+
+let test_unparseable_survives_unchanged () =
+ let sg = S.make ~style:R.default_style ~tradition:B.vulgate ~names in
+ Alcotest.(check s) "passed through" "Nonesuch 1:1" (S.format sg "Nonesuch 1:1")
+
+let test_tradition_applies () =
+ let modern = B.tradition_of_fields [ ("kings_3", "kings_1") ] in
+ let sg = S.make ~style:R.default_style ~tradition:modern ~names in
+ Alcotest.(check s) "renumbered" "kings_1 19:3-8" (S.format sg "3 Kings 19:3-8")
+
+let sigla_suite =
+ [ ("verbatim identity", `Quick, test_verbatim_is_identity);
+ ("unparseable survives", `Quick, test_unparseable_survives_unchanged);
+ ("tradition applies", `Quick, test_tradition_applies) ]