blob: d72484f6e1adfc503853245c685cbd4684443a48 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
module L = Colitur_naming.Lang
let read path =
let ic = open_in_bin path in
let s = really_input_string ic (in_channel_length ic) in
close_in ic;
s
let la () =
match L.of_string (read "../lang/la.ini") with
| Ok t -> t
| Error e -> Alcotest.failf "lang/la.ini: %s" e
(* Every TEMPORAL slug the engine can emit must have a Latin name. THIS IS THE
TEST THAT WOULD HAVE CAUGHT THE ORIGINAL DEFECT -- a booklet printed
"ef-septuagesima-sunday-2" because nothing asserted coverage. It must fail
loudly the moment a new slug appears without a name.
RESTRICTED TO "^ef-" SLUGS FOR NOW (Task 3's own scope: la.ini's
[celebration] table currently carries the temporal half only). Task 4 adds
the sanctoral names and REMOVES this filter -- see this file's own
[is_temporal_slug] below, kept as one clearly-named, easy-to-find place to
change, rather than an inline condition. *)
let is_temporal_slug slug = String.length slug >= 3 && String.sub slug 0 3 = "ef-"
let test_every_temporal_slug_has_a_latin_name () =
let t = la () in
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 missing = ref [] in
for y = 2020 to 2045 do
Array.iter
(fun (d : (Rite_ef.Vocab_ef.season, Rite_ef.Vocab_ef.rank) Colitur_kernel.Liturgical_day.t) ->
let slug =
Colitur_kernel.Slug.to_string
d.Colitur_kernel.Liturgical_day.observed.Colitur_kernel.Celebration.slug
in
(* A miss returns the key itself, so name = slug means "no entry". *)
if
is_temporal_slug slug
&& L.celebration t slug = slug
&& not (List.mem slug !missing)
then missing := slug :: !missing)
(Colitur_kernel.Calendar.year ctx layer y)
done;
if !missing <> [] then
Alcotest.failf "%d slugs have no Latin name, e.g. %s" (List.length !missing)
(String.concat ", " (List.filteri (fun i _ -> i < 5) !missing))
let test_vocabularies_are_complete () =
let t = la () in
List.iter
(fun s -> if L.season t s = s then Alcotest.failf "no Latin season name for %S" s)
[ "advent"; "christmastide"; "time-after-epiphany"; "septuagesima"; "lent";
"passiontide"; "paschaltide"; "time-after-pentecost" ];
List.iter
(fun r -> if L.rank t r = r then Alcotest.failf "no Latin rank name for %S" r)
[ "class-1"; "class-2"; "class-3"; "class-4" ];
List.iter
(fun c -> if L.colour t c = c then Alcotest.failf "no Latin colour name for %S" c)
[ "white"; "red"; "green"; "violet"; "rose"; "black" ];
for n = 0 to 6 do
if L.weekday t n = string_of_int n then Alcotest.failf "no Latin weekday for %d" n
done;
for n = 1 to 12 do
if L.month t n = string_of_int n then Alcotest.failf "no Latin month for %d" n
done
let suite =
( "Lang/coverage",
[ Alcotest.test_case "every temporal slug has a Latin name" `Slow
test_every_temporal_slug_has_a_latin_name;
Alcotest.test_case "vocabularies complete" `Quick test_vocabularies_are_complete ] )
|