[pypy-svn] r28460 - pypy/dist/pypy/rpython/test

antocuni at codespeak.net antocuni at codespeak.net
Wed Jun 7 17:02:33 CEST 2006


Author: antocuni
Date: Wed Jun  7 17:02:33 2006
New Revision: 28460

Modified:
   pypy/dist/pypy/rpython/test/test_rclass.py
   pypy/dist/pypy/rpython/test/tool.py
Log:
A bit of refactoring for reuse the test in the backends.



Modified: pypy/dist/pypy/rpython/test/test_rclass.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_rclass.py	(original)
+++ pypy/dist/pypy/rpython/test/test_rclass.py	Wed Jun  7 17:02:33 2006
@@ -44,12 +44,7 @@
             x = EmptyBase()
             return x
         res = self.interpret(dummyfn, [])
-        T = typeOf(res)
-        if self.type_system == "lltype":
-            assert isinstance(T, Ptr) and isinstance(T.TO, GcStruct)
-        else:
-            assert isinstance(T, ootype.Instance)
-
+        assert self.is_of_instance_type(res)
 
     def test_classattr(self):
         def dummyfn():

Modified: pypy/dist/pypy/rpython/test/tool.py
==============================================================================
--- pypy/dist/pypy/rpython/test/tool.py	(original)
+++ pypy/dist/pypy/rpython/test/tool.py	Wed Jun  7 17:02:33 2006
@@ -1,5 +1,6 @@
 import py
 from pypy.rpython.ootypesystem import ootype
+from pypy.rpython.lltypesystem import lltype
 from pypy.rpython.test.test_llinterp import interpret, interpret_raises
 
 class BaseRtypingTest(object):
@@ -43,6 +44,10 @@
                 return attr
         raise AttributeError()
 
+    def is_of_instance_type(self, val):
+        T = lltype.typeOf(val)
+        return isinstance(T, lltype.Ptr) and isinstance(T.TO, lltype.GcStruct)
+
 
 class OORtypeMixin(object):
     type_system = 'ootype'
@@ -66,3 +71,7 @@
     def read_attr(self, value, attr):
         value = ootype.oodowncast(ootype.dynamicType(value), value)
         return getattr(value, "o" + attr)
+
+    def is_of_instance_type(self, val):
+        T = lltype.typeOf(val)
+        return isinstance(T, ootype.Instance)



More information about the Pypy-commit mailing list