Skip to content

Commit 1f9e218

Browse files
committed
tests: Add tests for attrtuple, and for more corner cases.
1 parent 956d765 commit 1f9e218

5 files changed

Lines changed: 28 additions & 0 deletions

File tree

tests/basics/attrtuple1.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# test attrtuple
2+
# we can't test this type directly so we use sys.implementation object
3+
4+
import sys
5+
t = sys.implementation
6+
7+
# test printing of attrtuple
8+
print(str(t).find("version=") > 0)
9+
10+
# test read attr
11+
print(isinstance(t.name, str))

tests/basics/int1.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ def test(value, base):
7878
test('0o8', 8)
7979
test('0xg', 16)
8080
test('1 1', 16)
81+
test('123', 37)
8182

8283
# check that we don't parse this as a floating point number
8384
print(0x1e+1)

tests/basics/int_mpz.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,15 @@
6565
# test constant integer with more than 255 chars
6666
x = 0x84ce72aa8699df436059f052ac51b6398d2511e49631bcb7e71f89c499b9ee425dfbc13a5f6d408471b054f2655617cbbaf7937b7c80cd8865cf02c8487d30d2b0fbd8b2c4e102e16d828374bbc47b93852f212d5043c3ea720f086178ff798cc4f63f787b9c2e419efa033e7644ea7936f54462dc21a6c4580725f7f0e7d1aaaaaaa
6767
print(x)
68+
69+
# test parsing ints just on threshold of small to big
70+
# for 32 bit archs
71+
x = 1073741823 # small
72+
x = -1073741823 # small
73+
x = 1073741824 # big
74+
x = -1073741824 # big
75+
# for 64 bit archs
76+
x = 4611686018427387903 # small
77+
x = -4611686018427387903 # small
78+
x = 4611686018427387904 # big
79+
x = -4611686018427387904 # big

tests/basics/syntaxerror.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ def test_syntax(code):
2626
# bad indentation (lexer error)
2727
test_syntax(" a\n")
2828

29+
# malformed integer literal (parser error)
30+
test_syntax("123z")
31+
2932
# can't assign to literals
3033
test_syntax("1 = 2")
3134
test_syntax("'' = 1")

tests/basics/sys1.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
print(sys.version_info[0], sys.version_info[1])
1010
print(sys.byteorder in ('little', 'big'))
1111
print(sys.maxsize > 100)
12+
print(sys.implementation.name in ('cpython', 'micropython'))
1213

1314
try:
1415
sys.exit()

0 commit comments

Comments
 (0)