Browse Source

Added preliminary tests.

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.9.0
julienmalard 5 years ago
parent
commit
eeafdb954b
3 changed files with 36 additions and 0 deletions
  1. +1
    -0
      regex-requirements.txt
  2. +34
    -0
      tests/test_regex.py
  3. +1
    -0
      tox.ini

+ 1
- 0
regex-requirements.txt View File

@@ -0,0 +1 @@
regex

+ 34
- 0
tests/test_regex.py View File

@@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import

import logging
import unittest

logging.basicConfig(level=logging.INFO)

from lark.lark import Lark


class TestRegex(unittest.TestCase):
def test_unicode_class(self):
"Tests that character classes from the `regex` module work correctly."
g = Lark(r"""
?start: NAME
NAME: ID_START ID_CONTINUE*
ID_START: /[\p{Lu}\p{Ll}\p{Lt}\p{Lm}\p{Lo}\p{Nl}_]+/
ID_CONTINUE: ID_START | /[\p{Mn}\p{Mc}\p{Nd}\p{Pc}·]+/
""")

self.assertEqual(g.parse('வணக்கம்'), 'வணக்கம்')

def test_unicode_word(self):
"Tests that a persistent bug in the `re` module works when `regex` is enabled."
g = Lark(r"""
?start: NAME
NAME: /[\w]+/
""")
self.assertEqual(g.parse('வணக்கம்'), 'வணக்கம்')


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

+ 1
- 0
tox.ini View File

@@ -15,6 +15,7 @@ pypy3 = pypy3
whitelist_externals = git
deps =
-rnearley-requirements.txt
-rregex-requirements.txt

# to always force recreation and avoid unexpected side effects
recreate=True


Loading…
Cancel
Save