Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Genarito committed Jun 9, 2021
1 parent f8feb32 commit f3fb9c7
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions gura/GuraParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,11 @@ def list(self) -> MatchResult:
item = item.value[0]
else:
item = item.value

result.append(item)

self.maybe_match('ws')
self.maybe_match('new_line')
if not self.maybe_keyword(','):
break

Expand Down
16 changes: 16 additions & 0 deletions tests/arrays/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ def setUp(self):
]
}

self.expected_inside_object = {
"model": {
"columns": [
["var1", "str"],
["var2", "str"]
]
}
}

def __get_file_parsed_data(self, file_name) -> Dict:
"""
Gets the content of a specific file parsed
Expand All @@ -73,6 +82,13 @@ def test_with_comments(self):
parsed_data = self.__get_file_parsed_data('with_comments.ura')
self.assertDictEqual(parsed_data, self.expected)

def test_array_in_object(self):
"""Tests issue https://github.com/gura-conf/gura/issues/1"""
parsed_data = self.__get_file_parsed_data('array_in_object.ura')
self.assertDictEqual(parsed_data, self.expected_inside_object)
parsed_data = self.__get_file_parsed_data('array_in_object_trailing_comma.ura')
self.assertDictEqual(parsed_data, self.expected_inside_object)


if __name__ == '__main__':
unittest.main()
5 changes: 5 additions & 0 deletions tests/arrays/tests-files/array_in_object.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
model:
columns: [
[ "var1", "str" ],
[ "var2", "str" ]
]
5 changes: 5 additions & 0 deletions tests/arrays/tests-files/array_in_object_trailing_comma.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
model:
columns: [
[ "var1", "str" ],
[ "var2", "str" ],
]

0 comments on commit f3fb9c7

Please sign in to comment.