Amaury Forgeot d'Arc avatar Amaury Forgeot d'Arc committed 7be4735 Merge

Merged in kostialopuhin/pypy-fix1180 (pull request #70). Thanks!

Comments (0)

Files changed (4)

Add a comment to this file

lib-python/2.7/test/test_bool.py

File contents unchanged.

pypy/objspace/std/boolobject.py

 from pypy.rlib.rbigint import rbigint
 from pypy.rlib.rarithmetic import r_uint
 from pypy.interpreter.error import OperationError
+from pypy.objspace.std import newformat
 from pypy.objspace.std.model import registerimplementation, W_Object
 from pypy.objspace.std.register_all import register_all
 from pypy.objspace.std.intobject import W_IntObject
 
 str__Bool = repr__Bool
 
+def format__Bool_ANY(space, w_bool, w_format_spec):
+    return newformat.run_formatter(
+            space, w_format_spec, "format_int_or_long", w_bool,
+            newformat.INT_KIND)
+
 register_all(vars())
Add a comment to this file

pypy/objspace/std/newformat.py

File contents unchanged.

pypy/objspace/std/test/test_newformat.py

         assert self.s("{!r}").format(x()) == self.s("32")
 
 
+class AppTestBoolFormat:
+
+    def test_str_format(self):
+        assert format(False) == "False"
+        assert format(True) == "True"
+        assert "{0}".format(True) == "True"
+        assert "{0}".format(False) == "False"
+        assert "{0} or {1}".format(True, False) == "True or False"
+        assert "{} or {}".format(True, False) == "True or False"
+
+    def test_int_delegation_format(self):
+        assert "{:f}".format(True) == "1.000000"
+        assert "{:05d}".format(False) == "00000"
+        assert "{:g}".format(True) == "1"
+
+
+
 class BaseIntegralFormattingTest:
 
     def test_simple(self):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.