aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/pyre2/py3/tests/test_charliterals.txt
blob: 2eaea128a31a46aa2535403e9a676bc9f68f90e0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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