Skip to content

Commit 3ab6aa3

Browse files
committed
tests/basic: Split tests into working with small ints and not working.
Tests which don't work with small ints are suffixed with _intbig.py. Some of these may still work with long long ints and need to be reclassified later.
1 parent 89e570a commit 3ab6aa3

34 files changed

Lines changed: 166 additions & 120 deletions

tests/basics/builtin_abs.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,3 @@
44
print(abs(True))
55
print(abs(1))
66
print(abs(-1))
7-
8-
# bignum
9-
print(abs(123456789012345678901234567890))
10-
print(abs(-123456789012345678901234567890))
11-
12-
# edge cases for 32 and 64 bit archs (small int overflow when negating)
13-
print(abs(-0x3fffffff - 1))
14-
print(abs(-0x3fffffffffffffff - 1))

tests/basics/builtin_abs_intbig.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# test builtin abs
2+
3+
# bignum
4+
print(abs(123456789012345678901234567890))
5+
print(abs(-123456789012345678901234567890))
6+
7+
# edge cases for 32 and 64 bit archs (small int overflow when negating)
8+
print(abs(-0x3fffffff - 1))
9+
print(abs(-0x3fffffffffffffff - 1))

tests/basics/builtin_bin.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,4 @@
88
print(bin(12345))
99
print(bin(0b10101))
1010

11-
print(bin(12345678901234567890))
1211
print(bin(0b10101010101010101010))

tests/basics/builtin_bin_intbig.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# test builtin bin function
2+
3+
print(bin(12345678901234567890))

tests/basics/builtin_divmod.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,7 @@
99
except ZeroDivisionError:
1010
print("ZeroDivisionError")
1111

12-
try:
13-
divmod(1 << 65, 0)
14-
except ZeroDivisionError:
15-
print("ZeroDivisionError")
16-
1712
try:
1813
divmod('a', 'b')
1914
except TypeError:
2015
print("TypeError")
21-
22-
# bignum
23-
l = (1 << 65) + 123
24-
print(divmod(3, l))
25-
print(divmod(l, 5))
26-
print(divmod(l + 3, l))
27-
print(divmod(l * 20, l + 2))
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# test builtin divmod
2+
3+
try:
4+
divmod(1 << 65, 0)
5+
except ZeroDivisionError:
6+
print("ZeroDivisionError")
7+
8+
# bignum
9+
l = (1 << 65) + 123
10+
print(divmod(3, l))
11+
print(divmod(l, 5))
12+
print(divmod(l + 3, l))
13+
print(divmod(l * 20, l + 2))

tests/basics/builtin_hash.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
print(hash(True))
55
print({():1}) # hash tuple
66
print({(1,):1}) # hash non-empty tuple
7-
print({1 << 66:1}) # hash big int
8-
print({-(1 << 66):2}) # hash negative big int
97
print(hash in {hash:1}) # hash function
108

119
try:
@@ -50,9 +48,3 @@ class E:
5048
def __hash__(self):
5149
return True
5250
print(hash(E()))
53-
54-
# __hash__ returning a large number should be truncated
55-
class F:
56-
def __hash__(self):
57-
return 1 << 70 | 1
58-
print(hash(F()) != 0)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# test builtin hash function
2+
3+
print({1 << 66:1}) # hash big int
4+
print({-(1 << 66):2}) # hash negative big int
5+
6+
# __hash__ returning a large number should be truncated
7+
class F:
8+
def __hash__(self):
9+
return 1 << 70 | 1
10+
print(hash(F()) != 0)

tests/basics/builtin_hex.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,3 @@
77

88
print(hex(12345))
99
print(hex(0x12345))
10-
11-
print(hex(12345678901234567890))
12-
print(hex(0x12345678901234567890))

0 commit comments

Comments
 (0)