summaryrefslogtreecommitdiffstatshomepage
path: root/tests/extmod/ure_error.py
blob: 3f16f9158ccba81d0929c5b012da1f78d3db2870 (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
# test errors in regex

try:
    import ure as re
except ImportError:
    try:
        import re
    except ImportError:
        import sys
        print("SKIP")
        sys.exit()

def test_re(r):
    try:
        re.compile(r)
        print("OK")
    except: # uPy and CPy use different errors, so just ignore the type
        print("Error")

test_re(r'?')
test_re(r'*')
test_re(r'+')
test_re(r')')
test_re(r'[')
test_re(r'([')
test_re(r'([)')