Author: Matti Picus <[email protected]>
Branch: pypy-pyarray
Changeset: r66979:5d58d1a25800
Date: 2013-09-17 00:15 +0300
http://bitbucket.org/pypy/pypy/changeset/5d58d1a25800/
Log: add failing test (amaury)
diff --git a/pypy/module/cpyext/test/test_number.py
b/pypy/module/cpyext/test/test_number.py
--- a/pypy/module/cpyext/test/test_number.py
+++ b/pypy/module/cpyext/test/test_number.py
@@ -1,8 +1,6 @@
-from rpython.rtyper.lltypesystem import rffi, lltype
-from pypy.interpreter.error import OperationError
+from rpython.rtyper.lltypesystem import lltype
from pypy.module.cpyext.test.test_api import BaseApiTest
-from pypy.module.cpyext import sequence
-from pypy.module.cpyext.pyobject import PyObject, PyObjectP, from_ref,
make_ref, Py_DecRef
+from pypy.module.cpyext.pyobject import PyObjectP, from_ref, make_ref,
Py_DecRef
class TestIterator(BaseApiTest):
def test_check(self, space, api):
@@ -36,6 +34,24 @@
assert w_l is None
api.PyErr_Clear()
+ def test_coerce(self, space, api):
+ w_obj1 = space.wrap(123)
+ w_obj2 = space.wrap(456.789)
+ pp1 = lltype.malloc(PyObjectP.TO, 1, flavor='raw')
+ pp1[0] = make_ref(space, w_obj1)
+ pp2 = lltype.malloc(PyObjectP.TO, 1, flavor='raw')
+ pp2[0] = make_ref(space, w_obj2)
+ assert api.PyNumber_Coerce(pp1, pp2) == 0
+ assert space.str_w(space.repr(from_ref(space, pp1[0]))) == '123.0'
+ assert space.str_w(space.repr(from_ref(space, pp2[0]))) == '456.789'
+ Py_DecRef(space, pp1[0])
+ Py_DecRef(space, pp2[0])
+ # Yes, decrement twice.
+ Py_DecRef(space, w_obj1)
+ Py_DecRef(space, w_obj2)
+ lltype.free(pp1, flavor='raw')
+ lltype.free(pp2, flavor='raw')
+
def test_number_coerce_ex(self, space, api):
pl = make_ref(space, space.wrap(123))
pf = make_ref(space, space.wrap(42.))
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit