diff options
author | Rami Ali <flowergrass@users.noreply.github.com> | 2016-12-19 13:13:10 +1100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2016-12-20 10:15:48 +1100 |
commit | 5e1ccddc825e1304dbf235e391df3e1a5aea0723 (patch) | |
tree | 8ce60a5eacff2d7416b62fd9894d0fe2b6e9e01d /tests | |
parent | 91359c86900ea664a8ad4fefad22b630bd714e2d (diff) | |
download | micropython-5e1ccddc825e1304dbf235e391df3e1a5aea0723.tar.gz micropython-5e1ccddc825e1304dbf235e391df3e1a5aea0723.zip |
tests/basics: Improve mpz test coverage.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/basics/int_big_rshift.py | 1 | ||||
-rw-r--r-- | tests/basics/int_big_xor.py | 1 | ||||
-rw-r--r-- | tests/basics/int_mpz.py | 8 |
3 files changed, 10 insertions, 0 deletions
diff --git a/tests/basics/int_big_rshift.py b/tests/basics/int_big_rshift.py index 6055e95b97..b2fecb36c9 100644 --- a/tests/basics/int_big_rshift.py +++ b/tests/basics/int_big_rshift.py @@ -4,3 +4,4 @@ print(i >> 1000) # result needs rounding up print(-(1<<70) >> 80) +print(-0xffffffffffffffff >> 32) diff --git a/tests/basics/int_big_xor.py b/tests/basics/int_big_xor.py index 943d1ac15d..318db45e60 100644 --- a/tests/basics/int_big_xor.py +++ b/tests/basics/int_big_xor.py @@ -19,6 +19,7 @@ print((-a) ^ (1 << 100)) print((-a) ^ (1 << 200)) print((-a) ^ a == 0) print(bool((-a) ^ a)) +print(-1 ^ 0xffffffffffffffff) # carry overflows to higher digit # test + - diff --git a/tests/basics/int_mpz.py b/tests/basics/int_mpz.py index 05aec95cea..814e1b4aad 100644 --- a/tests/basics/int_mpz.py +++ b/tests/basics/int_mpz.py @@ -7,6 +7,8 @@ y = 2000000000000000000000000000000 # printing print(x) print(y) +print('%#X' % (x - x)) # print prefix +print('{:#,}'.format(x)) # print with commas # addition print(x + 1) @@ -67,6 +69,12 @@ print(int("-123456789012345678901234567890")) print(int("123456789012345678901234567890abcdef", 16)) print(int("123456789012345678901234567890ABCDEF", 16)) +# invalid characters in string +try: + print(int("123456789012345678901234567890abcdef")) +except ValueError: + print('ValueError'); + # test constant integer with more than 255 chars x = 0x84ce72aa8699df436059f052ac51b6398d2511e49631bcb7e71f89c499b9ee425dfbc13a5f6d408471b054f2655617cbbaf7937b7c80cd8865cf02c8487d30d2b0fbd8b2c4e102e16d828374bbc47b93852f212d5043c3ea720f086178ff798cc4f63f787b9c2e419efa033e7644ea7936f54462dc21a6c4580725f7f0e7d1aaaaaaa print(x) |