tests: Add boolean-as-integer formatting tests for fixed regression.

As suggested by @dpgeorge in #5538.
This commit is contained in:
Yonatan Goldschmidt 2020-01-22 20:53:54 +01:00 committed by Damien George
parent 35e664d779
commit cb4472df42
3 changed files with 12 additions and 0 deletions

View File

@ -63,6 +63,12 @@ test("{:>20}", "foo")
test("{:^20}", "foo") test("{:^20}", "foo")
test("{:<20}", "foo") test("{:<20}", "foo")
# formatting bool as int
test('{:d}', False)
test('{:20}', False)
test('{:d}', True)
test('{:20}', True)
# nested format specifiers # nested format specifiers
print("{:{}}".format(123, '#>10')) print("{:{}}".format(123, '#>10'))
print("{:{}{}{}}".format(123, '#', '>', '10')) print("{:{}{}{}}".format(123, '#', '>', '10'))

View File

@ -40,6 +40,9 @@ print("%c" % 'a')
print("%10s" % 'abc') print("%10s" % 'abc')
print("%-10s" % 'abc') print("%-10s" % 'abc')
print('%c' % False)
print('%c' % True)
# Should be able to print dicts; in this case they aren't used # Should be able to print dicts; in this case they aren't used
# to lookup keywords in formats like %(foo)s # to lookup keywords in formats like %(foo)s
print('%s' % {}) print('%s' % {})

View File

@ -24,6 +24,9 @@ test("{:06e}", float("inf"))
test("{:06e}", float("-inf")) test("{:06e}", float("-inf"))
test("{:06e}", float("nan")) test("{:06e}", float("nan"))
test('{:f}', False)
test('{:f}', True)
# The following fails right now # The following fails right now
#test("{:10.1}", 0.0) #test("{:10.1}", 0.0)