[pypy-svn] r13961 - in pypy/dist/pypy/rpython: . test
tismer at codespeak.net
tismer at codespeak.net
Sun Jun 26 16:06:13 CEST 2005
Author: tismer
Date: Sun Jun 26 16:06:12 2005
New Revision: 13961
Modified:
pypy/dist/pypy/rpython/rstr.py
pypy/dist/pypy/rpython/test/test_rstr.py
Log:
checking that replace really gets char args
Modified: pypy/dist/pypy/rpython/rstr.py
==============================================================================
--- pypy/dist/pypy/rpython/rstr.py (original)
+++ pypy/dist/pypy/rpython/rstr.py Sun Jun 26 16:06:12 2005
@@ -123,6 +123,8 @@
return hop.gendirectcall(ll_split_chr, c, v_str, v_chr)
def rtype_method_replace(_, hop):
+ if not (hop.args_r[1] == char_repr and hop.args_r[2] == char_repr):
+ raise TyperError, 'replace only works for char args'
v_str, v_c1, v_c2 = hop.inputargs(string_repr, char_repr, char_repr)
return hop.gendirectcall(ll_replace_chr_chr, v_str, v_c1, v_c2)
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 Sun Jun 26 16:06:12 2005
@@ -1,7 +1,7 @@
from pypy.translator.translator import Translator
from pypy.rpython.lltype import *
from pypy.rpython.rstr import parse_fmt_string
-from pypy.rpython.rtyper import RPythonTyper
+from pypy.rpython.rtyper import RPythonTyper, TyperError
from pypy.rpython.test.test_llinterp import interpret
@@ -322,4 +322,11 @@
assert res == 4
res = interpret(fn, ['c', 'b'])
assert res == 5
-
+ def fn():
+ s = 'abbccc'
+ s = s.replace('a', 'baz')
+ raises (TyperError, interpret, fn, ())
+ def fn():
+ s = 'abbccc'
+ s = s.replace('abb', 'c')
+ raises (TyperError, interpret, fn, ())
More information about the Pypy-commit
mailing list