Skip to content

Commit 07615d9

Browse files
committed
tests/extmod: Move split-on-empty-match tests to a separate test file.
And provide an expected-output file because these tests have a different behaviour under CPython.
1 parent 23df4b0 commit 07615d9

3 files changed

Lines changed: 22 additions & 10 deletions

File tree

tests/extmod/ure_split.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,6 @@
1919
s = r.split("a b c foobar", 2)
2020
print(s)
2121

22-
r = re.compile(" *")
23-
s = r.split("a b c foobar")
24-
# TODO - no idea how this is supposed to work, per docs, empty match == stop
25-
# splitting, so CPython code apparently does some dirty magic.
26-
#print(s)
27-
28-
r = re.compile("x*")
29-
s = r.split("foo")
30-
print(s)
31-
3222
r = re.compile("[a-f]+")
3323
s = r.split("0a3b9")
3424
print(s)

tests/extmod/ure_split_empty.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# test splitting with pattern matches that can be empty
2+
#
3+
# CPython 3.5 issues a FutureWarning for these tests because their
4+
# behaviour will change in a future version. MicroPython just stops
5+
# splitting as soon as an empty match is found.
6+
7+
import ure as re
8+
9+
r = re.compile(" *")
10+
s = r.split("a b c foobar")
11+
print(s)
12+
13+
r = re.compile("x*")
14+
s = r.split("foo")
15+
print(s)
16+
17+
r = re.compile("x*")
18+
s = r.split("axbc")
19+
print(s)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
['a b c foobar']
2+
['foo']
3+
['axbc']

0 commit comments

Comments
 (0)