summaryrefslogtreecommitdiffstatshomepage
path: root/tests/extmod
diff options
context:
space:
mode:
Diffstat (limited to 'tests/extmod')
-rw-r--r--tests/extmod/ure1.py37
-rw-r--r--tests/extmod/ure_split.py35
2 files changed, 72 insertions, 0 deletions
diff --git a/tests/extmod/ure1.py b/tests/extmod/ure1.py
new file mode 100644
index 0000000000..dff099c8cc
--- /dev/null
+++ b/tests/extmod/ure1.py
@@ -0,0 +1,37 @@
+try:
+ import ure as re
+except ImportError:
+ import re
+
+r = re.compile(".+")
+m = r.match("abc")
+print(m.group(0))
+try:
+ m.group(1)
+except IndexError:
+ print("IndexError")
+
+r = re.compile("(.+)1")
+m = r.match("xyz781")
+print(m.group(0))
+print(m.group(1))
+try:
+ m.group(2)
+except IndexError:
+ print("IndexError")
+
+
+r = re.compile("o+")
+m = r.search("foobar")
+print(m.group(0))
+try:
+ m.group(1)
+except IndexError:
+ print("IndexError")
+
+
+m = re.match(".*", "foo")
+print(m.group(0))
+
+m = re.search("w.r", "hello world")
+print(m.group(0))
diff --git a/tests/extmod/ure_split.py b/tests/extmod/ure_split.py
new file mode 100644
index 0000000000..0154f3abc2
--- /dev/null
+++ b/tests/extmod/ure_split.py
@@ -0,0 +1,35 @@
+try:
+ import ure as re
+except ImportError:
+ import re
+
+r = re.compile(" ")
+s = r.split("a b c foobar")
+print(s)
+
+r = re.compile(" +")
+s = r.split("a b c foobar")
+print(s)
+
+r = re.compile(" +")
+s = r.split("a b c foobar", 1)
+print(s)
+
+r = re.compile(" +")
+s = r.split("a b c foobar", 2)
+print(s)
+
+r = re.compile(" *")
+s = r.split("a b c foobar")
+# TODO - no idea how this is supposed to work, per docs, empty match == stop
+# splitting, so CPython code apparently does some dirty magic.
+#print(s)
+
+r = re.compile("x*")
+s = r.split("foo")
+print(s)
+
+r = re.compile("[a-f]+")
+s = r.split("0a3b9")
+# TODO - char classes are not yet supported by re1.5
+#print(s)