package toml import ( "testing" "git.makaay.nl/mauricem/go-parsekit/parse" ) func TestArrayStart(t *testing.T) { parser := newParser() wrapper := func(p *parse.API) { parser.parseArray(p) } testParseToAST(t, parser, wrapper, parseToASTTest{"INVALID", "{}", "unexpected input (expected an array) at start of file"}) } func TestArray(t *testing.T) { for _, test := range []parseToASTTest{ {"x=[ape", `{}`, `unexpected input (expected a value) at line 1, column 4`}, {"x=[1", `{}`, `unexpected end of file (expected an array separator) at line 1, column 5`}, {"x=[]", `{"x": []}`, ``}, {"x=[\n]", `{"x": []}`, ``}, {"x=[,]", `{"x": []}`, ``}, {"x=[ , ]", `{"x": []}`, ``}, {"x=[ \n , \r\n ]", `{"x": []}`, ``}, {"x=[ \t , \t ]", `{"x": []}`, ``}, {"x=[\r\n\r\n , \r\n \t\n]", `{"x": []}`, ``}, {"x=[\n#comment on its own line\n]", `{"x": []}`, ``}, {"x=[#comment before close\n]", `{"x": []}`, ``}, {"x=[,#comment after separator\n]", `{"x": []}`, ``}, {"x=[#comment before separator\n,]", `{"x": []}`, ``}, {"x=[#comment before value\n1]", `{"x": [1]}`, ``}, {"x=[1#comment after value\n]", `{"x": [1]}`, ``}, {"x=[1\n#comment on its own line after value\n]", `{"x": [1]}`, ``}, {"x=[1#comment 1\n#comment 2\n#comment 3\n , \n2]", `{"x": [1, 2]}`, ``}, {"x=[1]", `{"x": [1]}`, ``}, {"x=[1,0x2, 0b11, 0o4]", `{"x": [1, 2, 3, 4]}`, ``}, {"x=[0.1,0.2,3e-1,0.04e+1, nan, inf]", `{"x": [0.1, 0.2, 0.3, 0.4, NaN, +Inf]}`, ``}, {"x=[\n\t 'a', \"b\", '''c''', \"\"\"d\ne\"\"\",\n \t]", `{"x": ["a", "b", "c", "d\ne"]}`, ``}, {`x=[1, 2, 3, "four"]`, `{}`, `type mismatch in array of integers: found an item of type string at line 1, column 19`}, {`x=[[1],['a']]`, `{"x": [[1], ["a"]]}`, ``}, {`x=[[[],[]],[]]`, `{"x": [[[], []], []]}`, ``}, {"x=[\r\n\r\n \t\n [\r\n\r\n\t [],[\t]],\t\n[]\t \t \n ]", `{"x": [[[], []], []]}`, ``}, {`x=[[1],'a']`, `{}`, `type mismatch in array of static arrays: found an item of type string at line 1, column 11`}, } { p := newParser() testParseToAST(t, p, p.startKeyValuePair, test) } }