[pypy-svn] pypy fast-forward: Be sure to add .0 at the end of repr(1.0),

amauryfa commits-noreply at bitbucket.org
Tue Jan 4 09:07:02 CET 2011


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: fast-forward
Changeset: r40372:3e445a90386f
Date: 2011-01-04 09:09 +0100
http://bitbucket.org/pypy/pypy/changeset/3e445a90386f/

Log:	Be sure to add .0 at the end of repr(1.0), even in translated
	pypy...

diff --git a/pypy/rlib/rarithmetic.py b/pypy/rlib/rarithmetic.py
--- a/pypy/rlib/rarithmetic.py
+++ b/pypy/rlib/rarithmetic.py
@@ -579,6 +579,11 @@
         fmt = "%%%s.%d%s" % (alt, precision, code)
     s = fmt % (x,)
 
+    return s
+
+def formatd(x, code, precision, flags=0):
+    s = _formatd(x, code, precision, flags)
+
     if flags & DTSF_ADD_DOT_0:
         # We want float numbers to be recognizable as such,
         # i.e., they should contain a decimal point or an exponent.
@@ -593,8 +598,6 @@
         s = s[:-2]
 
     return s
-def formatd(x, code, precision, flags=0):
-    return _formatd(x, code, precision, flags)
 
 formatd_max_length = 120
 

diff --git a/pypy/rpython/module/test/test_ll_strtod.py b/pypy/rpython/module/test/test_ll_strtod.py
--- a/pypy/rpython/module/test/test_ll_strtod.py
+++ b/pypy/rpython/module/test/test_ll_strtod.py
@@ -5,10 +5,12 @@
 
 class BaseTestStrtod(BaseRtypingTest):    
     def test_formatd(self):
-        def f(y):
-            return rarithmetic.formatd(y, 'f', 2)
+        for flags in [0,
+                      rarithmetic.DTSF_ADD_DOT_0]:
+            def f(y):
+                return rarithmetic.formatd(y, 'g', 2, flags)
 
-        assert self.ll_to_string(self.interpret(f, [3.0])) == f(3.0)
+            assert self.ll_to_string(self.interpret(f, [3.0])) == f(3.0)
 
     def test_parts_to_float(self):
         from pypy.rpython.annlowlevel import hlstr


More information about the Pypy-commit mailing list