[pypy-svn] r70876 - pypy/branch/stringbuilder2/pypy/translator/c/test

arigo at codespeak.net arigo at codespeak.net
Tue Jan 26 13:11:53 CET 2010


Author: arigo
Date: Tue Jan 26 13:11:52 2010
New Revision: 70876

Modified:
   pypy/branch/stringbuilder2/pypy/translator/c/test/test_boehm.py
   pypy/branch/stringbuilder2/pypy/translator/c/test/test_newgc.py
Log:
Fix these tests to check for rgc.ll_shrink_array().


Modified: pypy/branch/stringbuilder2/pypy/translator/c/test/test_boehm.py
==============================================================================
--- pypy/branch/stringbuilder2/pypy/translator/c/test/test_boehm.py	(original)
+++ pypy/branch/stringbuilder2/pypy/translator/c/test/test_boehm.py	Tue Jan 26 13:11:52 2010
@@ -411,20 +411,25 @@
         run = self.getcompiled(func)
         assert run() == 0
 
-    def test_resizable_buffer(self):
+    def test_shrink_array(self):
         from pypy.rpython.lltypesystem.rstr import STR
-        from pypy.rpython.annlowlevel import hlstr
         from pypy.rlib import rgc
 
         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] = '0'
+            ptr.chars[1] = 'B'
+            ptr.chars[2] = 'C'
+            ptr2 = rgc.ll_shrink_array(ptr, 2)
+            return ((ptr == ptr2)             +
+                     ord(ptr2.chars[0])       +
+                    (ord(ptr2.chars[1]) << 8) +
+                    (len(ptr2.chars)   << 16) +
+                    (ptr2.hash         << 24))
 
         run = self.getcompiled(f)
-        assert run() == True
+        assert run() == 0x62024230
 
     def test_assume_young_pointers_nop(self):
         S = lltype.GcStruct('S', ('x', lltype.Signed))

Modified: pypy/branch/stringbuilder2/pypy/translator/c/test/test_newgc.py
==============================================================================
--- pypy/branch/stringbuilder2/pypy/translator/c/test/test_newgc.py	(original)
+++ pypy/branch/stringbuilder2/pypy/translator/c/test/test_newgc.py	Tue Jan 26 13:11:52 2010
@@ -20,6 +20,7 @@
     taggedpointers = False
     GC_CAN_MOVE = False
     GC_CANNOT_MALLOC_NONMOVABLE = False
+    GC_CAN_SHRINK_ARRAY = False
 
     _isolated_func = None
 
@@ -697,19 +698,28 @@
 
     def define_resizable_buffer(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] = '0'
+            ptr.chars[1] = 'B'
+            ptr.chars[2] = 'C'
+            ptr2 = rgc.ll_shrink_array(ptr, 2)
+            return ((ptr == ptr2)             +
+                     ord(ptr2.chars[0])       +
+                    (ord(ptr2.chars[1]) << 8) +
+                    (len(ptr2.chars)   << 16) +
+                    (ptr2.hash         << 24))
         return f
 
     def test_resizable_buffer(self):
-        assert self.run('resizable_buffer')
+        res = self.run('resizable_buffer')
+        if self.GC_CAN_SHRINK_ARRAY:
+            expected = 0x62024231
+        else:
+            expected = 0x62024230
+        assert res == expected
 
     def define_hash_preservation(cls):
         from pypy.rlib.objectmodel import compute_hash
@@ -882,6 +892,7 @@
     should_be_moving = True
     GC_CAN_MOVE = True
     GC_CANNOT_MALLOC_NONMOVABLE = True
+    GC_CAN_SHRINK_ARRAY = True
 
     # for snippets
     large_tests_ok = True
@@ -1029,6 +1040,7 @@
 class TestMarkCompactGC(TestSemiSpaceGC):
     gcpolicy = "markcompact"
     should_be_moving = True
+    GC_CAN_SHRINK_ARRAY = False
 
     def setup_class(cls):
         py.test.skip("Disabled for now")



More information about the Pypy-commit mailing list