Hold the template doc to naming a pass, and name the check for what it does

This commit is contained in:
2026-09-21 11:17:57 +02:00
committed by Lillem4n
parent 311ed40d05
commit dda470dc9c
+7 -4
View File
@@ -133,12 +133,15 @@ func receiverType(recv *ast.FieldList) string {
const fillHeader = "Filled by " const fillHeader = "Filled by "
// TestTemplateFieldsNameTheirPass holds a renamed pass to the group it fills. // TestTemplateFieldGroupsNameADeclaredPass holds a renamed pass to the group it
func TestTemplateFieldsNameTheirPass(t *testing.T) { // fills, and to the template doc.
func TestTemplateFieldGroupsNameADeclaredPass(t *testing.T) {
fset, files := sourceFiles(t) fset, files := sourceFiles(t)
declared := declaredSymbols(files) declared := declaredSymbols(files)
doc, st, headers := templateStruct(t, fset, files) doc, st, headers := templateStruct(t, fset, files)
namesDeclared(t, "the template doc", doc, declared) if namesDeclared(t, "the template doc", doc, declared) == 0 {
t.Error("the template doc names no pass, so nothing says when a field is final")
}
for _, field := range st.Fields.List { for _, field := range st.Fields.List {
if len(field.Names) == 0 { if len(field.Names) == 0 {
t.Error("an embedded field of template sits under no header, so nothing says which pass fills it") t.Error("an embedded field of template sits under no header, so nothing says which pass fills it")
@@ -150,7 +153,7 @@ func TestTemplateFieldsNameTheirPass(t *testing.T) {
continue continue
} }
if namesDeclared(t, "the header above template."+id.Name, header, declared) == 0 { if namesDeclared(t, "the header above template."+id.Name, header, declared) == 0 {
t.Errorf("the header above template.%s names no function, so it names no pass", id.Name) t.Errorf("the header above template.%s names no symbol, so it names no pass", id.Name)
} }
} }
} }