[pypy-svn] r28788 - pypy/dist/pypy/rpython/test
arigo at codespeak.net
arigo at codespeak.net
Wed Jun 14 19:38:14 CEST 2006
Author: arigo
Date: Wed Jun 14 19:38:13 2006
New Revision: 28788
Modified:
pypy/dist/pypy/rpython/test/test_rstr.py
Log:
Some more (passing) tests about corner cases of string methods.
Modified: pypy/dist/pypy/rpython/test/test_rstr.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_rstr.py (original)
+++ pypy/dist/pypy/rpython/test/test_rstr.py Wed Jun 14 19:38:13 2006
@@ -210,21 +210,21 @@
def test_startswith(self):
def fn(i, j):
- s1 = ['one', 'two']
- s2 = ['one', 'two', 'o', 'on', 'ne', 'e', 'twos', 'foobar', 'fortytwo']
+ s1 = ['', 'one', 'two']
+ s2 = ['', 'one', 'two', 'o', 'on', 'ne', 'e', 'twos', 'foobar', 'fortytwo']
return s1[i].startswith(s2[j])
- for i in range(2):
- for j in range(9):
+ for i in range(3):
+ for j in range(10):
res = self.interpret(fn, [i,j])
assert res is fn(i, j)
def test_endswith(self):
def fn(i, j):
- s1 = ['one', 'two']
- s2 = ['one', 'two', 'o', 'on', 'ne', 'e', 'twos', 'foobar', 'fortytwo']
+ s1 = ['', 'one', 'two']
+ s2 = ['', 'one', 'two', 'o', 'on', 'ne', 'e', 'twos', 'foobar', 'fortytwo']
return s1[i].endswith(s2[j])
- for i in range(2):
- for j in range(9):
+ for i in range(3):
+ for j in range(10):
res = self.interpret(fn, [i,j])
assert res is fn(i, j)
@@ -256,17 +256,17 @@
assert res == fn(i, j)
def test_find_empty_string(self):
- def f():
+ def f(i):
+ assert i >= 0
s = "abc"
x = s.find('')
- x+= s.find('', 1)*10
- x+= s.find('', 2)*100
- x+= s.find('', 3)*1000
- x+= s.find('', 4)*10000
- x+= s.find('', 5)*100000
+ x+= s.find('', i)*10
+ x+= s.find('', i, i)*100
+ x+= s.find('', i, i+1)*1000
return x
- res = self.interpret(f, [])
- assert res == f()
+ for i in range(5):
+ res = self.interpret(f, [i])
+ assert res == f(i)
def test_rfind(self):
def fn():
@@ -275,18 +275,17 @@
assert res == 2 + 2 + 1
def test_rfind_empty_string(self):
- def f():
+ def f(i):
+ assert i >= 0
s = "abc"
- x = s.rfind('', 0 ,0)
- x+= s.rfind('', 0, 1)*10
- x+= s.rfind('', 0, 2)*100
- x+= s.rfind('', 0, 3)*1000
- x+= s.rfind('', 0, 4)*10000
- x+= s.rfind('', 0, 5)*100000
+ x = s.find('')
+ x+= s.find('', i)*10
+ x+= s.find('', i, i)*100
+ x+= s.find('', i, i+1)*1000
return x
- res = self.interpret(f, [])
- assert res == f()
-
+ for i in range(5):
+ res = self.interpret(f, [i])
+ assert res == f(i)
def test_find_char(self):
def fn(ch):
More information about the Pypy-commit
mailing list