Test internal/grammar, and allow the root to import it

This commit is contained in:
2026-10-05 12:06:43 +02:00
committed by Lillem4n
parent 46895151c8
commit 41292f9d89
9 changed files with 170 additions and 33 deletions
+21
View File
@@ -0,0 +1,21 @@
package grammar
import "testing"
func TestRefShapeSplitsTheSigil(t *testing.T) {
for ref, want := range map[string][2]string{
"/a.b": {"/", "a.b"},
".a": {".", "a"},
"..a.b": {"..", "a.b"},
} {
sigil, rest, err := RefShape(ref)
if err != nil || sigil != want[0] || rest != want[1] {
t.Errorf("RefShape(%q) = %q, %q, %v, want %q", ref, sigil, rest, err, want)
}
}
for _, ref := range []string{"/", "//a", ".../a", "/a..b.", "/a.[b]"} {
if _, _, err := RefShape(ref); err == nil {
t.Errorf("RefShape(%q) = nil error, want one", ref)
}
}
}