Skip to content

Commit

Permalink
Forward test.
Browse files Browse the repository at this point in the history
  • Loading branch information
eerimoq committed Jul 22, 2018
1 parent 20d146c commit 20dcb51
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/test_textparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from textparser import create_token_re
from textparser import Any
from textparser import Inline
from textparser import Forward


def tokenize(items):
Expand Down Expand Up @@ -287,6 +288,19 @@ def test_1(self):
tree = grammar.parse(tokenize(tokens + [('__EOF__', '')]))
self.assertEqual(tree, expected_tree)

def test_forward(self):
foo = Forward()
foo <<= Sequence('FOO')
grammar = Grammar(foo)

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

for tokens, expected_tree in datas:
tree = grammar.parse(tokenize(tokens + [('__EOF__', '')]))
self.assertEqual(tree, expected_tree)


if __name__ == '__main__':
unittest.main()

0 comments on commit 20dcb51

Please sign in to comment.