diff options
| author | Jeff Epler <jepler@gmail.com> | 2024-01-25 09:09:06 -0600 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2025-05-13 12:16:35 +1000 |
| commit | 9032491efd8a63e0b13dbcfb8579cde4791c03af (patch) | |
| tree | 50245b32d8cba4f36c049a7c68cf11ff6606b5aa /tests | |
| parent | f47e214cdcf11c2067936cb4b4e4f9deab73f6fc (diff) | |
py/objstr: Add support for the :_b/o/x specifier in str.format.
This groups non-decimal values by fours, such as bbb_bbbb_bbbb. It also
supports `{:_d}` to use underscore for decimal numbers (grouped in threes).
Use of incorrect ":,b" is not diagnosed.
Thanks to @dpgeorge for the suggestion to reduce code size.
Signed-off-by: Jeff Epler <jepler@gmail.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/basics/string_format.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/basics/string_format.py b/tests/basics/string_format.py index e8600f583..11e7836a7 100644 --- a/tests/basics/string_format.py +++ b/tests/basics/string_format.py @@ -22,7 +22,17 @@ test("{:4o}", 123) test("{:4x}", 123) test("{:4X}", 123) +test("{:4,d}", 1) +test("{:4_d}", 1) +test("{:4_o}", 1) +test("{:4_b}", 1) +test("{:4_x}", 1) + test("{:4,d}", 12345678) +test("{:4_d}", 12345678) +test("{:4_o}", 12345678) +test("{:4_b}", 12345678) +test("{:4_x}", 12345678) test("{:#4b}", 10) test("{:#4o}", 123) |
