2015-03-10 17:47:43 +00:00
|
|
|
# test errors in regex
|
|
|
|
|
|
|
|
try:
|
2022-08-18 07:57:45 +01:00
|
|
|
import re
|
2017-02-14 22:56:22 +00:00
|
|
|
except ImportError:
|
2022-08-18 07:57:45 +01:00
|
|
|
print("SKIP")
|
|
|
|
raise SystemExit
|
2015-03-10 17:47:43 +00:00
|
|
|
|
2020-03-23 02:26:08 +00:00
|
|
|
|
2015-03-10 17:47:43 +00:00
|
|
|
def test_re(r):
|
|
|
|
try:
|
|
|
|
re.compile(r)
|
|
|
|
print("OK")
|
|
|
|
except: # uPy and CPy use different errors, so just ignore the type
|
|
|
|
print("Error")
|
|
|
|
|
2020-03-23 02:26:08 +00:00
|
|
|
|
2015-03-10 17:47:43 +00:00
|
|
|
test_re(r"?")
|
|
|
|
test_re(r"*")
|
|
|
|
test_re(r"+")
|
|
|
|
test_re(r")")
|
|
|
|
test_re(r"[")
|
|
|
|
test_re(r"([")
|
|
|
|
test_re(r"([)")
|
2019-10-16 06:56:29 +01:00
|
|
|
test_re(r"[a\]")
|