Skip to content

Commit

Permalink
Delimited list mismatch test.
Browse files Browse the repository at this point in the history
  • Loading branch information
eerimoq committed Jul 22, 2018
1 parent 83eb8c2 commit 2ca8678
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/test_textparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,21 @@ def test_delimited_list(self):
tree = grammar.parse(tokens)
self.assertEqual(tree, expected_tree)

def test_delimited_list_mismatch(self):
grammar = Grammar(DelimitedList('WORD'))

datas = [
[('WORD', 'foo'), (',', ',')]
]

for tokens in datas:
tokens = tokenize(tokens + [('__EOF__', '')])

with self.assertRaises(textparser.Error) as cm:
grammar.parse(tokens)

self.assertEqual(str(cm.exception), '')

def test_zero_or_more(self):
grammar = Grammar(ZeroOrMore('WORD'))

Expand Down

0 comments on commit 2ca8678

Please sign in to comment.