Commits

wlav committed 6fd647e

updates for handling of null-ptrs and enums

Comments (0)

Files changed (2)

pypy/module/cppyy/test/test_datatypes.py

         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):
         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)

pypy/module/cppyy/test/test_fragile.py

         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')
         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"""
             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__