Browse Source

Added test for standalone compression

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.11.0
Erez Sh 4 years ago
parent
commit
6bcff89e3c
1 changed files with 7 additions and 2 deletions
  1. +7
    -2
      tests/test_tools.py

+ 7
- 2
tests/test_tools.py View File

@@ -19,9 +19,9 @@ class TestStandalone(TestCase):
def setUp(self): def setUp(self):
pass pass


def _create_standalone(self, grammar):
def _create_standalone(self, grammar, compress=False):
code_buf = StringIO() code_buf = StringIO()
standalone.gen_standalone(Lark(grammar, parser='lalr'), out=code_buf)
standalone.gen_standalone(Lark(grammar, parser='lalr'), out=code_buf, compress=compress)
code = code_buf.getvalue() code = code_buf.getvalue()


context = {'__doc__': None} context = {'__doc__': None}
@@ -52,6 +52,11 @@ class TestStandalone(TestCase):
self.assertRaises(context['UnexpectedToken'], l.parse, 'twelve') self.assertRaises(context['UnexpectedToken'], l.parse, 'twelve')
self.assertRaises(context['UnexpectedCharacters'], l.parse, '$ talks') self.assertRaises(context['UnexpectedCharacters'], l.parse, '$ talks')


context = self._create_standalone(grammar, compress=True)
_Lark = context['Lark_StandAlone']
l = _Lark()
x = l.parse('12 elephants')

def test_contextual(self): def test_contextual(self):
grammar = """ grammar = """
start: a b start: a b


Loading…
Cancel
Save