Hold only the {token} grammar's tests in format_test.go, the rest in files named for what they test, and drop the done item

This commit is contained in:
2026-09-25 18:18:57 +02:00
committed by Lillem4n
parent 44a824ccf5
commit 5e84b26a5f
8 changed files with 301 additions and 264 deletions
+19
View File
@@ -170,3 +170,22 @@ func TestBindingKeyIsNotAPathSegment(t *testing.T) {
t.Errorf("Fake(name./color) = %v, want a no-field error", err)
}
}
func TestFakePathNavigation(t *testing.T) {
f := engine(1)
f.categories = map[string]node{
"addr": compiled(t, `{"format":"{street}","street":"Main"}`),
}
if got, err := f.Fake("addr"); err != nil || !strings.Contains(got, "Main") {
t.Fatalf("Fake(addr) = %q, %v", got, err)
}
if got, err := f.Fake("addr.street"); err != nil || got != "Main" {
t.Fatalf("Fake(addr.street) = %q, %v, want Main", got, err)
}
if _, err := f.Fake("addr.nope"); err == nil {
t.Error("Fake(addr.nope) = nil error, want missing-field error")
}
if _, err := f.Fake("missing"); err == nil {
t.Error("Fake(missing) = nil error, want unknown-category error")
}
}