[pypy-svn] r70850 - in pypy/branch/stringbuilder2/pypy/rpython: lltypesystem memory/test

arigo at codespeak.net arigo at codespeak.net
Mon Jan 25 19:21:00 CET 2010


Author: arigo
Date: Mon Jan 25 19:20:59 2010
New Revision: 70850

Modified:
   pypy/branch/stringbuilder2/pypy/rpython/lltypesystem/rbuilder.py
   pypy/branch/stringbuilder2/pypy/rpython/memory/test/test_transformed_gc.py
Log:
Test and fix for test_transformed_gc.  Still not actually
linked to the GC.


Modified: pypy/branch/stringbuilder2/pypy/rpython/lltypesystem/rbuilder.py
==============================================================================
--- pypy/branch/stringbuilder2/pypy/rpython/lltypesystem/rbuilder.py	(original)
+++ pypy/branch/stringbuilder2/pypy/rpython/lltypesystem/rbuilder.py	Mon Jan 25 19:20:59 2010
@@ -102,6 +102,7 @@
     @staticmethod
     def ll_build(ll_builder):
         final_size = ll_builder.used
+        assert final_size >= 0
         return rgc.ll_shrink_array(ll_builder.buf, final_size)
 
 class StringBuilderRepr(BaseStringBuilderRepr):

Modified: pypy/branch/stringbuilder2/pypy/rpython/memory/test/test_transformed_gc.py
==============================================================================
--- pypy/branch/stringbuilder2/pypy/rpython/memory/test/test_transformed_gc.py	(original)
+++ pypy/branch/stringbuilder2/pypy/rpython/memory/test/test_transformed_gc.py	Mon Jan 25 19:20:59 2010
@@ -631,22 +631,25 @@
         run = self.runner("malloc_nonmovable_fixsize")
         assert run([]) == int(self.GC_CANNOT_MALLOC_NONMOVABLE)
 
-    def define_resizable_buffer(cls):
+    def define_shrink_array(cls):
         from pypy.rpython.lltypesystem.rstr import STR
-        from pypy.rpython.annlowlevel import hlstr
 
         def f():
-            ptr = rgc.resizable_buffer_of_shape(STR, 2)
-            ptr.chars[0] = 'a'
-            ptr = rgc.resize_buffer(ptr, 1, 200)
-            ptr.chars[1] = 'b'
-            return hlstr(rgc.finish_building_buffer(ptr, 2)) == "ab"
-
+            ptr = lltype.malloc(STR, 3)
+            ptr.hash = 0x62
+            ptr.chars[0] = 'A'
+            ptr.chars[1] = 'B'
+            ptr.chars[2] = 'C'
+            ptr = rgc.ll_shrink_array(ptr, 2)
+            return ( ord(ptr.chars[0])       +
+                    (ord(ptr.chars[1]) << 8) +
+                    (len(ptr.chars)   << 16) +
+                    (ptr.hash         << 24))
         return f
 
-    def test_resizable_buffer(self):
-        run = self.runner("resizable_buffer")
-        assert run([]) == 1
+    def test_shrink_array(self):
+        run = self.runner("shrink_array")
+        assert run([]) == 0x62024241
 
     def define_string_builder_over_allocation(cls):
         import gc



More information about the Pypy-commit mailing list