Skip to content

Commit 26a9975

Browse files
committed
tests: Add some more tests for bytes, bignum, string and ujson.
1 parent 0683c1c commit 26a9975

File tree

12 files changed

+34
-0
lines changed

12 files changed

+34
-0
lines changed

tests/basics/bytes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
print(bytes())
2+
13
a = b"123"
24
print(a)
35
print(str(a))

tests/basics/int_big_and.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
print(a & -2)
1414
print(a & -2345678901234567890123456789)
1515
print(a & (-a))
16+
print(a & (-a - 1))
17+
print(a & (-a + 1))
1618

1719
# test negative on lhs
1820
a = 123456789012345678901234567890

tests/basics/int_big_or.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
print(0 | (1 << 80))
2+
3+
a = 0xfffffffffffffffffffffffffffff
4+
print(a | (1 << 200))

tests/basics/int_big_rshift.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
i = 123456789012345678901234567890
2+
print(i >> 1)
3+
print(i >> 1000)

tests/basics/int_big_xor.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
print(0 ^ (1 << 80))
2+
print((1 << 80) ^ (1 << 80))
3+
print((1 << 80) ^ 0)
4+
5+
a = 0xfffffffffffffffffffffffffffff
6+
print(a ^ (1 << 100))
7+
print(a ^ (1 << 200))

tests/basics/int_mpz.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@
5656
print(-10000000000000000000000003 >> i)
5757
print(-10000000000000000000000004 >> i)
5858

59+
# conversion from string
60+
print(int("123456789012345678901234567890"))
61+
print(int("-123456789012345678901234567890"))
62+
print(int("123456789012345678901234567890abcdef", 16))
63+
print(int("123456789012345678901234567890ABCDEF", 16))
64+
5965
# test constant integer with more than 255 chars
6066
x = 0x84ce72aa8699df436059f052ac51b6398d2511e49631bcb7e71f89c499b9ee425dfbc13a5f6d408471b054f2655617cbbaf7937b7c80cd8865cf02c8487d30d2b0fbd8b2c4e102e16d828374bbc47b93852f212d5043c3ea720f086178ff798cc4f63f787b9c2e419efa033e7644ea7936f54462dc21a6c4580725f7f0e7d1aaaaaaa
6167
print(x)

tests/basics/string1.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# basic strings
22

3+
print(str())
4+
35
x = 'abc'
46
print(x)
57

tests/basics/string_endswith.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
print("foobar".endswith("bar1"))
44
print("foobar".endswith("foobar"))
55
print("foobar".endswith(""))
6+
print("foobar".endswith("foobarbaz"))
67

78
#print("1foobar".startswith("foo", 1))
89
#print("1foo".startswith("foo", 1))

tests/basics/string_format.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
def test(fmt, *args):
77
print('{:8s}'.format(fmt) + '>' + fmt.format(*args) + '<')
88

9+
test("}}{{")
910
test("{}-{}", 1, [4, 5])
1011
test("{0}-{1}", 1, [4, 5])
1112
test("{1}-{0}", 1, [4, 5])
@@ -40,6 +41,7 @@ def test(fmt, *args):
4041
test("{:<6s}", "ab")
4142
test("{:>6s}", "ab")
4243
test("{:^6s}", "ab")
44+
test("{:.1s}", "ab")
4345

4446
test("{: <6d}", 123)
4547
test("{: <6d}", -123)

tests/basics/string_format_modulo.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
print("%%" % ())
12
print("=%s=" % 1)
23
print("=%s=%s=" % (1, 2))
34
print("=%s=" % (1,))
@@ -23,6 +24,7 @@
2324

2425
print("%s" % True)
2526
print("%s" % 1)
27+
print("%.1s" % "ab")
2628

2729
print("%r" % True)
2830
print("%r" % 1)

0 commit comments

Comments
 (0)