aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/dune6
-rw-r--r--test/test_citation.ml21
2 files changed, 25 insertions, 2 deletions
diff --git a/test/dune b/test/dune
index a90b715..d883d2f 100644
--- a/test/dune
+++ b/test/dune
@@ -6,6 +6,7 @@
../data/ef/adjustments.sexp
../lang/la.ini
../lang/en.ini
+ ../lang/traditions.ini
../data/ef/expected-divergences.sexp
../data/ef/expected-divergences-missalemeum.sexp
../data/ef/lectionary.sexp
@@ -55,4 +56,7 @@
; back to the workspace root's own default alias), so schema/day-v1.json
; needs its own entry here too, exactly like every other runtime file
; above.
- ../schema/day-v1.json))
+ ../schema/day-v1.json
+ ; Same trap, same fix: Task 8's --sigla-tradition flag makes the CLI read
+ ; this file, and a cram sandbox holds only what this stanza names.
+ ../lang/traditions.ini))
diff --git a/test/test_citation.ml b/test/test_citation.ml
index 25fc260..d9be86e 100644
--- a/test/test_citation.ml
+++ b/test/test_citation.ml
@@ -174,6 +174,23 @@ let test_every_data_file_token_resolves () =
Alcotest.failf "unresolved book tokens in shipped data: %s"
(String.concat ", " unresolved)
+(* lang/traditions.ini's own [modern] section, duplicated here on purpose:
+ the shipped file and this expectation are written twice and must agree,
+ so a typo in either is visible. Two ids mapping onto the SAME target is
+ always a typo -- it would silently merge two books -- so this asserts the
+ mapping is injective, not merely that every id is known. *)
+let test_modern_tradition_is_injective () =
+ let fields =
+ [ ("kings_3", "kings_1"); ("kings_4", "kings_2");
+ ("esdras_2", "nehemiah"); ("ecclesiasticus", "sirach");
+ ("osee", "hosea"); ("jonas", "jonah") ]
+ in
+ Alcotest.(check (list string)) "all ids known" [] (B.unknown_fields fields);
+ let targets = List.map snd fields in
+ let uniq = List.sort_uniq compare targets in
+ Alcotest.(check int) "no two ids share a target"
+ (List.length targets) (List.length uniq)
+
let suite =
( "book",
[ Alcotest.test_case "both spellings one book" `Quick test_both_spellings_are_one_book;
@@ -185,7 +202,9 @@ let suite =
Alcotest.test_case "tokens has no duplicate spelling" `Quick
test_tokens_has_no_duplicate_spelling;
Alcotest.test_case "every data file token resolves" `Quick
- test_every_data_file_token_resolves ] )
+ test_every_data_file_token_resolves;
+ Alcotest.test_case "modern tradition is injective" `Quick
+ test_modern_tradition_is_injective ] )
module P = Colitur_citation.Parse