[pypy-svn] r68333 - in pypy/trunk/pypy/rpython: . test

arigo at codespeak.net arigo at codespeak.net
Mon Oct 12 15:23:59 CEST 2009


Author: arigo
Date: Mon Oct 12 15:23:57 2009
New Revision: 68333

Modified:
   pypy/trunk/pypy/rpython/rfloat.py
   pypy/trunk/pypy/rpython/test/test_rdict.py
Log:
Test and fix.


Modified: pypy/trunk/pypy/rpython/rfloat.py
==============================================================================
--- pypy/trunk/pypy/rpython/rfloat.py	(original)
+++ pypy/trunk/pypy/rpython/rfloat.py	Mon Oct 12 15:23:57 2009
@@ -152,12 +152,13 @@
     This should be special-cased in W_FloatObject.
     In the low-level case, floats cannot be used with ints in dicts, anyway.
     """
+    from pypy.rlib.rarithmetic import intmask
     v, expo = math.frexp(f)
     v *= TAKE_NEXT
     hipart = int(v)
     v = (v - float(hipart)) * TAKE_NEXT
     x = hipart + int(v) + (expo << 15)
-    return x
+    return intmask(x)
 #
 # _________________________ Conversions _________________________
 

Modified: pypy/trunk/pypy/rpython/test/test_rdict.py
==============================================================================
--- pypy/trunk/pypy/rpython/test/test_rdict.py	(original)
+++ pypy/trunk/pypy/rpython/test/test_rdict.py	Mon Oct 12 15:23:57 2009
@@ -556,6 +556,14 @@
             return d['a']
         assert self.interpret(func, []) == 42
 
+    def test_dict_of_floats(self):
+        d = {3.0: 42, 3.1: 43, 3.2: 44, 3.3: 45, 3.4: 46}
+        def fn(f):
+            return d[f]
+
+        res = self.interpret(fn, [3.0])
+        assert res == 42
+
 
 class TestLLtype(BaseTestRdict, LLRtypeMixin):
     def test_dict_but_not_with_char_keys(self):



More information about the Pypy-commit mailing list