[pypy-svn] r53658 - pypy/branch/jit-hotpath/pypy/jit/rainbow/test

antocuni at codespeak.net antocuni at codespeak.net
Thu Apr 10 16:26:21 CEST 2008


Author: antocuni
Date: Thu Apr 10 16:26:19 2008
New Revision: 53658

Modified:
   pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_interpreter.py
Log:
port this test to ootype, it passes out of the box :-)



Modified: pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_interpreter.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_interpreter.py	(original)
+++ pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_interpreter.py	Thu Apr 10 16:26:19 2008
@@ -1237,15 +1237,19 @@
         res = self.interpret(f, [ord('b'), 0], [], policy=P_NOVIRTUAL)
         assert res == 1
 
-    def test_self_referential_structures(self):
+    def _make_self_referential_type(self):
         S = lltype.GcForwardReference()
-        S.become(lltype.GcStruct('s',
-                                 ('ps', lltype.Ptr(S))))
+        S.become(lltype.GcStruct('s', ('ps', lltype.Ptr(S))))
+        return S
+
+    def test_self_referential_structures(self):
+        S = self._make_self_referential_type()
+        malloc = self.malloc
 
         def f(x):
-            s = lltype.malloc(S)
+            s = malloc(S)
             if x:
-                s.ps = lltype.malloc(S)
+                s.ps = malloc(S)
             return s
         def count_depth(s):
             x = 0
@@ -2216,6 +2220,11 @@
     def malloc_immortal(T):
         return ootype.new(T)
 
+    def _make_self_referential_type(self):
+        S = ootype.Instance('s', ootype.ROOT, {})
+        S._add_fields({'ps': S})
+        return S
+
     def translate_insns(self, insns):
         replace = {
             'getfield': 'oogetfield',
@@ -2333,4 +2342,3 @@
     test_array_of_voids = _skip
     test_compile_time_const_tuple = _skip    # needs vdict
     test_green_char_at_merge = _skip
-    test_self_referential_structures = _skip



More information about the Pypy-commit mailing list