aboutsummaryrefslogtreecommitdiff
path: root/test/test_precedence_of.ml
blob: bf514ffa1985bc47b5c6845d9755397a5fa6537e (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
(* Table-driven, one Alcotest case per Tabula entry, so a transcription error
   names the entry it broke. Mirrors test/test_precedence_ef.ml. *)
open Colitur_kernel
module Vocab_of = Rite_of.Vocab_of

let mk_cel ?(layer = Rite_of.Precedence_of.universal_layer)
    ?(status = Celebration.Feast) ?(colour = Colour.White)
    ?(subject = Subject.Saint) ~slug ~rank () =
  { Celebration.slug = Slug.of_string_exn slug;
    names = Names.empty; rank; status; colour; subject;
    citations = []; layer }

let mk ?layer ?status ?colour ?subject ~slug ~rank ~origin () =
  { Precedence.cel = mk_cel ?layer ?status ?colour ?subject ~slug ~rank ();
    origin }

let ctx ~iso ~season =
  let date = Date.of_iso8601 iso |> Result.get_ok in
  { Precedence.date; season; weekday = Date.weekday date }

(* Each row: label, context, candidate, expected band value. *)
let part1_cases =
  [ ( "entry 1: Good Friday",
      ctx ~iso:"2026-04-03" ~season:Vocab_of.Lent,
      mk ~slug:"of-lent-6-friday" ~rank:Vocab_of.Feria ~origin:Precedence.Temporal (),
      10 );
    ( "entry 1: Holy Saturday",
      ctx ~iso:"2026-04-04" ~season:Vocab_of.Lent,
      mk ~slug:"of-lent-6-saturday" ~rank:Vocab_of.Feria ~origin:Precedence.Temporal (),
      10 );
    ( "entry 1: Easter Sunday",
      ctx ~iso:"2026-04-05" ~season:Vocab_of.Easter,
      mk ~slug:"of-easter-sunday" ~rank:Vocab_of.Sollemnitas ~origin:Precedence.Temporal (),
      10 );
    ( "entry 2: Holy Thursday is a Holy Week feria, not the Triduum",
      ctx ~iso:"2026-04-02" ~season:Vocab_of.Lent,
      mk ~slug:"of-lent-6-thursday" ~rank:Vocab_of.Feria ~origin:Precedence.Temporal (),
      20 );
    ( "entry 2: the Nativity",
      ctx ~iso:"2026-12-25" ~season:Vocab_of.Christmas,
      mk ~slug:"of-nativity" ~rank:Vocab_of.Sollemnitas ~origin:Precedence.Temporal (),
      20 );
    ( "entry 2: a Sunday of Advent",
      ctx ~iso:"2026-11-29" ~season:Vocab_of.Advent,
      mk ~slug:"of-advent-sunday-1" ~rank:Vocab_of.Sollemnitas ~origin:Precedence.Temporal (),
      20 );
    ( "entry 2: Ash Wednesday",
      ctx ~iso:"2026-02-18" ~season:Vocab_of.Lent,
      mk ~slug:"of-ash-wednesday" ~rank:Vocab_of.Feria ~origin:Precedence.Temporal (),
      20 );
    ( "entry 2: a day within the Octave of Easter",
      ctx ~iso:"2026-04-07" ~season:Vocab_of.Easter,
      mk ~slug:"of-easter-octave-day-3" ~rank:Vocab_of.Sollemnitas ~origin:Precedence.Temporal (),
      20 );
    ( "entry 3: a universal solemnity of a saint",
      ctx ~iso:"2026-06-29" ~season:Vocab_of.Ordinary_time,
      mk ~slug:"of-peter-and-paul" ~rank:Vocab_of.Sollemnitas ~origin:Precedence.Sanctoral (),
      30 );
    ( "entry 4: a proper solemnity",
      ctx ~iso:"2026-06-29" ~season:Vocab_of.Ordinary_time,
      mk ~layer:"proper:diocese-of-poznan" ~slug:"of-local-patron"
        ~rank:Vocab_of.Sollemnitas ~origin:Precedence.Sanctoral (),
      40 ) ]

let test_part1 () =
  List.iter
    (fun (label, c, cand, expected) ->
      Alcotest.(check int) label expected (Rite_of.Precedence_of.band c cand))
    part1_cases

let suite =
  ("precedence-of", [ Alcotest.test_case "Tabula part I (entries 1-4)" `Quick test_part1 ])