Author: Wim Lavrijsen <wlavrij...@lbl.gov> Branch: reflex-support Changeset: r72457:6fd647e28232 Date: 2014-07-16 12:16 -0700 http://bitbucket.org/pypy/pypy/changeset/6fd647e28232/
Log: updates for handling of null-ptrs and enums diff --git a/pypy/module/cppyy/test/test_datatypes.py b/pypy/module/cppyy/test/test_datatypes.py --- a/pypy/module/cppyy/test/test_datatypes.py +++ b/pypy/module/cppyy/test/test_datatypes.py @@ -391,6 +391,15 @@ CppyyTestData.s_ldouble = math.pi assert c.s_ldouble == math.pi + # enum types + assert raises(AttributeError, getattr, CppyyTestData, 'kBanana') + if self.capi_identity == 'Cling': # detailed enum support only in Cling + assert raises(TypeError, setattr, CppyyTestData, 'kLots', 42) + c.s_enum = CppyyTestData.kLots + assert CppyyTestData.s_enum == CppyyTestData.kLots + CppyyTestData.s_enum = CppyyTestData.kNothing + assert c.s_enum == CppyyTestData.kNothing + c.__destruct__() def test07_range_access(self): @@ -772,8 +781,13 @@ def address_equality_test(a, b): assert cppyy.addressof(a) == cppyy.addressof(b) b2 = cppyy.bind_object(a, CppyyTestData) + b.m_int = 888 + assert b.m_int == 888 + assert b == b2 and b.m_int == b2.m_int assert b is b2 # memory regulator recycles b3 = cppyy.bind_object(cppyy.addressof(a), CppyyTestData) + assert b3.m_int == 888 + assert b == b3 and b.m_int == b3.m_int assert b is b3 # likewise address_equality_test(c.m_voidp, c2) diff --git a/pypy/module/cppyy/test/test_fragile.py b/pypy/module/cppyy/test/test_fragile.py --- a/pypy/module/cppyy/test/test_fragile.py +++ b/pypy/module/cppyy/test/test_fragile.py @@ -70,7 +70,7 @@ assert fragile.D().check() == ord('D') d = fragile.D() - raises(TypeError, d.overload, None) + raises(TypeError, d.overload, 1.) raises(TypeError, d.overload, None, None, None) d.overload('a') @@ -88,8 +88,10 @@ assert fragile.E().check() == ord('E') e = fragile.E() - raises(TypeError, e.overload, None) - raises(TypeError, getattr, e, 'm_pp_no_such') + # TODO: figure out the desired behavior here; right now, an opaque + # pointer is returned to allow passing back to C++ code + #raises(TypeError, e.overload, None) + #raises(TypeError, getattr, e, 'm_pp_no_such') def test05_wrong_arg_addressof(self): """Test addressof() error reporting""" @@ -184,17 +186,17 @@ assert "TypeError: wrong number of arguments" in str(e) try: - d.overload(None) # raises TypeError + d.overload(1.) # raises TypeError assert 0 except TypeError, e: assert "fragile::D::overload()" in str(e) assert "TypeError: wrong number of arguments" in str(e) assert "fragile::D::overload(fragile::no_such_class*)" in str(e) - assert "TypeError: no converter available for 'fragile::no_such_class*'" in str(e) + # assert "TypeError: no converter available for 'fragile::no_such_class*'" in str(e) assert "fragile::D::overload(char, int)" in str(e) - assert "TypeError: expected string, got NoneType object" in str(e) + assert "TypeError: expected string, got float object" in str(e) assert "fragile::D::overload(int, fragile::no_such_class*)" in str(e) - assert "TypeError: expected integer, got NoneType object" in str(e) + assert "TypeError: expected integer, got float object" in str(e) j = fragile.J() assert fragile.J.method1.__doc__ == j.method1.__doc__ _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit