summaryrefslogtreecommitdiff
path: root/test/test_computus.ml
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-07-31 14:06:33 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-07-31 14:06:33 +0200
commit9c0a755767da935dce6bfdaed2f7e11cfd30421a (patch)
treeb17f429cdb8aeb4f3dfe628c162511de14d62faf /test/test_computus.ml
parentcdb7ffe804ca19aee935af090f76c9eb83cbce14 (diff)
downloadcolitur-9c0a755767da935dce6bfdaed2f7e11cfd30421a.tar.gz
colitur-9c0a755767da935dce6bfdaed2f7e11cfd30421a.zip
kernel(computus): Gregorian + Julian Easter
Anonymous Gregorian (Meeus/Jones/Butcher) for OF+EF; Meeus Julian mapped to the proleptic-Gregorian date for future eastern rites. Verified vs known dates (2000/2024-27, 1583; Orthodox 2023/24) and EXHAUSTIVELY over 1583..9999: every Easter is a Sunday in [Mar22,Apr25].
Diffstat (limited to 'test/test_computus.ml')
-rw-r--r--test/test_computus.ml38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/test_computus.ml b/test/test_computus.ml
new file mode 100644
index 0000000..1502ad2
--- /dev/null
+++ b/test/test_computus.ml
@@ -0,0 +1,38 @@
+module D = Colitur_kernel.Date
+module C = Colitur_kernel.Computus
+
+let ymd d = (D.year d, D.month d, D.day d)
+
+let test_gregorian_known () =
+ let cases = [ (2024, 3, 31); (2025, 4, 20); (2026, 4, 5); (2027, 3, 28); (2000, 4, 23); (1583, 4, 10) ] in
+ List.iter
+ (fun (y, m, d) ->
+ Alcotest.(check (triple int int int)) (Printf.sprintf "Gregorian Easter %d" y)
+ (y, m, d) (ymd (C.gregorian_easter y)))
+ cases
+
+let test_julian_known () =
+ (* Orthodox (Julian) Easter, expressed as the equivalent Gregorian date *)
+ let cases = [ (2023, 4, 16); (2024, 5, 5) ] in
+ List.iter
+ (fun (y, m, d) ->
+ Alcotest.(check (triple int int int)) (Printf.sprintf "Julian Easter %d" y)
+ (y, m, d) (ymd (C.julian_easter y)))
+ cases
+
+let test_gregorian_invariants_exhaustive () =
+ (* the confidence-to-9999 guarantee: EVERY year's Easter is a Sunday in
+ [Mar 22, Apr 25] inclusive. *)
+ for y = 1583 to 9999 do
+ let e = C.gregorian_easter y in
+ Alcotest.(check bool) (Printf.sprintf "%d Easter is Sunday" y) true (D.weekday e = D.Sun);
+ let _, m, d = ymd e in
+ let ok = (m = 3 && d >= 22) || (m = 4 && d <= 25) in
+ Alcotest.(check bool) (Printf.sprintf "%d Easter in [Mar22,Apr25]" y) true ok
+ done
+
+let suite =
+ ( "Computus",
+ [ Alcotest.test_case "Gregorian known dates" `Quick test_gregorian_known;
+ Alcotest.test_case "Julian known dates" `Quick test_julian_known;
+ Alcotest.test_case "Gregorian invariants 1583..9999" `Slow test_gregorian_invariants_exhaustive ] )