package eval import ( "math/rand" "strings" "testing" "github.com/kami/maven/internal/phraser" ) // TestFallbackPersona scores every line in fallbacks_ru_v1.json and // ack_ru_v1.json on the persona checks the nudges already pass. 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 in between. // // Only the persona checks run. Mood and topic belong to a nudge, and these are // not nudges. 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, } ack, err := phraser.LoadAcks(rand.NewSource(20260804)) if err != nil { t.Fatalf("LoadAcks: %v", err) } variants := append(fb.Variants(), ack.Variants()...) if len(variants) == 0 { t.Fatal("no variants — the file loaded empty") } for _, v := range variants { // The placeholders stand for his own words and carry no persona. body := v for _, ph := range []string{"{sources}", "{key}", "{value}", "{fn}", "{text}"} { body = strings.ReplaceAll(body, ph, "вода") } for _, r := range RunChecks(Case{}, body, "neutral") { if persona[r.Name] && !r.Pass { t.Errorf("%q fails %s: %s", v, r.Name, r.Detail) } } } }