aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/test_temporal_ef.ml26
1 files changed, 25 insertions, 1 deletions
diff --git a/test/test_temporal_ef.ml b/test/test_temporal_ef.ml
index 84ee031..96c7761 100644
--- a/test/test_temporal_ef.ml
+++ b/test/test_temporal_ef.ml
@@ -100,7 +100,12 @@ let test_week_numbers () =
(* Time after Pentecost counts from Pentecost, so Trinity is week 1. *)
Alcotest.(check (option int)) "Trinity 2026 is week 1" (Some 1) (T.week (d 2026 5 31));
(* Christmastide has no numbered weeks. *)
- Alcotest.(check (option int)) "Christmastide has no week" None (T.week (d 2026 12 30))
+ Alcotest.(check (option int)) "Christmastide has no week" None (T.week (d 2026 12 30));
+ (* Ash Wednesday is 4 days before the Lent I origin (22 Feb 2026): it belongs
+ to no numbered week. This is the only place in the system [floor_div]'s
+ negative branch fires -- guard against a regression to plain [/], which
+ would wrongly round this up to week 1. *)
+ Alcotest.(check (option int)) "Ash Wednesday has no week" None (T.week (d 2026 2 18))
let test_sunday_slugs () =
Alcotest.(check string) "Advent I" "ef-advent-sunday-1" (sunday_slug_of (T.advent_start 2026));
@@ -115,6 +120,24 @@ let test_sunday_slugs () =
Alcotest.(check string) "11 Jan 2026" "ef-time-after-epiphany-sunday-1"
(sunday_slug_of (d 2026 1 11))
+(* Cross-check: on an ordinary (non-Last, non-resumed) Sunday after Pentecost,
+ the number embedded in [sunday_slug] must equal [week]. The two functions
+ independently compute Pentecost-relative week arithmetic; nothing else pins
+ them together, so a future rubric fix to one that is not mirrored in the
+ other would otherwise diverge silently. *)
+let test_week_sunday_slug_agree () =
+ let easter = Colitur_kernel.Computus.gregorian_easter 2026 in
+ let pentecost = D.add_days easter 49 in
+ List.iter
+ (fun n ->
+ let dt = D.add_days pentecost (7 * n) in
+ let slug = sunday_slug_of dt in
+ let embedded = Scanf.sscanf slug "ef-time-after-pentecost-sunday-%d" (fun k -> k) in
+ Alcotest.(check (option int))
+ (Printf.sprintf "week %d after Pentecost matches slug" n)
+ (Some embedded) (T.week dt))
+ [ 1; 5; 10; 15; 20 ]
+
(* The resumed-Sunday tail: when Easter is early there are more than 23 Sundays
after Pentecost, and the surplus resume the Sundays after Epiphany that
Septuagesima cut short. 2038 has Easter on 25 April (the latest possible) and
@@ -147,6 +170,7 @@ let suite_extra =
Alcotest.test_case "nativity octave" `Quick test_nativity_octave;
Alcotest.test_case "week numbers" `Quick test_week_numbers;
Alcotest.test_case "sunday slugs" `Quick test_sunday_slugs;
+ Alcotest.test_case "week/sunday_slug agree" `Quick test_week_sunday_slug_agree;
Alcotest.test_case "resumed sundays" `Quick test_resumed_sundays ]
let suite =