865623ef3e
The accessors are functions now, so the call sites that compared against one literal compare against the entry instead: IsUnknownFallback and IsSourcesFallback in the daemon tests, the entry key in the phraser tests. A reworded variant no longer breaks a Go test. The eval scores every variant on the persona checks the nudges already pass.
41 lines
1.3 KiB
Go
41 lines
1.3 KiB
Go
package eval
|
|
|
|
import (
|
|
"math/rand"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/kami/maven/internal/phraser"
|
|
)
|
|
|
|
// TestFallbackPersona scores every line in fallbacks_ru_v1.json on the persona
|
|
// checks the nudges are already held to. These lines are heard out loud, and
|
|
// they live in a JSON file now, so a reworded variant that says "рад" or "вы"
|
|
// would otherwise reach him with nothing between it and the speaker.
|
|
//
|
|
// Only the persona checks run. Mood and topic belong to a nudge, and these are
|
|
// not nudges: they are what she says when there is no answer.
|
|
func TestFallbackPersona(t *testing.T) {
|
|
fb, err := phraser.LoadFallbacks(rand.NewSource(20260804))
|
|
if err != nil {
|
|
t.Fatalf("LoadFallbacks: %v", err)
|
|
}
|
|
persona := map[string]bool{
|
|
CheckLang: true, CheckFeminine: true, CheckHisGender: true,
|
|
CheckAddress: true, CheckCringe: true, CheckLength: true,
|
|
}
|
|
variants := fb.Variants()
|
|
if len(variants) == 0 {
|
|
t.Fatal("no variants — the file loaded empty")
|
|
}
|
|
for _, v := range variants {
|
|
// {sources} stands for his own notes and never carries persona of its own.
|
|
body := strings.ReplaceAll(v, "{sources}", "два литра")
|
|
for _, r := range RunChecks(Case{}, body, "neutral") {
|
|
if persona[r.Name] && !r.Pass {
|
|
t.Errorf("%q fails %s: %s", v, r.Name, r.Detail)
|
|
}
|
|
}
|
|
}
|
|
}
|