summaryrefslogtreecommitdiff
path: root/tests/extmod/ure_limit.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/extmod/ure_limit.py')
-rw-r--r--tests/extmod/ure_limit.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/extmod/ure_limit.py b/tests/extmod/ure_limit.py
new file mode 100644
index 000000000..99c6a818e
--- /dev/null
+++ b/tests/extmod/ure_limit.py
@@ -0,0 +1,34 @@
+# Test overflow in ure.compile output code.
+
+try:
+ import ure as re
+except ImportError:
+ print("SKIP")
+ raise SystemExit
+
+
+def test_re(r):
+ try:
+ re.compile(r)
+ except:
+ print("Error")
+
+
+# too many chars in []
+test_re("[" + "a" * 256 + "]")
+
+# too many groups
+test_re("(a)" * 256)
+
+# jump too big for ?
+test_re("(" + "a" * 62 + ")?")
+
+# jump too big for *
+test_re("(" + "a" * 60 + ".)*")
+test_re("(" + "a" * 60 + "..)*")
+
+# jump too big for +
+test_re("(" + "a" * 62 + ")+")
+
+# jump too big for |
+test_re("b" * 63 + "|a")