Tests for an arm check that yields to a clearer error

{..|..} reported a repeated arm rather than a reference with no path, and
{|} reported one rather than a missing field. Both are load errors either
way, but the repeat is a consequence of the real mistake, so the real one
should be what the author reads.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
M
2026-08-31 13:40:07 +02:00
committed by lilleman-tw
parent 465eb05704
commit dea1fcf311
+10
View File
@@ -137,6 +137,16 @@ func TestNewErrors(t *testing.T) {
map[string]string{"a": `{"format":"{p.v|p.v}","p":{"format":"{v}","v":["1"]}}`}, map[string]string{"a": `{"format":"{p.v|p.v}","p":{"format":"{v}","v":["1"]}}`},
`arm "p.v" is repeated`, `arm "p.v" is repeated`,
}, },
// An arm that is broken on its own terms is reported as that, not as a
// repeat: the repeat is a consequence of the real mistake.
"repeated arm with no path": {
map[string]string{"a": `{"format":"{..|..}"}`},
"reference has no path",
},
"repeated empty arm": {
map[string]string{"a": `{"format":"{|}"}`},
`no field ""`,
},
} }
for name, c := range rejected { for name, c := range rejected {
_, err := New([]string{writeData(t, c.files)}) _, err := New([]string{writeData(t, c.files)})