[pypy-svn] r64494 - in pypy/branch/pyjitpl5-simplify/pypy/rpython/ootypesystem: . test

antocuni at codespeak.net antocuni at codespeak.net
Tue Apr 21 12:01:23 CEST 2009


Author: antocuni
Date: Tue Apr 21 12:01:23 2009
New Revision: 64494

Modified:
   pypy/branch/pyjitpl5-simplify/pypy/rpython/ootypesystem/ootype.py
   pypy/branch/pyjitpl5-simplify/pypy/rpython/ootypesystem/test/test_ootype.py
Log:
(arigo, antocuni) make sure it is possible to cast from Object to Class


Modified: pypy/branch/pyjitpl5-simplify/pypy/rpython/ootypesystem/ootype.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/rpython/ootypesystem/ootype.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/rpython/ootypesystem/ootype.py	Tue Apr 21 12:01:23 2009
@@ -883,13 +883,11 @@
             return self
         elif isinstance(EXPECTED_TYPE, Instance):
             return oodowncast(EXPECTED_TYPE, self.obj)
-        elif isinstance(EXPECTED_TYPE, SpecializableType):
+        else:
             T = typeOf(self.obj)
             if T != EXPECTED_TYPE:
                 raise RuntimeError("Invalid cast: %s --> %s" % (T, EXPECTED_TYPE))
             return self.obj
-        else:
-            assert False, 'to be implemented'
 
 
 class _class(object):

Modified: pypy/branch/pyjitpl5-simplify/pypy/rpython/ootypesystem/test/test_ootype.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/rpython/ootypesystem/test/test_ootype.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/rpython/ootypesystem/test/test_ootype.py	Tue Apr 21 12:01:23 2009
@@ -614,6 +614,13 @@
     obj1 = cast_to_object(a)
     assert NULL != obj1
     assert obj1 != NULL
+
+def test_cast_object_class():
+    A = Instance("Foo", ROOT)
+    cls = runtimeClass(A)
+    obj = cast_to_object(cls)
+    cls2 = cast_from_object(Class, obj)
+    assert cls is cls2
     
 def test_object_ooidentityhash():
     A = Instance("Foo", ROOT)



More information about the Pypy-commit mailing list