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:
@@ -137,6 +137,16 @@ func TestNewErrors(t *testing.T) {
|
||||
map[string]string{"a": `{"format":"{p.v|p.v}","p":{"format":"{v}","v":["1"]}}`},
|
||||
`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 {
|
||||
_, err := New([]string{writeData(t, c.files)})
|
||||
|
||||
Reference in New Issue
Block a user