From abade24943f2f77c058b5ff768093b8babc9a8c3 Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Tue, 11 Aug 2026 11:59:43 +0200 Subject: kernel: Vocab, Celebration and Temporal parametric types Rite specificity is carried by type parameters plus a vocab record of operations rather than by functors: the same guarantee that a rite cannot name another rite's season, without threading module plumbing through every kernel module. Celebration takes only the rank parameter, since it has no season field and OCaml rejects a type variable that appears in no field. --- test/test_names.ml | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'test/test_names.ml') diff --git a/test/test_names.ml b/test/test_names.ml index 9db8217..f340c62 100644 --- a/test/test_names.ml +++ b/test/test_names.ml @@ -74,6 +74,25 @@ let test_date_spec_sexp_roundtrip () = Alcotest.(check bool) "sexp roundtrip" true (ds = ds') | Error e -> Alcotest.failf "fixed: %s" e) +module Cel = Colitur_kernel.Celebration +module S = Colitur_kernel.Slug +module Col = Colitur_kernel.Colour +module Sub = Colitur_kernel.Subject + +(* A throwaway rank vocabulary, to exercise the parametric type. *) +type demo_rank = High | Low [@@deriving sexp] + +let test_celebration () = + let c = + Cel.make ~slug:(S.of_string_exn "ef-easter-sunday") + ~names:(N.of_list [ (lang "la", "Dominica Resurrectionis") ]) + ~rank:High ~colour:Col.White ~subject:Sub.Lord ~layer:"temporal" () + in + Alcotest.(check string) "slug" "ef-easter-sunday" (S.to_string c.Cel.slug); + Alcotest.(check bool) "default citations empty" true (c.Cel.citations = []); + let sexp = Cel.sexp_of_t sexp_of_demo_rank c in + Alcotest.(check bool) "sexp roundtrip" true (Cel.t_of_sexp demo_rank_of_sexp sexp = c) + let suite = ( "Names/Citation/DateSpec", [ Alcotest.test_case "names basics" `Quick test_names_basics; @@ -83,4 +102,5 @@ let suite = Alcotest.test_case "names sexp roundtrip" `Quick test_names_sexp_roundtrip; Alcotest.test_case "citation" `Quick test_citation; Alcotest.test_case "date_spec" `Quick test_date_spec; - Alcotest.test_case "date_spec sexp roundtrip" `Quick test_date_spec_sexp_roundtrip ] ) + Alcotest.test_case "date_spec sexp roundtrip" `Quick test_date_spec_sexp_roundtrip; + Alcotest.test_case "celebration" `Quick test_celebration ] ) -- cgit v1.3