each agenda grammar is tested against its own example (V-552)

Replaces a test whose name promised more than its body checked: it
looped the grammars asserting Pattern != nil, which regexp.MustCompile
already guarantees at init. Asserting the grammars pass IsAgendaQuestion
would be true by construction, since the first arm is that same loop.

A hand-written example per grammar name catches what neither does: a
grammar edited until it no longer matches the case its comment gives,
and a new grammar nobody wrote an example for.
This commit is contained in:
2026-08-05 21:40:49 +04:00
parent aa7ef33bbf
commit 6e3bb3be97
+25
View File
@@ -39,3 +39,28 @@ func TestIsAgendaQuestionSeparatesHisDayFromTheWorld(t *testing.T) {
}
}
}
// One hand-written utterance per agenda grammar, keyed by name. Asserting that
// the grammars pass IsAgendaQuestion would be true by construction, since the
// first arm is the loop over them. This asserts something else: that each
// grammar still matches the case its own comment gives, and that the set of
// grammars has not grown a member nobody wrote an example for.
func TestEachAgendaGrammarStillMatchesItsOwnExample(t *testing.T) {
examples := map[string]string{
"calendar-query": "что в календаре на завтра",
"agenda-query": "что у меня сегодня",
"plan-day-query": "какие планы на завтра",
"rest-of-day-query": "что дальше?",
"event-time-query": "когда планёрка",
}
for _, g := range AgendaQueryGrammars() {
u, ok := examples[g.Name]
if !ok {
t.Errorf("agenda grammar %q has no example here — add one", g.Name)
continue
}
if !g.Pattern.MatchString(u) {
t.Errorf("grammar %q no longer matches %q", g.Name, u)
}
}
}