Skip to content

Commit 1ad0013

Browse files
committed
tests: Add some tests for bigint hash, float hash and float parsing.
Following outcome of recent fuzz testing and sanitizing by @jepler.
1 parent 95e43ef commit 1ad0013

3 files changed

Lines changed: 11 additions & 0 deletions

File tree

tests/basics/builtin_hash_intbig.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ class F:
88
def __hash__(self):
99
return 1 << 70 | 1
1010
print(hash(F()) != 0)
11+
12+
# this had a particular error with internal integer arithmetic of hash function
13+
print(hash(6699999999999999999999999999999999999999999999999999999999999999999999) != 0)

tests/float/builtin_float_hash.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# these should hash to an integer with a specific value
44
for val in (
55
'0.0',
6+
'-0.0',
67
'1.0',
78
'2.0',
89
'-12.0',
@@ -15,6 +16,7 @@
1516
'0.1',
1617
'-0.1',
1718
'10.3',
19+
'0.4e3',
1820
'1e16',
1921
'inf',
2022
'-inf',

tests/float/float_parse.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,9 @@
2424
print(float('1.00000000000000000000e-37'))
2525
print(float('10.0000000000000000000e-38'))
2626
print(float('100.000000000000000000e-39'))
27+
28+
# very large exponent literal
29+
print(float('1e4294967301'))
30+
print(float('1e-4294967301'))
31+
print(float('1e18446744073709551621'))
32+
print(float('1e-18446744073709551621'))

0 commit comments

Comments
 (0)