[pypy-svn] r78711 - in pypy/branch/fast-forward/pypy/objspace/std: . test

afa at codespeak.net afa at codespeak.net
Thu Nov 4 23:50:32 CET 2010


Author: afa
Date: Thu Nov  4 23:50:30 2010
New Revision: 78711

Modified:
   pypy/branch/fast-forward/pypy/objspace/std/formatting.py
   pypy/branch/fast-forward/pypy/objspace/std/test/test_stringformat.py
Log:
'%F' % nan == 'NAN'


Modified: pypy/branch/fast-forward/pypy/objspace/std/formatting.py
==============================================================================
--- pypy/branch/fast-forward/pypy/objspace/std/formatting.py	(original)
+++ pypy/branch/fast-forward/pypy/objspace/std/formatting.py	Thu Nov  4 23:50:30 2010
@@ -117,12 +117,21 @@
         space = self.space
         x = space.float_w(maybe_float(space, w_value))
         if isnan(x):
-            r = 'nan'
+            if char in 'EFG':
+                r = 'NAN'
+            else:
+                r = 'nan'
         elif isinf(x):
             if x < 0:
-                r = '-inf'
+                if char in 'EFG':
+                    r = '-INF'
+                else:
+                    r = '-inf'
             else:
-                r = 'inf'
+                if char in 'EFG':
+                    r = 'INF'
+                else:
+                    r = 'inf'
         else:
             prec = self.prec
             if prec < 0:

Modified: pypy/branch/fast-forward/pypy/objspace/std/test/test_stringformat.py
==============================================================================
--- pypy/branch/fast-forward/pypy/objspace/std/test/test_stringformat.py	(original)
+++ pypy/branch/fast-forward/pypy/objspace/std/test/test_stringformat.py	Thu Nov  4 23:50:30 2010
@@ -253,10 +253,15 @@
     def test_subnormal(self):
         inf = 1e300 * 1e300
         assert "%f" % (inf,) == 'inf'
+        assert "%E" % (inf,) == 'INF'
         assert "%f" % (-inf,) == '-inf'
+        assert "%F" % (-inf,) == '-INF'
         nan = inf / inf
         assert "%f" % (nan,) == 'nan'
         assert "%f" % (-nan,) == 'nan'
+        assert "%E" % (nan,) == 'NAN'
+        assert "%F" % (nan,) == 'NAN'
+        assert "%G" % (nan,) == 'NAN'
 
 class AppTestUnicodeObject:
     def test_unicode_convert(self):



More information about the Pypy-commit mailing list