Skip to content

Commit

Permalink
added test case for an array line ending with a comment starting with…
Browse files Browse the repository at this point in the history
… '#' character, fixes #46
  • Loading branch information
gurkankaymak committed Dec 24, 2023
1 parent 9979b59 commit fd4b8e7
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1188,14 +1188,27 @@ func TestExtractArray(t *testing.T) {
assertDeepEqual(t, got, Array{Int(1)})
})

t.Run("extract the array without an error if if elements are separated with ASCII newline", func(t *testing.T) {
t.Run("extract the array without an error if elements are separated with ASCII newline", func(t *testing.T) {
parser := newParser(strings.NewReader("[1\n2]"))
parser.advance()
got, err := parser.extractArray()
assertNoError(t, err)
assertDeepEqual(t, got, Array{Int(1), Int(2)})
})

t.Run("extract the array without an error if a line ends with a comment starting with the '#' character", func(t *testing.T) {
parser := newParser(strings.NewReader(`
[
1,
2 # this is a comment
]
`))
parser.advance()
got, err := parser.extractArray()
assertNoError(t, err)
assertDeepEqual(t, got, Array{Int(1), Int(2)})
})

t.Run("extract the array", func(t *testing.T) {
parser := newParser(strings.NewReader("[1, 2]"))
parser.advance()
Expand Down

0 comments on commit fd4b8e7

Please sign in to comment.