Link every test fragment before asserting on it

This commit is contained in:
2026-09-28 02:53:08 +02:00
committed by Lillem4n
parent e0969e69e7
commit e11ee9ec0e
9 changed files with 36 additions and 26 deletions
+3 -3
View File
@@ -21,7 +21,7 @@ func TestStringIsAFormat(t *testing.T) {
if got := mustRender(t, f, `"{digits(3)}"`); !regexp.MustCompile(`^[0-9]{3}$`).MatchString(got) {
t.Errorf(`render("{digits(3)}") = %q, want three digits`, got)
}
if _, err := compile(parse(t, `"{x}"`)); err == nil || !strings.Contains(err.Error(), `no field "x"`) {
if _, err := linked(t, `"{x}"`); err == nil || !strings.Contains(err.Error(), `no field "x"`) {
t.Errorf(`compile("{x}") = %v, want a no-field error`, err)
}
}
@@ -51,7 +51,7 @@ func TestBraceEscapes(t *testing.T) {
`{"format":"{a{b}","a":"Q"}`: "'{'",
`"{x"`: "unterminated",
} {
if _, err := compile(parse(t, src)); err == nil || !strings.Contains(err.Error(), want) {
if _, err := linked(t, src); err == nil || !strings.Contains(err.Error(), want) {
t.Errorf("compile(%s) = %v, want an error mentioning %s", src, err, want)
}
}
@@ -126,7 +126,7 @@ func TestFormatCompileErrors(t *testing.T) {
`"{int(1)}"`, // wrong arity
`"{float(1,2)}"`, // wrong arity
} {
if _, err := compile(parse(t, bad)); err == nil {
if _, err := linked(t, bad); err == nil {
t.Errorf("compile(%s) = nil error, want error", bad)
}
}