Slight improvement for the document-level error in case no key or table was found.
This commit is contained in:
parent
5782971bde
commit
b1484cb690
|
@ -21,8 +21,10 @@ func (t *parser) startDocument(p *parse.API) {
|
|||
p.Handle(t.startTable)
|
||||
case p.Peek(detectKey):
|
||||
p.Handle(t.startKeyValuePair)
|
||||
case p.Accept(a.EndOfFile):
|
||||
p.Stop()
|
||||
default:
|
||||
p.ExpectEndOfFile()
|
||||
p.Expected("key/value pair, table or array of tables")
|
||||
return
|
||||
}
|
||||
if p.IsStoppedOrInError() {
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
|
||||
func TestComment(t *testing.T) {
|
||||
for _, test := range []parseTest{
|
||||
{``, `{}`, `unexpected end of file (expected comment) at start of file`},
|
||||
{``, `{}`, ``},
|
||||
{`#`, `{}`, ``},
|
||||
{`# `, `{}`, ``},
|
||||
{`# with data`, `{}`, ``},
|
||||
|
@ -20,3 +20,12 @@ func TestComment(t *testing.T) {
|
|||
testParse(t, p, p.startDocument, test)
|
||||
}
|
||||
}
|
||||
|
||||
func TestInvalidDocument(t *testing.T) {
|
||||
for _, test := range []parseTest{
|
||||
{`!false!`, `{}`, `unexpected input (expected key/value pair, table or array of tables) at start of file`},
|
||||
} {
|
||||
p := newParser()
|
||||
testParse(t, p, p.startDocument, test)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue