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

afa at codespeak.net afa at codespeak.net
Tue Oct 5 19:31:41 CEST 2010


Author: afa
Date: Tue Oct  5 19:31:39 2010
New Revision: 77623

Modified:
   pypy/branch/fast-forward/pypy/objspace/std/strutil.py
   pypy/branch/fast-forward/pypy/objspace/std/test/test_floatobject.py
Log:
Add float('infinity')


Modified: pypy/branch/fast-forward/pypy/objspace/std/strutil.py
==============================================================================
--- pypy/branch/fast-forward/pypy/objspace/std/strutil.py	(original)
+++ pypy/branch/fast-forward/pypy/objspace/std/strutil.py	Tue Oct  5 19:31:39 2010
@@ -178,10 +178,12 @@
 
     
     low = s.lower()
-    if low == "-inf":
+    if low == "-inf" or low == "-infinity":
         return -INFINITY
     elif low == "inf" or low == "+inf":
         return INFINITY
+    elif low == "infinity" or low == "+infinity":
+        return INFINITY
     elif low == "nan" or low == "-nan" or low == "+nan":
         return NAN
 

Modified: pypy/branch/fast-forward/pypy/objspace/std/test/test_floatobject.py
==============================================================================
--- pypy/branch/fast-forward/pypy/objspace/std/test/test_floatobject.py	(original)
+++ pypy/branch/fast-forward/pypy/objspace/std/test/test_floatobject.py	Tue Oct  5 19:31:39 2010
@@ -98,6 +98,9 @@
         assert float("-INf") == -inf
         assert str(inf) == "inf"
         assert str(-inf) == "-inf"
+        assert str(float("infinity")) == 'inf'
+        assert str(float("+infinity")) == 'inf'
+        assert str(float("-infinity")) == '-inf'
         assert str(float("nan")) == "nan"
         assert str(float("-nAn")) == "nan"
         assert repr(inf) == "inf"



More information about the Pypy-commit mailing list