package router import "testing" func TestParseCommandProhibitionUsesCommandPositionAndScope(t *testing.T) { for _, utterance := range []string{ "не отменяй напоминание про молоко", "не закрой задачу купить молоко", "не закрыть задачу купить молоко", "никогда не перезапускай nginx", "только не удаляй будильник", "ни в коем случае не перезапускай nginx", "ни за что не закрывай задачу", "Maven, пожалуйста, не удаляй будильник", "don't restart nginx", "don’t close the task", "do not cancel the milk reminder", "never remove the task", } { if got, ok := ParseCommandProhibition(utterance); !ok || len(got.Body) == 0 { t.Errorf("ParseCommandProhibition(%q) = %+v, %v; want direct prohibition", utterance, got, ok) } } for _, utterance := range []string{ "я не закрыл задачу купить молоко", "I did not close the task", "можно ли не отменять напоминание", "проверь диск, но ничего не удаляй", "не забудь напомнить мне завтра про молоко", "don't forget to remind me about milk", "не мог бы ты отменить напоминание про молоко", "donut restart nginx", "noteworthy restart nginx", } { if got, ok := ParseCommandProhibition(utterance); ok { t.Errorf("ParseCommandProhibition(%q) = %+v; not a direct prohibited mutation", utterance, got) } } for _, utterance := range []string{ "не мог перезапустить nginx", "не могла закрыть задачу купить молоко", "не могли удалить напоминание", "не забудь сначала задачу, потом напомнить про молоко", } { if _, ok := ParseCommandProhibition(utterance); !ok { t.Errorf("%q must retain the fail-closed execution belt", utterance) } } // This idiom does not contain a reminder verb. Treating its nested board // transition as affirmative would be unsafe, so the execution belt wins. if _, ok := ParseCommandProhibition("не забудь закрыть задачу купить молоко"); !ok { t.Fatal("an ambiguous don't-forget board transition must fail closed") } } func TestCommandProhibitionGrammarEmitsANonExecutableSentinel(t *testing.T) { decision, matched, accepted := CommandProhibitionGrammar().Evaluate("don't restart nginx") if !matched || !accepted || decision.Intent != IntentAct { t.Fatalf("decision=%+v matched=%v accepted=%v; want deterministic act refusal", decision, matched, accepted) } if !decision.Slots.HasFn || decision.Slots.Fn != ProhibitedActFn { t.Fatalf("slots=%+v, want non-executable fn %q", decision.Slots, ProhibitedActFn) } }