Merge pull request #11 from pelletier/fix_comments_multilines_array
Comments in a multiline array cause parse error
This commit is contained in:
@@ -175,6 +175,10 @@ func lexVoid(l *lexer) stateFn {
|
||||
l.ignore()
|
||||
}
|
||||
|
||||
if l.depth > 0 {
|
||||
return lexRvalue
|
||||
}
|
||||
|
||||
if l.next() == eof {
|
||||
break
|
||||
}
|
||||
|
||||
@@ -207,6 +207,22 @@ func TestArrayInts(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestMultilineArrayComments(t *testing.T) {
|
||||
testFlow(t, "a = [1, # wow\n2, # such items\n3, # so array\n]", []token{
|
||||
token{tokenKey, "a"},
|
||||
token{tokenEqual, "="},
|
||||
token{tokenLeftBracket, "["},
|
||||
token{tokenInteger, "1"},
|
||||
token{tokenComma, ","},
|
||||
token{tokenInteger, "2"},
|
||||
token{tokenComma, ","},
|
||||
token{tokenInteger, "3"},
|
||||
token{tokenComma, ","},
|
||||
token{tokenRightBracket, "]"},
|
||||
token{tokenEOF, ""},
|
||||
})
|
||||
}
|
||||
|
||||
func TestKeyEqualArrayBools(t *testing.T) {
|
||||
testFlow(t, "foo = [true, false, true]", []token{
|
||||
token{tokenKey, "foo"},
|
||||
|
||||
@@ -170,6 +170,20 @@ func TestNewlinesInArrays(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestArrayWithExtraComma(t *testing.T) {
|
||||
tree, err := Load("a = [1,\n2,\n3,\n]")
|
||||
assertTree(t, tree, err, map[string]interface{}{
|
||||
"a": []int64{int64(1), int64(2), int64(3)},
|
||||
})
|
||||
}
|
||||
|
||||
func TestArrayWithExtraCommaComment(t *testing.T) {
|
||||
tree, err := Load("a = [1, # wow\n2, # such items\n3, # so array\n]")
|
||||
assertTree(t, tree, err, map[string]interface{}{
|
||||
"a": []int64{int64(1), int64(2), int64(3)},
|
||||
})
|
||||
}
|
||||
|
||||
func TestMissingFile(t *testing.T) {
|
||||
_, err := LoadFile("foo.toml")
|
||||
if err.Error() != "open foo.toml: no such file or directory" {
|
||||
|
||||
Reference in New Issue
Block a user