[pypy-svn] r15028 - pypy/dist/pypy/objspace/std/test

arigo at codespeak.net arigo at codespeak.net
Mon Jul 25 16:03:03 CEST 2005


Author: arigo
Date: Mon Jul 25 16:02:46 2005
New Revision: 15028

Modified:
   pypy/dist/pypy/objspace/std/test/test_longobject.py
Log:
Tests for hash(long).


Modified: pypy/dist/pypy/objspace/std/test/test_longobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/test/test_longobject.py	(original)
+++ pypy/dist/pypy/objspace/std/test/test_longobject.py	Mon Jul 25 16:02:46 2005
@@ -384,3 +384,12 @@
         assert 0xAAAAAAAAL | 0x555555555L == 0x5FFFFFFFFL
         assert 0xAAAAAAAAL & 0x555555555L == 0x000000000L
         assert 0xAAAAAAAAL ^ 0x555555555L == 0x5FFFFFFFFL
+
+    def test_hash(self):
+        # ints have the same hash as equal longs
+        for i in range(-4, 14):
+            assert hash(i) == hash(long(i))
+        # might check too much -- it's ok to change the hashing algorithm
+        assert hash(123456789L) == 123456789
+        assert hash(1234567890123456789L) == -1895067127
+        assert hash(-3**333) == -368329968



More information about the Pypy-commit mailing list