Commit 26a9975f authored by Damien George's avatar Damien George
Browse files

tests: Add some more tests for bytes, bignum, string and ujson.

parent 0683c1ce
print(bytes())
a = b"123"
print(a)
print(str(a))
......
......@@ -13,6 +13,8 @@ print(a & -1)
print(a & -2)
print(a & -2345678901234567890123456789)
print(a & (-a))
print(a & (-a - 1))
print(a & (-a + 1))
# test negative on lhs
a = 123456789012345678901234567890
......
print(0 | (1 << 80))
a = 0xfffffffffffffffffffffffffffff
print(a | (1 << 200))
i = 123456789012345678901234567890
print(i >> 1)
print(i >> 1000)
print(0 ^ (1 << 80))
print((1 << 80) ^ (1 << 80))
print((1 << 80) ^ 0)
a = 0xfffffffffffffffffffffffffffff
print(a ^ (1 << 100))
print(a ^ (1 << 200))
......@@ -56,6 +56,12 @@ for i in range(8):
print(-10000000000000000000000003 >> i)
print(-10000000000000000000000004 >> i)
# conversion from string
print(int("123456789012345678901234567890"))
print(int("-123456789012345678901234567890"))
print(int("123456789012345678901234567890abcdef", 16))
print(int("123456789012345678901234567890ABCDEF", 16))
# test constant integer with more than 255 chars
x = 0x84ce72aa8699df436059f052ac51b6398d2511e49631bcb7e71f89c499b9ee425dfbc13a5f6d408471b054f2655617cbbaf7937b7c80cd8865cf02c8487d30d2b0fbd8b2c4e102e16d828374bbc47b93852f212d5043c3ea720f086178ff798cc4f63f787b9c2e419efa033e7644ea7936f54462dc21a6c4580725f7f0e7d1aaaaaaa
print(x)
# basic strings
print(str())
x = 'abc'
print(x)
......
......@@ -3,6 +3,7 @@ print("foobar".endswith("baR"))
print("foobar".endswith("bar1"))
print("foobar".endswith("foobar"))
print("foobar".endswith(""))
print("foobar".endswith("foobarbaz"))
#print("1foobar".startswith("foo", 1))
#print("1foo".startswith("foo", 1))
......
......@@ -6,6 +6,7 @@ full_tests = False
def test(fmt, *args):
print('{:8s}'.format(fmt) + '>' + fmt.format(*args) + '<')
test("}}{{")
test("{}-{}", 1, [4, 5])
test("{0}-{1}", 1, [4, 5])
test("{1}-{0}", 1, [4, 5])
......@@ -40,6 +41,7 @@ test("{:#4X}", 0)
test("{:<6s}", "ab")
test("{:>6s}", "ab")
test("{:^6s}", "ab")
test("{:.1s}", "ab")
test("{: <6d}", 123)
test("{: <6d}", -123)
......
print("%%" % ())
print("=%s=" % 1)
print("=%s=%s=" % (1, 2))
print("=%s=" % (1,))
......@@ -23,6 +24,7 @@ except TypeError:
print("%s" % True)
print("%s" % 1)
print("%.1s" % "ab")
print("%r" % True)
print("%r" % 1)
......
print("".replace("a", "b"))
print("aaa".replace("b", "c"))
print("aaa".replace("a", "b", 0))
print("aaa".replace("a", "b", -5))
print("asdfasdf".replace("a", "b"))
......
......@@ -21,3 +21,5 @@ print(json.dumps((1, (2, 3))))
print(json.dumps({}))
print(json.dumps({"a":1}))
print(json.dumps({"a":(2,[3,None])}))
print(json.dumps('"quoted"'))
print(json.dumps('space\n\r\tspace'))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment