summaryrefslogtreecommitdiff
path: root/test/test_precedence_of.ml
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_precedence_of.ml')
-rw-r--r--test/test_precedence_of.ml41
1 files changed, 40 insertions, 1 deletions
diff --git a/test/test_precedence_of.ml b/test/test_precedence_of.ml
index 8817fa8..64b182c 100644
--- a/test/test_precedence_of.ml
+++ b/test/test_precedence_of.ml
@@ -225,8 +225,47 @@ let test_part3 () =
Alcotest.(check int) label expected (Rite_of.Precedence_of.band c cand))
part3_cases
+(* The temporal candidate Temporal_of produces for [d], as Precedence.resolve
+ would build it. *)
+let temporal_candidate d =
+ let t = Rite_of.Temporal_of.temporal d in
+ { Precedence.cel = t.Temporal.office; origin = Precedence.Temporal }
+
+let ctx_of_date d =
+ let t = Rite_of.Temporal_of.temporal d in
+ { Precedence.date = d; season = t.Temporal.season; weekday = Date.weekday d }
+
+let band_of_date d = Rite_of.Precedence_of.band (ctx_of_date d) (temporal_candidate d)
+
+(* Every day of a year: the temporal candidate must land on a real table
+ entry, never [unclassified]. *)
+let check_year y =
+ let mk_date y m dd =
+ Date.make ~year:y ~month:m ~day:dd |> Result.get_ok in
+ let d = ref (mk_date y 1 1) in
+ let last = mk_date y 12 31 in
+ while Date.compare !d last <= 0 do
+ let b = band_of_date !d in
+ if b = Rite_of.Precedence_of.unclassified then
+ Alcotest.failf "%s: temporal candidate is unclassified"
+ (Date.to_iso8601 !d);
+ d := Date.add_days !d 1
+ done
+
+let prop_band_total =
+ QCheck.Test.make ~count:200 ~name:"band classifies every temporal candidate"
+ (QCheck.int_range 1583 9999)
+ (fun y -> check_year y; true)
+
+let test_exhaustive_band_total () =
+ if Sys.getenv_opt "COLITUR_EXHAUSTIVE_SWEEP" = None then
+ Alcotest.skip ()
+ else for y = 1583 to 9999 do check_year y done
+
let suite =
( "precedence-of",
[ Alcotest.test_case "Tabula part I (entries 1-4)" `Quick test_part1;
Alcotest.test_case "Tabula part II (entries 5-9)" `Quick test_part2;
- Alcotest.test_case "Tabula part III (entries 10-13)" `Quick test_part3 ] )
+ Alcotest.test_case "Tabula part III (entries 10-13)" `Quick test_part3;
+ Alcotest.test_case "band is total over the domain" `Slow test_exhaustive_band_total ]
+ @ List.map QCheck_alcotest.to_alcotest [ prop_band_total ] )