tests/float: Add tests for hashing float and complex numbers.

This commit is contained in:
Damien George 2017-04-04 12:14:34 +10:00
parent 19f2e47d59
commit 677fb31015
2 changed files with 26 additions and 0 deletions

View File

@ -0,0 +1,22 @@
# test builtin hash function with float args
# these should hash to an integer with a specific value
for val in (
'0.0',
'1.0',
'2.0',
'-12.0',
'12345.0',
):
print(val, hash(float(val)))
# just check that these values are hashable
for val in (
'0.1',
'-0.1',
'10.3',
'inf',
'-inf',
'nan',
):
print(val, type(hash(float(val))))

View File

@ -41,6 +41,10 @@ print(1j == 1j)
print(abs(1j))
print("%.5g" % abs(1j + 2))
# builtin hash
print(hash(1 + 0j))
print(type(hash(1j)))
# float on lhs should delegate to complex
print(1.2 + 3j)