aboutsummaryrefslogtreecommitdiff
path: root/test/test_temporal_ef.ml
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_temporal_ef.ml')
-rw-r--r--test/test_temporal_ef.ml29
1 files changed, 28 insertions, 1 deletions
diff --git a/test/test_temporal_ef.ml b/test/test_temporal_ef.ml
index aa84014..f99626c 100644
--- a/test/test_temporal_ef.ml
+++ b/test/test_temporal_ef.ml
@@ -162,6 +162,32 @@ let test_resumed_sundays () =
in
Alcotest.(check bool) "2035 has resumed Epiphany Sundays" true (resumed <> [])
+(* Regression for a Task 14 Validate finding: named's own explicit week
+ numbers (Easter, Low Sunday, Passion/Palm Sunday, Trinity, Pentecost and
+ its Vigil, Christ the King) must agree with what [week] independently
+ computes for the same date -- omitting or mis-stating one breaks week
+ continuity across that day. A general property over every day of many
+ years, not point assertions on the three days the bug was found on, so the
+ same drift cannot silently reappear in a future addition to [named]. *)
+let prop_named_week_agrees_with_week =
+ QCheck.Test.make ~count:200
+ ~name:"named's explicit week agrees with week, wherever named gives one"
+ (QCheck.int_range 1583 9998)
+ (fun y ->
+ let start = d y 1 1 in
+ let stop = d (y + 1) 1 1 in
+ let n = D.to_rata stop - D.to_rata start in
+ let rec check i =
+ i >= n
+ ||
+ let dt = D.add_days start i in
+ (match T.named dt with
+ | Some (_, _, _, _, Some w) -> T.week dt = Some w
+ | _ -> true)
+ && check (i + 1)
+ in
+ check 0)
+
module Cel = Colitur_kernel.Celebration
module Sl = Colitur_kernel.Slug
module Colr = Colitur_kernel.Colour
@@ -277,4 +303,5 @@ let suite =
( "Rite_ef",
[ Alcotest.test_case "vocab roundtrips" `Quick test_vocab_roundtrips;
Alcotest.test_case "slug words" `Quick test_slug_words ]
- @ suite_extra )
+ @ suite_extra
+ @ List.map QCheck_alcotest.to_alcotest [ prop_named_week_agrees_with_week ] )