aboutsummaryrefslogtreecommitdiff
path: root/test/test_citation_coverage_of.ml
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-08-26 23:53:49 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-08-26 23:53:58 +0200
commit90584d87e763789808329847c46dbaa8e22dca47 (patch)
tree6b5e7c29adc0d1cf5fdfb71cfb8f097867bf04b5 /test/test_citation_coverage_of.ml
parent9ebb06983b7a26db5564302253f2551dfbcf834e (diff)
downloadcolitur-90584d87e763789808329847c46dbaa8e22dca47.tar.gz
colitur-90584d87e763789808329847c46dbaa8e22dca47.zip
fix(citation): represent chapter-crossing verse ranges (W4)
Parse.verse_range's [last] endpoint gains an optional chapter (Parse.verse_end: { chapter : int option; verse : verse_num }), so a hyphen range whose two endpoints lie in different chapters ("1 John 1:5-2:2") can be represented at all. Rejected: a bare [int option] living alongside [last] as a second field on verse_range -- that would let 'a chapter with no verse' exist as a constructible value. parse_part now splits a part's leading "chapter:" at the FIRST colon only (not every colon), so the verses side can itself carry a second colon from a crossing range. parse_range detects a crossing by checking whether the range's right-hand side contains ':', and skips the same-chapter descending-range guard for that case (a later chapter is always "ahead", whatever its own verse numbers are). Handles the compound shape too -- a crossing range followed by further, same-chapter verse references in the same comma list ("Matthew 9:35-10:1,5a,6-8") -- since those trailing pieces parse as ordinary bare verses/ranges, unaffected by the preceding crossing. Render's one_range renders a crossing [last] through the same chapter_verse template one_part already uses for the part's own leading "chapter:verses", so a style that reconfigures the chapter/verse separator renders a crossing endpoint in that same convention rather than a hardcoded ':'. This closes the W4 known-wrong: 41 (now 49, after an intervening Second-reading extraction) of the OF lectionary's citations printed unconverted, every one this exact shape. test_citation_coverage_of.ml's pinned residual is now empty and asserted exactly, over the full 1725-field data/of/lectionary.sexp population, including the round-trip check (parse -> render -> parse structural equality). test_citation.ml gains direct parse-suite cases for the basic crossing, the compound shape, a mid-list crossing, a crossing with a sub-verse letter, and a malformed-crossing rejection. data/of/lectionary.sexp is regenerated via its own generator (tools/bootstrap_lectionary_of.ml, whose own embedded header text is updated to match); only comment lines change, confirmed by diff -- no lectionary entry differs. test_lectionary_of.ml's whole-file SHA-256 pin is updated to match. EF is unaffected: data/ef/ is untouched since v1.0.0, and a direct byte comparison of `colitur day`/`colitur readings` for 2026, 1583 and 9999 against a git-worktree build of 1c0137d is identical on all six outputs.
Diffstat (limited to 'test/test_citation_coverage_of.ml')
-rw-r--r--test/test_citation_coverage_of.ml109
1 files changed, 48 insertions, 61 deletions
diff --git a/test/test_citation_coverage_of.ml b/test/test_citation_coverage_of.ml
index 7badd96..af8d161 100644
--- a/test/test_citation_coverage_of.ml
+++ b/test/test_citation_coverage_of.ml
@@ -3,48 +3,46 @@
(* Fix wave I2 (final-review.md, 2026-08-25-colitur-of-phases-3-5): the OF
counterpart of test_citation_coverage.ml. That file's own header states
the rule this one follows: "every citation the engine can emit must
- parse". EF reaches zero unconverted citations; OF does not, and this
- file is the honest record of exactly where it falls short, mirroring the
- review's own explicit instruction -- "enumerate them rather than
- lowering the bar to fit".
+ parse". At the time this file was first written, EF reached zero
+ unconverted citations and OF did not; this file was the honest record of
+ exactly where it fell short.
- MEASURED, not estimated: before this fix wave, 259 of 730 citation
- fields in `colitur readings --rite of 2026` (35%) printed unconverted --
- 345 distinct book spellings unregistered ({!Colitur_citation.Book}),
- plus verse sub-letter markers ("11a") and a handful of single-chapter-
- book misreads ({!Colitur_citation.Book.is_single_chapter}) the parser
- could not read at all. All of that is now fixed at the source (book.ml's
- own [of_lectionary_table] and parse.ml's own [verse_num]/[single_chapter]
- additions), closing every genuinely fixable shape. What remains, walking
- the FULL data/of/lectionary.sexp (not merely what one civil year happens
- to observe -- a stricter check than EF's own year-walk, and the same one
- tools/bootstrap_lectionary_of.ml's own generated header now runs and
- discloses): 41 distinct references, out of 1542 total, EVERY ONE a
- hyphenated range crossing a chapter boundary ("2:29-3:6", "1 John") --
- a {!Colitur_citation.Parse.t} shape [part]/[verse_range] do not
- represent (a [part] is one chapter and a list of within-chapter ranges;
- representing a cross-chapter range would need restructuring that type
- and {!Colitur_citation.Render}'s own consumption of it), deliberately
- not built this task.
+ MEASURED, not estimated: before fix wave I2, 259 of 730 citation fields
+ in `colitur readings --rite of 2026` (35%) printed unconverted -- 345
+ distinct book spellings unregistered ({!Colitur_citation.Book}), plus
+ verse sub-letter markers ("11a") and a handful of single-chapter-book
+ misreads ({!Colitur_citation.Book.is_single_chapter}) the parser could
+ not read at all. All of that was fixed at the source (book.ml's own
+ [of_lectionary_table] and parse.ml's own [verse_num]/[single_chapter]
+ additions). What remained, walking the FULL data/of/lectionary.sexp (not
+ merely what one civil year happens to observe -- a stricter check than
+ EF's own year-walk, and the same one tools/bootstrap_lectionary_of.ml's
+ own generated header runs and discloses): a hyphenated verse range whose
+ two endpoints lie in different chapters ("2:29-3:6", "1 John") -- a
+ {!Colitur_citation.Parse.t} shape [part]/[verse_range] did not
+ represent. Fix wave I7 (2026-08-26) grew the population from 1542 to
+ 1725 citation fields (a new Second-reading extraction) and the residual
+ from 41 to 49 references, same shape, no new failure mode.
- UPDATED, fix wave I7 (final-review.md, 2026-08-25-colitur-of-phases-3-5,
- 2026-08-26): {!Rite.t.citation_shapes} (kernel change) plus
- tools/bootstrap_lectionary_of.ml's own [cite] now also extract a Second
- reading on every Sunday-cycle (Sunday/solemnity) entry, so the total grew
- 1542 -> 1725 (+183, exactly the count data/of/lectionary.sexp's own
- header COVERAGE (5) now discloses) and the unparseable residual grew
- 41 -> 49: the same chapter-crossing shape, now also hit by 8 of the 183
- new Second-reading references. Not a new failure MODE, just a bigger
- population drawing from the same, already-understood one -- confirmed
- below by [looks_chapter_crossing], unchanged, still holding for all 49.
+ CLOSED (W4, this task): {!Colitur_citation.Parse.verse_end} now lets a
+ range's [last] endpoint name its own, later chapter, and
+ {!Colitur_citation.Render}'s [one_range] renders it back through the
+ part's own [chapter_verse] template. Every one of the 49 pinned
+ references now parses and round-trips -- including the COMPOUND shape
+ ("Matthew 9:35-10:1,5a,6-8": a crossing range followed by further,
+ same-chapter verse references in the same comma list) and a crossing
+ that is not the list's first or only piece ("2 Samuel
+ 18:9-10,14b,24-25a,30-19:3"). The residual below is therefore now EMPTY,
+ over the full 1725-field population -- measured, not merely no longer
+ observed on a sample.
- This file pins that residual EXACTLY -- not merely "at least these fail"
- -- so it fails loudly in BOTH directions: a NEW unconverted reference
- appearing (a regression) and one of these 49 starting to convert (this
- list going stale, e.g. because a future task builds cross-chapter
- support) are both caught, the same discipline every allow-list in this
- project's suite already follows (`expected_rows`, `expected_bands`, the
- litcal/missalemeum comparators). *)
+ The pinning discipline is kept rather than deleted: this file still
+ fails LOUDLY, in both directions, if the unconverted set ever stops
+ being empty -- a real regression (a genuinely new unparseable shape) and
+ a silently corrupted lectionary file are both caught by the same
+ mechanism every allow-list in this project's suite already follows
+ (`expected_rows`, `expected_bands`, the litcal/missalemeum
+ comparators). *)
let lectionary_path = "../data/of/lectionary.sexp"
@@ -53,25 +51,12 @@ let lectionary () =
| Ok l -> l
| Error e -> Alcotest.failf "%s: %s" lectionary_path e
-(* The exact, pinned residual -- copied from data/of/lectionary.sexp's own
- generated "Citations that do not parse" listing, itself produced by the
- SAME {!Colitur_citation.Parse.parse} call this test makes, so the two
- can never silently drift apart without one of them visibly failing to
- regenerate/re-test clean. *)
-let known_cross_chapter_residual =
- [ "1 Corinthians 10:31-11:1"; "1 Corinthians 12:31-13:13"; "1 John 1:5-2:2"; "1 John 2:29-3:6";
- "1 John 3:22-4:6"; "1 John 4:19-5:4"; "1 Thessalonians 3:12-4:2"; "2 Corinthians 3:15-4:1,3-6";
- "2 Corinthians 4:13-5:1"; "2 Samuel 18:9-10,14b,24-25a,30-19:3"; "2 Thessalonians 1:11-2:2";
- "2 Thessalonians 2:16-3:5"; "2 Timothy 3:14-4:2"; "Colossians 1:24-2:3"; "Ecclesiastes 11:9-12:8";
- "Ephesians 4:30-5:2"; "Ephesians 4:32-5:8"; "Exodus 11:10-12:14"; "Exodus 14:21-15:1";
- "Ezekiel 2:8-3:4"; "Galatians 4:22-24,26-27,31-5:1"; "Genesis 1:1-2:2"; "Genesis 1:20-2:4a";
- "Habakkuk 1:12-2:4"; "Hebrews 7:25-8:6"; "Isaiah 52:13-53:12"; "Isaiah 8:23b-9:3";
- "James 3:16-4:3"; "John 15:26-16:4a"; "John 18:1-19:42"; "Jonah 1:1-2:2,11"; "Luke 7:36-8:3";
- "Malachi 1:14b-2:2b,8-10"; "Mark 2:23-3:6"; "Mark 8:34-9:1"; "Matthew 10:34-11:1";
- "Matthew 18:21-19:1"; "Matthew 9:35-10:1,5a,6-8"; "Matthew 9:36-10:8";
- "Numbers 13:1-2,25-14:1,26a-29a,34-35"; "Philippians 3:17-4:1"; "Revelation 20:1-4,11-21:2";
- "Sirach 27:30-28:7"; "The Acts 12:24-13:5a"; "The Acts 17:15,22-18:1"; "The Acts 7:51-8:1a";
- "Wisdom 11:22-12:2"; "Wisdom 2:23-3:9"; "Wisdom 7:22b-8:1" ]
+(* The exact, pinned residual -- EMPTY since W4 closed the cross-chapter gap
+ (see this file's own header). Kept as a named binding, not inlined as
+ [[]] at each use site, so a future partial regression has one place to
+ list what it could not fix, exactly as the pre-W4 version of this file
+ did for the 49 references it once named here. *)
+let known_cross_chapter_residual = []
(* Every failure this walk finds really is a chapter-crossing hyphen range
(a "-" whose right side itself contains a ":") -- checked mechanically,
@@ -107,8 +92,8 @@ let test_of_citations_convert_or_are_the_known_cross_chapter_residual () =
Alcotest.(check int) "1725 citation fields in data/of/lectionary.sexp today -- if this changes, the \
pinned residual below may need updating too, not just this count"
1725 !total;
- Alcotest.(check (list string)) "the unconverted set is EXACTLY the known cross-chapter residual, no \
- more and no fewer"
+ Alcotest.(check (list string)) "the unconverted set is EXACTLY the known cross-chapter residual (empty, \
+ since W4) -- no more and no fewer"
(List.sort compare known_cross_chapter_residual) bad;
List.iter
(fun r ->
@@ -119,7 +104,9 @@ let test_of_citations_convert_or_are_the_known_cross_chapter_residual () =
(* Everything OUTSIDE the pinned residual round-trips through Sigla, the
same structural (not textual) comparison test_citation_coverage.ml's own
- EF version makes, and for the identical reason its own header gives. *)
+ EF version makes, and for the identical reason its own header gives.
+ Since the residual is now empty, this exercises the FULL 1725-field
+ population, cross-chapter shapes included. *)
let test_round_trip_outside_the_residual () =
let sg =
Colitur_citation.Sigla.make ~style:Colitur_citation.Render.default_style