diff options
author | Damien George <damien.p.george@gmail.com> | 2014-07-05 06:14:29 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-07-05 06:14:29 +0100 |
commit | 539681fffd96082ca3b5d18643d4f08f65c47170 (patch) | |
tree | 7e6f8332c6e7737b768750e67265bb02b22932e6 /tests/basics/int_small.py | |
parent | 0182385ab0b4a1b2e549c92f8f5b621135aeb975 (diff) |
tests: Rename test scripts, changing - to _ for consistency.
From now on, all new tests must use underscore.
Addresses issue #727.
Diffstat (limited to 'tests/basics/int_small.py')
-rw-r--r-- | tests/basics/int_small.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/basics/int_small.py b/tests/basics/int_small.py new file mode 100644 index 000000000..102dac8ae --- /dev/null +++ b/tests/basics/int_small.py @@ -0,0 +1,50 @@ +# This tests small int range for 32-bit machine + +# Small ints are variable-length encoded in MicroPython, so first +# test that encoding works as expected. + +print(0) +print(1) +print(-1) +# Value is split in 7-bit "subwords", and taking into account that all +# ints in Python are signed, there're 6 bits of magnitude. So, around 2^6 +# there's "turning point" +print(63) +print(64) +print(65) +print(-63) +print(-64) +print(-65) +# Maximum values of small ints on 32-bit platform +print(1073741823) +# Per python semantics, lexical integer is without a sign (i.e. positive) +# and '-' is unary minus operation applied to it. That's why -1073741824 +# (min two-complement's negative value) is not allowed. +print(-1073741823) + +# Operations tests + +a = 0x3fffff +print(a) +a *= 0x10 +print(a) +a *= 0x10 +print(a) +a += 0xff +print(a) +# This would overflow +#a += 1 + +a = -0x3fffff +print(a) +a *= 0x10 +print(a) +a *= 0x10 +print(a) +a -= 0xff +print(a) +# This still doesn't overflow +a -= 1 +print(a) +# This would overflow +#a -= 1 |