Browse Source

Write test for nearley include

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.5.1
Kaspar Emanuel 7 years ago
parent
commit
21ecd9a319
1 changed files with 13 additions and 0 deletions
  1. +13
    -0
      tests/test_nearley/test_nearley.py

+ 13
- 0
tests/test_nearley/test_nearley.py View File

@@ -65,6 +65,19 @@ class TestNearley(unittest.TestCase):
assert c['g'] == 178
assert c['b'] == 3

def test_include(self):
fn = os.path.join(NEARLEY_PATH, 'test/grammars/folder-test.ne')
with open(fn) as f:
grammar = f.read()

code = create_code_for_nearley_grammar(grammar, 'main', BUILTIN_PATH, os.path.dirname(fn))
d = {}
exec (code, d)
parse = d['parse']

parse('a')
parse('b')


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

Loading…
Cancel
Save