From 6bcff89e3c3a9b94f17a014028efa392c88228ed Mon Sep 17 00:00:00 2001 From: Erez Sh Date: Tue, 6 Oct 2020 22:29:05 +0300 Subject: [PATCH] Added test for standalone compression --- tests/test_tools.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/test_tools.py b/tests/test_tools.py index 0972f8f..7a732d1 100644 --- a/tests/test_tools.py +++ b/tests/test_tools.py @@ -19,9 +19,9 @@ class TestStandalone(TestCase): def setUp(self): pass - def _create_standalone(self, grammar): + def _create_standalone(self, grammar, compress=False): 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() context = {'__doc__': None} @@ -52,6 +52,11 @@ class TestStandalone(TestCase): self.assertRaises(context['UnexpectedToken'], l.parse, 'twelve') 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): grammar = """ start: a b