[pypy-svn] r61446 - in pypy/trunk/pypy/objspace/std: . test

afa at codespeak.net afa at codespeak.net
Thu Jan 29 14:09:24 CET 2009


Author: afa
Date: Thu Jan 29 14:09:24 2009
New Revision: 61446

Modified:
   pypy/trunk/pypy/objspace/std/formatting.py
   pypy/trunk/pypy/objspace/std/test/test_stringformat.py
Log:
'%f' did not make the distinction between positive and negative infinities
Test and fix.


Modified: pypy/trunk/pypy/objspace/std/formatting.py
==============================================================================
--- pypy/trunk/pypy/objspace/std/formatting.py	(original)
+++ pypy/trunk/pypy/objspace/std/formatting.py	Thu Jan 29 14:09:24 2009
@@ -111,7 +111,10 @@
         if isnan(x):
             r = 'nan'
         elif isinf(x):
-            r = 'inf'
+            if x < 0:
+                r = '-inf'
+            else:
+                r = 'inf'
         else:
             prec = self.prec
             if prec < 0:

Modified: pypy/trunk/pypy/objspace/std/test/test_stringformat.py
==============================================================================
--- pypy/trunk/pypy/objspace/std/test/test_stringformat.py	(original)
+++ pypy/trunk/pypy/objspace/std/test/test_stringformat.py	Thu Jan 29 14:09:24 2009
@@ -196,6 +196,14 @@
         raises(OverflowError, f, "%.70f", 2.0)
         raises(OverflowError, f, "%.110g", 2.0)
 
+    def test_subnormal(self):
+        inf = 1e300 * 1e300
+        assert "%f" % (inf,) == 'inf'
+        assert "%f" % (-inf,) == '-inf'
+        nan = inf / inf
+        assert "%f" % (nan,) == 'nan'
+        assert "%f" % (-nan,) == 'nan'
+
 class AppTestUnicodeObject:
     def test_unicode_convert(self):
         assert isinstance("%s" % (u"x"), unicode)



More information about the Pypy-commit mailing list