aboutsummaryrefslogtreecommitdiff
path: root/tests/extmod
diff options
context:
space:
mode:
Diffstat (limited to 'tests/extmod')
-rw-r--r--tests/extmod/ure1.py11
-rw-r--r--tests/extmod/ure_sub.py9
2 files changed, 20 insertions, 0 deletions
diff --git a/tests/extmod/ure1.py b/tests/extmod/ure1.py
index 9e1be5fc7..2bdf2d0cf 100644
--- a/tests/extmod/ure1.py
+++ b/tests/extmod/ure1.py
@@ -125,3 +125,14 @@ print(re.compile(r"[ax\-]").split("foo-bar"))
print(re.compile(r"[a\-x]").split("foo-bar"))
print(re.compile(r"[\-ax]").split("foo-bar"))
print("===")
+
+# Module functions take str/bytes/re.
+for f in (re.match, re.search):
+ print(f(".", "foo").group(0))
+ print(f(b".", b"foo").group(0))
+ print(f(re.compile("."), "foo").group(0))
+ try:
+ f(123, "a")
+ except TypeError:
+ print("TypeError")
+print("===")
diff --git a/tests/extmod/ure_sub.py b/tests/extmod/ure_sub.py
index 6bb332077..953e7bf62 100644
--- a/tests/extmod/ure_sub.py
+++ b/tests/extmod/ure_sub.py
@@ -60,3 +60,12 @@ try:
re.sub("(a)", "b\\199999999999999999999999999999999999999", "a")
except:
print("invalid group")
+
+# Module function takes str/bytes/re.
+print(re.sub("a", "a", "a"))
+print(re.sub(b".", b"a", b"a"))
+print(re.sub(re.compile("a"), "a", "a"))
+try:
+ re.sub(123, "a", "a")
+except TypeError:
+ print("TypeError")