[pypy-svn] r71453 - pypy/branch/gc-better-hash/pypy/translator/c/test

arigo at codespeak.net arigo at codespeak.net
Wed Feb 24 17:11:39 CET 2010


Author: arigo
Date: Wed Feb 24 17:11:38 2010
New Revision: 71453

Modified:
   pypy/branch/gc-better-hash/pypy/translator/c/test/test_newgc.py
Log:
Write a failing test that shows the issue -- obvious right now because the
hash of nursery objects is fixed to 0, but fails on trunk too.  (Indeed,
even on trunk all 200 objects end up with exactly the same hash.)


Modified: pypy/branch/gc-better-hash/pypy/translator/c/test/test_newgc.py
==============================================================================
--- pypy/branch/gc-better-hash/pypy/translator/c/test/test_newgc.py	(original)
+++ pypy/branch/gc-better-hash/pypy/translator/c/test/test_newgc.py	Wed Feb 24 17:11:38 2010
@@ -1019,6 +1019,29 @@
         res = self.run('string_builder_over_allocation')
         assert res[1000] == 'y'
 
+    def define_nursery_hash_base(cls):
+        from pypy.rlib.objectmodel import compute_identity_hash
+        class A:
+            pass
+        def fn():
+            objects = []
+            hashes = []
+            for i in range(200):
+                rgc.collect(0)     # nursery-only collection, if possible
+                obj = A()
+                objects.append(obj)
+                hashes.append(compute_identity_hash(obj))
+            unique = {}
+            for i in range(len(objects)):
+                unique[hashes[i]] = None
+            return len(unique)
+        return fn
+
+    def test_nursery_hash_base(self):
+        res = self.run('nursery_hash_base')
+        assert res >= 195
+
+
 class TestGenerationalGC(TestSemiSpaceGC):
     gcpolicy = "generation"
     should_be_moving = True



More information about the Pypy-commit mailing list