Skip to content

Commit 6ea65ea

Browse files
author
Franziska Geiger
committed
Added test cases
1 parent 06ff7eb commit 6ea65ea

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

graalpython/com.oracle.graal.python.test/src/tests/test_re.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,3 +442,16 @@ def test_escaping(self):
442442

443443
def test_escape(self):
444444
self.assertEqual(re.escape(" ()"), "\\ \\(\\)")
445+
446+
def test_none_value():
447+
path_tokenizer = re.compile(
448+
r"(//?| ==?)|([[]]+)"
449+
).findall
450+
451+
stream = iter([ (special,text)
452+
for (special,text) in path_tokenizer('[]')
453+
if special or text ])
454+
455+
n = next(stream)
456+
assert not n[0]
457+

graalpython/com.oracle.graal.python.test/src/tests/test_string.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,3 +1096,34 @@ def test_strip_with_sep():
10961096
assertRaises(TypeError, 'hello', 'strip', 42, 42)
10971097
assertRaises(TypeError, 'hello', 'lstrip', 42, 42)
10981098
assertRaises(TypeError, 'hello', 'rstrip', 42, 42)
1099+
1100+
class EncodedString(str):
1101+
# unicode string subclass to keep track of the original encoding.
1102+
# 'encoding' is None for unicode strings and the source encoding
1103+
# otherwise
1104+
encoding = None
1105+
1106+
def __deepcopy__(self, memo):
1107+
return self
1108+
1109+
def byteencode(self):
1110+
assert self.encoding is not None
1111+
return self.encode(self.encoding)
1112+
1113+
def utf8encode(self):
1114+
assert self.encoding is None
1115+
return self.encode("UTF-8")
1116+
1117+
@property
1118+
def is_unicode(self):
1119+
return self.encoding is None
1120+
1121+
def contains_surrogates(self):
1122+
return string_contains_surrogates(self)
1123+
1124+
def as_utf8_string(self):
1125+
return bytes_literal(self.utf8encode(), 'utf8')
1126+
1127+
def test_radd():
1128+
val = EncodedString('abc')
1129+
assert 'cde' + val == 'cdeabc'

0 commit comments

Comments
 (0)