[pypy-svn] r14639 - in pypy/dist/pypy/rpython: . test
pedronis at codespeak.net
pedronis at codespeak.net
Wed Jul 13 20:08:36 CEST 2005
Author: pedronis
Date: Wed Jul 13 20:08:33 2005
New Revision: 14639
Modified:
pypy/dist/pypy/rpython/rpbc.py
pypy/dist/pypy/rpython/rspecialcase.py
pypy/dist/pypy/rpython/test/test_rpbc.py
pypy/dist/pypy/rpython/test/test_rspecialcase.py
Log:
implemented call_specialcase(override:ignore). Conversion from NoneFrozePBCRepr to other reprs.
Modified: pypy/dist/pypy/rpython/rpbc.py
==============================================================================
--- pypy/dist/pypy/rpython/rpbc.py (original)
+++ pypy/dist/pypy/rpython/rpbc.py Wed Jul 13 20:08:33 2005
@@ -157,6 +157,9 @@
class __extend__(pairtype(NoneFrozenPBCRepr, Repr)):
+ def convert_from_to((_, r_to), v, llops):
+ return inputconst(r_to, None)
+
def rtype_is_((rnone1, robj2), hop):
return rtype_is_None(robj2, rnone1, hop, pos=1)
Modified: pypy/dist/pypy/rpython/rspecialcase.py
==============================================================================
--- pypy/dist/pypy/rpython/rspecialcase.py (original)
+++ pypy/dist/pypy/rpython/rspecialcase.py Wed Jul 13 20:08:33 2005
@@ -2,7 +2,7 @@
from pypy.annotation import model as annmodel
from pypy.objspace.flow.model import Constant
from pypy.rpython import rclass
-from pypy.rpython.rmodel import TyperError
+from pypy.rpython.rmodel import TyperError, inputconst
def rtype_call_specialcase(hop):
@@ -24,3 +24,7 @@
# def rtype_override_XXX to be added later
+
+
+def rtype_override_ignore(hop):
+ return inputconst(hop.r_result, None)
Modified: pypy/dist/pypy/rpython/test/test_rpbc.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_rpbc.py (original)
+++ pypy/dist/pypy/rpython/test/test_rpbc.py Wed Jul 13 20:08:33 2005
@@ -414,3 +414,30 @@
assert res == 9
res = interpret(f, [3])
assert res == 13
+
+def test_conv_from_None():
+ class A(object): pass
+ def none():
+ return None
+
+ def f(i):
+ if i == 1:
+ return none()
+ else:
+ return "ab"
+ res = interpret(f, [1])
+ assert not res
+ res = interpret(f, [0])
+ assert ''.join(res.chars) == "ab"
+
+ def g(i):
+ if i == 1:
+ return none()
+ else:
+ return A()
+ res = interpret(g, [1])
+ assert not res
+ res = interpret(g, [0])
+ assert res.super.typeptr.name[0] == 'A'
+
+
Modified: pypy/dist/pypy/rpython/test/test_rspecialcase.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_rspecialcase.py (original)
+++ pypy/dist/pypy/rpython/test/test_rspecialcase.py Wed Jul 13 20:08:33 2005
@@ -4,4 +4,19 @@
from pypy.translator.ann_override import PyPyAnnotatorPolicy
-# nothing to test here at the moment
+def test_override_ignore():
+ def f():
+ pass
+ f._annspecialcase_ = "override:ignore"
+ def g(i):
+ if i == 1:
+ return "ab"
+ else:
+ return f()
+
+ res = interpret(g, [0])
+ assert not res
+ res = interpret(g, [1])
+ assert ''.join(res.chars) == "ab"
+
+
More information about the Pypy-commit
mailing list