[agent/codex:gpt-5.4-mini] Read ~/spec/code/core/go/i18n/RFC.md fully. Find ONE feature... #20
2 changed files with 55 additions and 10 deletions
23
grammar.go
23
grammar.go
|
|
@ -567,15 +567,20 @@ func ArticlePhrase(word string) string {
|
|||
// TemplateFuncs returns the template.FuncMap with all grammar functions.
|
||||
func TemplateFuncs() template.FuncMap {
|
||||
return template.FuncMap{
|
||||
"title": Title,
|
||||
"lower": core.Lower,
|
||||
"upper": core.Upper,
|
||||
"past": PastTense,
|
||||
"gerund": Gerund,
|
||||
"plural": Pluralize,
|
||||
"pluralForm": PluralForm,
|
||||
"article": ArticlePhrase,
|
||||
"quote": Quote,
|
||||
"title": Title,
|
||||
"lower": core.Lower,
|
||||
"upper": core.Upper,
|
||||
"past": PastTense,
|
||||
"gerund": Gerund,
|
||||
"plural": Pluralize,
|
||||
"pluralForm": PluralForm,
|
||||
"article": ArticlePhrase,
|
||||
"quote": Quote,
|
||||
"label": Label,
|
||||
"progress": Progress,
|
||||
"progressSubject": ProgressSubject,
|
||||
"actionResult": ActionResult,
|
||||
"actionFailed": ActionFailed,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -643,7 +643,22 @@ func TestFrenchGrammarData(t *testing.T) {
|
|||
|
||||
func TestTemplateFuncs(t *testing.T) {
|
||||
funcs := TemplateFuncs()
|
||||
expected := []string{"title", "lower", "upper", "past", "gerund", "plural", "pluralForm", "article", "quote"}
|
||||
expected := []string{
|
||||
"title",
|
||||
"lower",
|
||||
"upper",
|
||||
"past",
|
||||
"gerund",
|
||||
"plural",
|
||||
"pluralForm",
|
||||
"article",
|
||||
"quote",
|
||||
"label",
|
||||
"progress",
|
||||
"progressSubject",
|
||||
"actionResult",
|
||||
"actionFailed",
|
||||
}
|
||||
for _, name := range expected {
|
||||
if _, ok := funcs[name]; !ok {
|
||||
t.Errorf("TemplateFuncs() missing %q", name)
|
||||
|
|
@ -667,6 +682,31 @@ func TestTemplateFuncs_Article(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestTemplateFuncs_CompositeHelpers(t *testing.T) {
|
||||
svc, err := New()
|
||||
if err != nil {
|
||||
t.Fatalf("New() failed: %v", err)
|
||||
}
|
||||
SetDefault(svc)
|
||||
|
||||
tmpl, err := template.New("").Funcs(TemplateFuncs()).Parse(
|
||||
`{{label "status"}}|{{progress "build"}}|{{progressSubject "build" "project"}}|{{actionResult "delete" "file"}}|{{actionFailed "delete" "file"}}`,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("Parse() failed: %v", err)
|
||||
}
|
||||
|
||||
var buf strings.Builder
|
||||
if err := tmpl.Execute(&buf, nil); err != nil {
|
||||
t.Fatalf("Execute() failed: %v", err)
|
||||
}
|
||||
|
||||
want := "Status:|Building...|Building project...|File deleted|Failed to delete file"
|
||||
if got := buf.String(); got != want {
|
||||
t.Fatalf("template composite helpers = %q, want %q", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// --- Benchmarks ---
|
||||
|
||||
func BenchmarkPastTense_Irregular(b *testing.B) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue