tests: Add some tests for bigint hash, float hash and float parsing.

Following outcome of recent fuzz testing and sanitizing by @jepler.
pull/3798/head
Damien George 2018-05-21 13:05:40 +10:00
rodzic 95e43efc99
commit 1ad0013dec
3 zmienionych plików z 11 dodań i 0 usunięć

Wyświetl plik

@ -8,3 +8,6 @@ class F:
def __hash__(self): def __hash__(self):
return 1 << 70 | 1 return 1 << 70 | 1
print(hash(F()) != 0) print(hash(F()) != 0)
# this had a particular error with internal integer arithmetic of hash function
print(hash(6699999999999999999999999999999999999999999999999999999999999999999999) != 0)

Wyświetl plik

@ -3,6 +3,7 @@
# these should hash to an integer with a specific value # these should hash to an integer with a specific value
for val in ( for val in (
'0.0', '0.0',
'-0.0',
'1.0', '1.0',
'2.0', '2.0',
'-12.0', '-12.0',
@ -15,6 +16,7 @@ for val in (
'0.1', '0.1',
'-0.1', '-0.1',
'10.3', '10.3',
'0.4e3',
'1e16', '1e16',
'inf', 'inf',
'-inf', '-inf',

Wyświetl plik

@ -24,3 +24,9 @@ print(float('.' + '0' * 60 + '9e40') == float('9e-21'))
print(float('1.00000000000000000000e-37')) print(float('1.00000000000000000000e-37'))
print(float('10.0000000000000000000e-38')) print(float('10.0000000000000000000e-38'))
print(float('100.000000000000000000e-39')) print(float('100.000000000000000000e-39'))
# very large exponent literal
print(float('1e4294967301'))
print(float('1e-4294967301'))
print(float('1e18446744073709551621'))
print(float('1e-18446744073709551621'))