Assert prove, stepInto and columnItems panic on an unhandled node, and a bare table read is refused as a row

This commit is contained in:
2026-09-29 09:36:14 +02:00
committed by Lillem4n
parent 64bb5c7004
commit d01c914e7f
2 changed files with 13 additions and 0 deletions
+3
View File
@@ -61,10 +61,13 @@ func (*unhandledNode) isNode() {}
func TestNodeSwitchesPanicOnAnUnhandledNode(t *testing.T) {
for name, call := range map[string]func(){
"columnItems": func() { columnItems(&unhandledNode{}) },
"contained": func() { contained(&unhandledNode{}) },
"paths": func() { paths(&unhandledNode{}) },
"prove": func() { (&valueProof{}).prove(&unhandledNode{}) },
"render": func() { render(nil, &unhandledNode{}, renderScope{}) },
"renderEdges": func() { renderEdges(&unhandledNode{}) },
"stepInto": func() { _, _ = stepInto(&unhandledNode{}, "x") },
} {
mustPanic(t, name, call)
}
+10
View File
@@ -1132,3 +1132,13 @@ func TestCellReadsMeetWhereTheRenderPairsTheRows(t *testing.T) {
t.Fatalf("New = %v, want 1280's shop and 1281's city kept apart, one draw of municipality rendering one of them", err)
}
}
func TestDatatypeRefusesARowRead(t *testing.T) {
for _, format := range []string{"{/region}", "{/region[01]}"} {
files := with(geo(), map[string]string{"row.json": `{"format":"","col":{"format":"` + format + `","datatype":"integer"}}`})
want := `"{name}" renders a row of region, which is composed text`
if _, err := New(WithoutShippedData(), WithDataPath(writeFiles(t, files))); err == nil || !strings.Contains(err.Error(), want) {
t.Errorf("%s: New = %v, want an error containing %q", format, err, want)
}
}
}