diff options
author | vitalyisaev <vitalyisaev@ydb.tech> | 2023-11-30 13:26:22 +0300 |
---|---|---|
committer | vitalyisaev <vitalyisaev@ydb.tech> | 2023-11-30 15:44:45 +0300 |
commit | 0a98fece5a9b54f16afeb3a94b3eb3105e9c3962 (patch) | |
tree | 291d72dbd7e9865399f668c84d11ed86fb190bbf /contrib/python/pyre2/py3/tests | |
parent | cb2c8d75065e5b3c47094067cb4aa407d4813298 (diff) | |
download | ydb-0a98fece5a9b54f16afeb3a94b3eb3105e9c3962.tar.gz |
YQ Connector:Use docker-compose in integrational tests
Diffstat (limited to 'contrib/python/pyre2/py3/tests')
-rw-r--r-- | contrib/python/pyre2/py3/tests/test_charliterals.txt | 47 | ||||
-rw-r--r-- | contrib/python/pyre2/py3/tests/test_count.txt | 40 | ||||
-rw-r--r-- | contrib/python/pyre2/py3/tests/test_emptygroups.txt | 36 | ||||
-rw-r--r-- | contrib/python/pyre2/py3/tests/test_findall.txt | 42 | ||||
-rw-r--r-- | contrib/python/pyre2/py3/tests/test_finditer.txt | 28 | ||||
-rw-r--r-- | contrib/python/pyre2/py3/tests/test_match_expand.txt | 29 | ||||
-rw-r--r-- | contrib/python/pyre2/py3/tests/test_mmap.txt | 18 | ||||
-rw-r--r-- | contrib/python/pyre2/py3/tests/test_namedgroups.txt | 56 | ||||
-rw-r--r-- | contrib/python/pyre2/py3/tests/test_pattern.txt | 12 | ||||
-rw-r--r-- | contrib/python/pyre2/py3/tests/test_search.txt | 29 | ||||
-rw-r--r-- | contrib/python/pyre2/py3/tests/test_split.txt | 17 | ||||
-rw-r--r-- | contrib/python/pyre2/py3/tests/test_sub.txt | 31 | ||||
-rw-r--r-- | contrib/python/pyre2/py3/tests/test_unicode.txt | 71 |
13 files changed, 456 insertions, 0 deletions
diff --git a/contrib/python/pyre2/py3/tests/test_charliterals.txt b/contrib/python/pyre2/py3/tests/test_charliterals.txt new file mode 100644 index 0000000000..2eaea128a3 --- /dev/null +++ b/contrib/python/pyre2/py3/tests/test_charliterals.txt @@ -0,0 +1,47 @@ + >>> import re2 as re + >>> import warnings + >>> warnings.filterwarnings('ignore', category=DeprecationWarning) + +character literals: + + >>> i = 126 + >>> re.compile(r"\%03o" % i) + re2.compile('\\176') + >>> re.compile(r"\%03o" % i)._dump_pattern() + '\\176' + >>> re.match(r"\%03o" % i, chr(i)) is None + False + >>> re.match(r"\%03o0" % i, chr(i) + "0") is None + False + >>> re.match(r"\%03o8" % i, chr(i) + "8") is None + False + >>> re.match(r"\x%02x" % i, chr(i)) is None + False + >>> re.match(r"\x%02x0" % i, chr(i) + "0") is None + False + >>> re.match(r"\x%02xz" % i, chr(i) + "z") is None + False + >>> re.match("\911", "") # doctest: +IGNORE_EXCEPTION_DETAIL +ELLIPSIS + Traceback (most recent call last): + ... + re.error: invalid escape sequence: \9 + +character class literals: + + >>> re.match(r"[\%03o]" % i, chr(i)) is None + False + >>> re.match(r"[\%03o0]" % i, chr(i) + "0") is None + False + >>> re.match(r"[\%03o8]" % i, chr(i) + "8") is None + False + >>> re.match(r"[\x%02x]" % i, chr(i)) is None + False + >>> re.match(r"[\x%02x0]" % i, chr(i) + "0") is None + False + >>> re.match(r"[\x%02xz]" % i, chr(i) + "z") is None + False + >>> re.match("[\911]", "") # doctest: +IGNORE_EXCEPTION_DETAIL +ELLIPSIS + Traceback (most recent call last): + ... + re.error: invalid escape sequence: \9 + diff --git a/contrib/python/pyre2/py3/tests/test_count.txt b/contrib/python/pyre2/py3/tests/test_count.txt new file mode 100644 index 0000000000..ce3525adc5 --- /dev/null +++ b/contrib/python/pyre2/py3/tests/test_count.txt @@ -0,0 +1,40 @@ +count tests +=========== + + >>> import re2 + >>> re2.set_fallback_notification(re2.FALLBACK_EXCEPTION) + +This one is from http://docs.python.org/library/re.html?#finding-all-adverbs: + + >>> re2.count(r"\w+ly", "He was carefully disguised but captured quickly by police.") + 2 + +Groups should not affect count(): + + >>> re2.count(r"(\w+)=(\d+)", "foo=1,foo=2") + 2 + >>> re2.count(r"(\w)\w", "fx") + 1 + +Zero matches: + + >>> re2.count("(f)", "gggg") + 0 + +A pattern matching an empty string: + + >>> re2.count(".*", "foo") + 2 + + >>> re2.count("", "foo") + 4 + +contains tests +============== + + >>> re2.contains('a', 'bbabb') + True + >>> re2.contains('a', 'bbbbb') + False + + >>> re2.set_fallback_notification(re2.FALLBACK_QUIETLY) diff --git a/contrib/python/pyre2/py3/tests/test_emptygroups.txt b/contrib/python/pyre2/py3/tests/test_emptygroups.txt new file mode 100644 index 0000000000..424c8ba25e --- /dev/null +++ b/contrib/python/pyre2/py3/tests/test_emptygroups.txt @@ -0,0 +1,36 @@ +Empty/unused groups +=================== + + >>> import re + >>> import re2 + >>> re2.set_fallback_notification(re2.FALLBACK_EXCEPTION) + +Unused vs. empty group: + + >>> re.search( '(foo)?((.*).)(bar)?', 'a').groups() + (None, 'a', '', None) + >>> re2.search('(foo)?((.*).)(bar)?', 'a').groups() + (None, 'a', '', None) + + >>> re.search(r'((.*)?.)', 'a').groups() + ('a', '') + >>> re2.search(r'((.*)?.)', 'a').groups() + ('a', '') + >>> re.search(r'((.*)+.)', 'a').groups() + ('a', '') + >>> re2.search(r'((.*)+.)', 'a').groups() + ('a', '') + +The following show different behavior for re and re2: + + >>> re.search(r'((.*)*.)', 'a').groups() + ('a', '') + >>> re2.search(r'((.*)*.)', 'a').groups() + ('a', None) + + >>> re.search(r'((.*)*.)', 'Hello').groups() + ('Hello', '') + >>> re2.search(r'((.*)*.)', 'Hello').groups() + ('Hello', 'Hell') + + >>> re2.set_fallback_notification(re2.FALLBACK_QUIETLY) diff --git a/contrib/python/pyre2/py3/tests/test_findall.txt b/contrib/python/pyre2/py3/tests/test_findall.txt new file mode 100644 index 0000000000..c753b936df --- /dev/null +++ b/contrib/python/pyre2/py3/tests/test_findall.txt @@ -0,0 +1,42 @@ +findall tests +============= + + >>> import re2 + >>> re2.set_fallback_notification(re2.FALLBACK_EXCEPTION) + +This one is from http://docs.python.org/library/re.html?#finding-all-adverbs: + + >>> re2.findall(r"\w+ly", "He was carefully disguised but captured quickly by police.") + ['carefully', 'quickly'] + +This one makes sure all groups are found: + + >>> re2.findall(r"(\w+)=(\d+)", "foo=1,foo=2") + [('foo', '1'), ('foo', '2')] + +When there's only one matched group, it should not be returned in a tuple: + + >>> re2.findall(r"(\w)\w", "fx") + ['f'] + +Zero matches is an empty list: + + >>> re2.findall("(f)", "gggg") + [] + +If pattern matches an empty string, do it only once at the end: + + >>> re2.findall(".*", "foo") + ['foo', ''] + + >>> re2.findall("", "foo") + ['', '', '', ''] + + + >>> import re + >>> re.findall(r'\b', 'The quick brown fox jumped over the lazy dog') + ['', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''] + >>> re2.findall(r'\b', 'The quick brown fox jumped over the lazy dog') + ['', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''] + + >>> re2.set_fallback_notification(re2.FALLBACK_QUIETLY) diff --git a/contrib/python/pyre2/py3/tests/test_finditer.txt b/contrib/python/pyre2/py3/tests/test_finditer.txt new file mode 100644 index 0000000000..3d60d199c7 --- /dev/null +++ b/contrib/python/pyre2/py3/tests/test_finditer.txt @@ -0,0 +1,28 @@ +Simple tests for the ``finditer`` function. +=========================================== + + >>> import re2 + >>> re2.set_fallback_notification(re2.FALLBACK_EXCEPTION) + + >>> with open('tests/cnn_homepage.dat') as tmp: + ... data = tmp.read() + >>> len(list(re2.finditer(r'\w+', data))) + 14230 + + >>> [m.group(1) for m in re2.finditer(r'\n#hdr-editions(.*?)\n', data)] + [' a { text-decoration:none; }', ' li { padding:0 10px; }', ' ul li.no-pad-left span { font-size:12px; }'] + + >>> [m.group(1) for m in re2.finditer(r'^#hdr-editions(.*?)$', + ... data, re2.M)] + [' a { text-decoration:none; }', ' li { padding:0 10px; }', ' ul li.no-pad-left span { font-size:12px; }'] + + >>> for a in re2.finditer(r'\b', 'foo bar zed'): print(a) + <re2.Match object; span=(0, 0), match=''> + <re2.Match object; span=(3, 3), match=''> + <re2.Match object; span=(4, 4), match=''> + <re2.Match object; span=(7, 7), match=''> + <re2.Match object; span=(8, 8), match=''> + <re2.Match object; span=(11, 11), match=''> + + + >>> re2.set_fallback_notification(re2.FALLBACK_QUIETLY) diff --git a/contrib/python/pyre2/py3/tests/test_match_expand.txt b/contrib/python/pyre2/py3/tests/test_match_expand.txt new file mode 100644 index 0000000000..b3d5652c76 --- /dev/null +++ b/contrib/python/pyre2/py3/tests/test_match_expand.txt @@ -0,0 +1,29 @@ +Match Expand Tests +================== + +Match objects have an .expand() method which allows them to +expand templates as if the .sub() method was called on the pattern. + + >>> import re2 + >>> re2.set_fallback_notification(re2.FALLBACK_EXCEPTION) + >>> m = re2.match("(\\w+) (\\w+)\\W+(?P<title>\\w+)", "Isaac Newton, physicist") + >>> m.expand("\\2, \\1") + 'Newton, Isaac' + >>> m.expand("\\1 \\g<title>") + 'Isaac physicist' + >>> m.expand("\\2, \\1 \\2") + 'Newton, Isaac Newton' + >>> m.expand("\\3") + 'physicist' + >>> m.expand("\\1 \\g<foo>") # doctest: +IGNORE_EXCEPTION_DETAIL +ELLIPSIS + Traceback (most recent call last): + ... + IndexError: no such group 'foo'; available groups: ['title'] + >>> m.expand("\\0") + '\x00' + >>> m.expand("\01") + '\x01' + >>> m.expand('\t\n\x0b\r\x0c\x07\x08\\B\\Z\x07\\A\\w\\W\\s\\S\\d\\D') + '\t\n\x0b\r\x0c\x07\x08\\B\\Z\x07\\A\\w\\W\\s\\S\\d\\D' + + >>> re2.set_fallback_notification(re2.FALLBACK_QUIETLY) diff --git a/contrib/python/pyre2/py3/tests/test_mmap.txt b/contrib/python/pyre2/py3/tests/test_mmap.txt new file mode 100644 index 0000000000..12ffa97498 --- /dev/null +++ b/contrib/python/pyre2/py3/tests/test_mmap.txt @@ -0,0 +1,18 @@ + +Testing re2 on buffer object +============================ + + >>> import re2 + >>> import mmap + >>> re2.set_fallback_notification(re2.FALLBACK_EXCEPTION) + + >>> tmp = open("tests/cnn_homepage.dat", "rb+") + >>> data = mmap.mmap(tmp.fileno(), 0) + + >>> len(list(re2.finditer(b'\\w+', data))) + 14230 + + >>> data.close() + >>> tmp.close() + + >>> re2.set_fallback_notification(re2.FALLBACK_QUIETLY) diff --git a/contrib/python/pyre2/py3/tests/test_namedgroups.txt b/contrib/python/pyre2/py3/tests/test_namedgroups.txt new file mode 100644 index 0000000000..70f561a39f --- /dev/null +++ b/contrib/python/pyre2/py3/tests/test_namedgroups.txt @@ -0,0 +1,56 @@ +Testing some aspects of named groups +================================================= + + >>> import re2 + >>> re2.set_fallback_notification(re2.FALLBACK_EXCEPTION) + + >>> m = re2.match(r"(?P<first_name>\w+) (?P<last_name>\w+)", "Malcolm Reynolds") + >>> m.start("first_name") + 0 + >>> m.start("last_name") + 8 + + >>> m.span("last_name") + (8, 16) + >>> m.regs + ((0, 16), (0, 7), (8, 16)) + + >>> m = re2.match(u"(?P<first_name>\\w+) (?P<last_name>\\w+)", u"Malcolm Reynolds") + >>> m.start(u"first_name") + 0 + >>> m.start(u"last_name") + 8 + + >>> m.span(u"last_name") + (8, 16) + >>> m.regs + ((0, 16), (0, 7), (8, 16)) + +Compare patterns with and without unicode + + >>> pattern = re2.compile(br"(?P<first_name>\w+) (?P<last_name>\w+)") + >>> print(pattern._dump_pattern().decode('utf8')) + (?P<first_name>\w+) (?P<last_name>\w+) + >>> pattern = re2.compile(u"(?P<first_name>\\w+) (?P<last_name>\\w+)", + ... re2.UNICODE) + >>> print(pattern._dump_pattern()) + (?P<first_name>[_\p{L}\p{Nd}]+) (?P<last_name>[_\p{L}\p{Nd}]+) + +Make sure positions are converted properly for unicode + + >>> m = pattern.match( + ... u'\u05d9\u05e9\u05e8\u05d0\u05dc \u05e6\u05d3\u05d5\u05e7') + >>> m.start(u"first_name") + 0 + >>> m.start(u"last_name") + 6 + >>> m.end(u"last_name") + 10 + >>> m.regs + ((0, 10), (0, 5), (6, 10)) + >>> m.span(2) + (6, 10) + >>> m.span(u"last_name") + (6, 10) + + >>> re2.set_fallback_notification(re2.FALLBACK_QUIETLY) diff --git a/contrib/python/pyre2/py3/tests/test_pattern.txt b/contrib/python/pyre2/py3/tests/test_pattern.txt new file mode 100644 index 0000000000..aab47359a2 --- /dev/null +++ b/contrib/python/pyre2/py3/tests/test_pattern.txt @@ -0,0 +1,12 @@ +pattern tests +============= + + >>> import re2 + >>> re2.set_fallback_notification(re2.FALLBACK_EXCEPTION) + +We should be able to get back what we put in. + + >>> re2.compile("(foo|b[a]r?)").pattern + '(foo|b[a]r?)' + + >>> re2.set_fallback_notification(re2.FALLBACK_QUIETLY) diff --git a/contrib/python/pyre2/py3/tests/test_search.txt b/contrib/python/pyre2/py3/tests/test_search.txt new file mode 100644 index 0000000000..9c1e18f08c --- /dev/null +++ b/contrib/python/pyre2/py3/tests/test_search.txt @@ -0,0 +1,29 @@ +These are simple tests of the ``search`` function +================================================= + + >>> import re2 + >>> re2.set_fallback_notification(re2.FALLBACK_EXCEPTION) + >>> import warnings + >>> warnings.filterwarnings('ignore', category=DeprecationWarning) + + >>> re2.search("((?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])", "hello 28.224.2.1 test").group() + '28.224.2.1' + + >>> re2.search("(\d{3})\D?(\d{3})\D?(\d{4})", "800-555-1212").groups() + ('800', '555', '1212') + + >>> input = 'a' * 999 + >>> len(re2.search('(?:a{1000})?a{999}', input).group()) + 999 + + >>> with open('tests/cnn_homepage.dat') as tmp: + ... data = tmp.read() + >>> re2.search(r'\n#hdr-editions(.*?)\n', data).groups() + (' a { text-decoration:none; }',) + +Verify some sanity checks + + >>> re2.compile(r'x').search('x', 2000) + >>> re2.compile(r'x').search('x', 1, -300) + + >>> re2.set_fallback_notification(re2.FALLBACK_QUIETLY) diff --git a/contrib/python/pyre2/py3/tests/test_split.txt b/contrib/python/pyre2/py3/tests/test_split.txt new file mode 100644 index 0000000000..a3e44bc605 --- /dev/null +++ b/contrib/python/pyre2/py3/tests/test_split.txt @@ -0,0 +1,17 @@ +Split tests +=========== + +This one tests to make sure that unicode / utf8 data is parsed correctly. + + >>> import re2 + >>> re2.set_fallback_notification(re2.FALLBACK_EXCEPTION) + >>> a = u'\u6211\u5f88\u597d, \u4f60\u5462?' + + >>> re2.split(u' ', a) == [u'\u6211\u5f88\u597d,', u'\u4f60\u5462?'] + True + >>> re2.split(b' ', a.encode('utf8')) == [ + ... b'\xe6\x88\x91\xe5\xbe\x88\xe5\xa5\xbd,', + ... b'\xe4\xbd\xa0\xe5\x91\xa2?'] + True + + >>> re2.set_fallback_notification(re2.FALLBACK_QUIETLY) diff --git a/contrib/python/pyre2/py3/tests/test_sub.txt b/contrib/python/pyre2/py3/tests/test_sub.txt new file mode 100644 index 0000000000..b41dd30d28 --- /dev/null +++ b/contrib/python/pyre2/py3/tests/test_sub.txt @@ -0,0 +1,31 @@ +Tests of substitution +===================== + +This first test is just looking to replace things between parentheses +with an empty string. + + + >>> import hashlib + >>> import gzip + >>> import re2 + >>> re2.set_fallback_notification(re2.FALLBACK_EXCEPTION) + >>> import warnings + >>> warnings.filterwarnings('ignore', category=DeprecationWarning) + + >>> with gzip.open('tests/wikipages.xml.gz', 'rb') as tmp: + ... data = tmp.read() + >>> print(hashlib.md5(re2.sub(b'\(.*?\)', b'', data)).hexdigest()) + b7a469f55ab76cd5887c81dbb0cfe6d3 + + >>> re2.set_fallback_notification(re2.FALLBACK_QUIETLY) + +Issue #26 re2.sub replacements with a match of "(.*)" hangs forever + + >>> re2.sub('(.*)', r'\1;replacement', 'original') + 'original;replacement;replacement' + + >>> re2.sub('(.*)', lambda x: x.group() + ';replacement', 'original') + 'original;replacement;replacement' + + >>> re2.subn("b*", lambda x: "X", "xyz", 4) + ('XxXyXzX', 4) diff --git a/contrib/python/pyre2/py3/tests/test_unicode.txt b/contrib/python/pyre2/py3/tests/test_unicode.txt new file mode 100644 index 0000000000..71d497b80d --- /dev/null +++ b/contrib/python/pyre2/py3/tests/test_unicode.txt @@ -0,0 +1,71 @@ +Here are some tests to make sure that utf-8 works +================================================= + + >>> import sys + >>> import re2 as re + >>> re.set_fallback_notification(re.FALLBACK_EXCEPTION) + >>> a = u'\u6211\u5f88\u597d' + >>> c = re.compile(a[0]) + >>> c.search(a).group() == u'\u6211' + True + +Test unicode stickyness + + >>> re.sub(u'x', u'y', u'x') == u'y' + True + >>> re.sub(r'x', 'y', 'x') == 'y' + True + >>> re.findall('.', 'x') == ['x'] + True + >>> re.findall(u'.', u'x') == [u'x'] + True + >>> re.split(',', '1,2,3') == ['1', '2', '3'] + True + >>> re.split(u',', u'1,2,3') == [u'1', u'2', u'3'] + True + >>> re.search('(\\d)', '1').group(1) == '1' + True + >>> re.search(u'(\\d)', u'1').group(1) == u'1' + True + +Test unicode character groups + + >>> re.search(u'\\d', u'\u0661', re.UNICODE).group(0) == u'\u0661' + True + >>> int(re.search(u'\\d', u'\u0661', re.UNICODE).group(0)) == 1 + True + >>> (re.search(u'\\w', u'\u0401') is None) == (sys.version_info[0] == 2) + True + >>> re.search(u'\\w', u'\u0401', re.UNICODE).group(0) == u'\u0401' + True + >>> re.search(u'\\s', u'\u1680', re.UNICODE).group(0) == u'\u1680' + True + >>> re.findall(r'[\s\d\w]', 'hey 123', re.UNICODE) == ['h', 'e', 'y', ' ', '1', '2', '3'] + True + >>> re.search(u'\\D', u'\u0661x', re.UNICODE).group(0) == u'x' + True + >>> re.search(u'\\W', u'\u0401!', re.UNICODE).group(0) == u'!' + True + >>> re.search(u'\\S', u'\u1680x', re.UNICODE).group(0) == u'x' + True + >>> re.set_fallback_notification(re.FALLBACK_QUIETLY) + >>> re.search(u'[\\W]', u'\u0401!', re.UNICODE).group(0) == u'!' + True + >>> re.search(u'[\\S]', u'\u1680x', re.UNICODE).group(0) == u'x' + True + >>> re.set_fallback_notification(re.FALLBACK_EXCEPTION) + + +Positions are translated transparently between unicode and UTF-8 + + >>> re.search(u' (.)', u'\U0001d200xxx\u1234 x').span(1) + (6, 7) + >>> re.search(b' (.)', u'\U0001d200xxx\u1234 x'.encode('utf-8')).span(1) + (11, 12) + >>> re.compile(u'x').findall(u'\u1234x', 1, 2) == [u'x'] + True + >>> data = u'\U0001d200xxx\u1234 x' + >>> re.search(u' (.)', data).string == data + True + + >>> re.set_fallback_notification(re.FALLBACK_QUIETLY) |