add a test for the unicode case

parent 12a7226bdbaa
Pipeline #18786 passed with stage
in 7 minutes and 21 seconds
......@@ -144,11 +144,11 @@ class TestString(BaseTestPyPyC):
jump(..., descr=...)
""")
def test_remove_duplicate_method_calls(self):
def test_remove_duplicate_method_calls_bytes(self):
def main(n):
lst = []
for i in range(n):
s = 'Hello %d' % i
s = b'Hello %d' % i
t = s.lower() # ID: callone
u = s.lower() # ID: calltwo
lst.append(t)
......@@ -164,6 +164,30 @@ class TestString(BaseTestPyPyC):
''')
assert loop.match_by_id('calltwo', '') # nothing
def test_remove_duplicate_method_calls_unicode(self):
def main(n):
lst = []
for i in range(n):
s = u'H\xe4llo %d' % i
t = s.lower() # ID: callone
u = s.lower() # ID: calltwo
lst.append(t)
lst.append(u)
return len(','.join(lst))
log = self.run(main, [1000])
assert log.result == main(1000)
loops = log.loops_by_filename(self.filepath)
loop, = loops
assert loop.match_by_id('callone', '''
i136 = strlen(p131)
i137 = int_eq(i135, i136)
guard_false(i137, descr=...)
p139 = call_r(ConstClass(_lower_unicode), p131, descr=...)
guard_no_exception(descr=...)
guard_nonnull(p139, descr=...)
''')
assert loop.match_by_id('calltwo', '') # nothing
def test_move_method_call_out_of_loop(self):
def main(n):
lst = []
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment