@@ -234,6 +234,7 @@ func (l *tomlLexer) lexRvalue() tomlLexStateFn {
|
|||||||
return l.lexKey
|
return l.lexKey
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return l.errorf("no value can start with %c", next)
|
||||||
}
|
}
|
||||||
|
|
||||||
l.emit(tokenEOF)
|
l.emit(tokenEOF)
|
||||||
|
|||||||
@@ -692,3 +692,17 @@ func TestInvalidFloat(t *testing.T) {
|
|||||||
token{Position{1, 7}, tokenEOF, ""},
|
token{Position{1, 7}, tokenEOF, ""},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestLexUnknownRvalue(t *testing.T) {
|
||||||
|
testFlow(t, `a = !b`, []token{
|
||||||
|
token{Position{1, 1}, tokenKey, "a"},
|
||||||
|
token{Position{1, 3}, tokenEqual, "="},
|
||||||
|
token{Position{1, 5}, tokenError, "no value can start with !"},
|
||||||
|
})
|
||||||
|
|
||||||
|
testFlow(t, `a = \b`, []token{
|
||||||
|
token{Position{1, 1}, tokenKey, "a"},
|
||||||
|
token{Position{1, 3}, tokenEqual, "="},
|
||||||
|
token{Position{1, 5}, tokenError, `no value can start with \`},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -299,6 +299,18 @@ func TestArrayNestedStrings(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestParseUnknownRvalue(t *testing.T) {
|
||||||
|
_, err := Load("a = !bssss")
|
||||||
|
if err == nil {
|
||||||
|
t.Error("Expecting a parse error")
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = Load("a = /b")
|
||||||
|
if err == nil {
|
||||||
|
t.Error("Expecting a parse error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestMissingValue(t *testing.T) {
|
func TestMissingValue(t *testing.T) {
|
||||||
_, err := Load("a = ")
|
_, err := Load("a = ")
|
||||||
if err.Error() != "(1, 5): expecting a value" {
|
if err.Error() != "(1, 5): expecting a value" {
|
||||||
|
|||||||
Reference in New Issue
Block a user