aboutsummaryrefslogtreecommitdiff
path: root/internal/calendar
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-08-12 14:51:33 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-08-12 14:51:33 +0200
commit96b14d17e5210b93f1c126fe165fd81ec1e839af (patch)
tree7382916de5a9415db6cc213fcfa6a03d4f9504ce /internal/calendar
parent09a14446d5b0d4150a6de118a7d04ab99e54c21e (diff)
downloadlectio-96b14d17e5210b93f1c126fe165fd81ec1e839af.tar.gz
lectio-96b14d17e5210b93f1c126fe165fd81ec1e839af.zip
oracle_ef_test: three structural coverage gaps in the strengthened test
Cheap fixes flagged in review, all confirmed against the committed snapshot before being applied: 1. An unmapped season phrase skipped the RANK AND COLOUR checks too, not just the season comparison -- `continue` in the wrong place. Confirmed live: neither Holy Thursday ("maundy"/"holy week" do not match the title "Holy Thursday" itself) nor any of the six September Ember days (no "ember" case exists at all; the Advent and Lent Ember days only ever passed by an incidental substring match on "advent"/"lent") had any oracle coverage at all -- reverting the Holy Thursday colour fix left this test green. Season skip and rank/colour checks are now independent. 2. Colour membership alone cannot catch a Rose regression: violet is a member of every rose/violet pair by construction (Gaudete/ Laetare), so "got violet, want one of [rose violet]" passed even with RG 131's Rose support removed entirely. On the day the pair actually names (oracle rank 1, the Sunday itself, not a weekday reusing its propers), a colour set containing rose now demands rose specifically. 3. `has("sexagesima")` never matched missalemeum's own ligatured "Sexagesimæ" -- confirmed in the committed snapshot: the ligatured form appears 10 times, the unligatured form only 4, and every ligatured instance mapped to season "" (skipped from ALL coverage, not merely a season miss, given finding 1 above). Normalised once, generally (æ -> ae), not as a single hardcoded word, so any other ligature this generator's own data may carry is covered too. Net effect on TestOracleEF: 730 checked (up from 691), 29 skipped (down from 39) -- the 10 reclaimed by fix 3. Still green: 0 unallow-listed rank or colour mismatches over the full snapshot.
Diffstat (limited to 'internal/calendar')
-rw-r--r--internal/calendar/oracle_ef_test.go43
1 files changed, 38 insertions, 5 deletions
diff --git a/internal/calendar/oracle_ef_test.go b/internal/calendar/oracle_ef_test.go
index 7a1b61e..6d63220 100644
--- a/internal/calendar/oracle_ef_test.go
+++ b/internal/calendar/oracle_ef_test.go
@@ -68,6 +68,14 @@ var efRankNumbers = map[int]calendar.Rank{
// there, not to Time after Epiphany.
func efSeasonFromString(s string, month int) calendar.Season {
s = strings.ToLower(s)
+ // missalemeum's own EN-locale text still carries the occasional Latin
+ // ligature (e.g. "Feria V after Sexagesimæ") -- confirmed in the
+ // committed snapshot: "Sexagesimæ" appears 10 times, "Sexagesima" (no
+ // ligature) only 4, and the ligatured form matched no case below,
+ // silently mapping those 10 days to season "" (skipped from coverage
+ // entirely, not merely a season miss). Normalising here fixes every
+ // current and future ligature in one place, not just this one word.
+ s = strings.ReplaceAll(s, "æ", "ae")
has := func(subs ...string) bool {
for _, sub := range subs {
if strings.Contains(s, sub) {
@@ -242,14 +250,22 @@ func TestOracleEF(t *testing.T) {
}
day, _ := time.Parse("2006-01-02", date)
want := efSeasonFromString(src, int(day.Month()))
- if want == "" {
- skipped++
- continue
- }
total++
got := calendar.Compute(day.UTC(), sel, layers)
- if got.Season != want {
+ // An unrecognised season phrase skips the SEASON comparison only --
+ // it must not also skip Rank/Colour for that day. A `continue` here
+ // once did exactly that, silently zeroing oracle coverage for every
+ // day whose phrase efSeasonFromString doesn't recognise (Holy
+ // Thursday -- "maundy"/"holy week" don't match "Holy Thursday"
+ // itself; the six September Ember days -- no "ember" case exists at
+ // all, only Advent/Lent Ember days pass by an incidental substring
+ // match on "advent"/"lent"). Reverting the Holy Thursday colour fix
+ // (temporal_ef.go) left this test green under the old `continue`;
+ // it does not under this one.
+ if want == "" {
+ skipped++
+ } else if got.Season != want {
seasonMiss++
if shownSeason < 40 {
t.Errorf("%s: EF season got %q want %q (from %q)", date, got.Season, want, src)
@@ -279,6 +295,23 @@ func TestOracleEF(t *testing.T) {
break
}
}
+ // Membership alone cannot catch a Rose regression: violet is a
+ // member of every rose/violet pair by construction (Gaudete/
+ // Laetare), so "got violet, want one of [rose violet]" passes even
+ // if RG 131's Rose support (temporal_ef.go) were reverted entirely.
+ // On the day the rose/violet pair actually names -- oracle rank 1,
+ // the Sunday itself, not a weekday reusing its propers (which
+ // carries a lower rank and is deliberately membership-only, this
+ // file's own doc comment item 3) -- a colour set containing rose
+ // demands rose specifically, not merely "some member".
+ if colourOK && od.Rank == 1 && got.Colour != calendar.Rose {
+ for _, c := range od.Colours {
+ if c == "p" {
+ colourOK = false
+ break
+ }
+ }
+ }
if !colourOK && len(od.Colours) > 0 {
if ok, reason := efAllowed(date, day, od, "colour"); ok {
colourAllowed++