summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics/int_small.py
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-11-02 02:39:41 +0200
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-11-02 02:41:30 +0200
commit039887a0ac9bd02cfd84e4792d3d21a78bc06a7f (patch)
tree009fccb2375d12d3bdc0302e346b6901753bd6d6 /tests/basics/int_small.py
parenta58713a899b7df5b291e868d2553b2333c0b3dc9 (diff)
downloadmicropython-039887a0ac9bd02cfd84e4792d3d21a78bc06a7f.tar.gz
micropython-039887a0ac9bd02cfd84e4792d3d21a78bc06a7f.zip
py: Fix bug with right-shifting small ints by large amounts.
Undefined behavior in C, needs explicit check.
Diffstat (limited to 'tests/basics/int_small.py')
-rw-r--r--tests/basics/int_small.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/basics/int_small.py b/tests/basics/int_small.py
index 102dac8ae7..1b2c983e23 100644
--- a/tests/basics/int_small.py
+++ b/tests/basics/int_small.py
@@ -48,3 +48,17 @@ a -= 1
print(a)
# This would overflow
#a -= 1
+
+
+# Shifts to big amounts are undefined behavior in C and is CPU-specific
+
+# These are compile-time constexprs
+print(1 >> 32)
+print(1 >> 64)
+print(1 >> 128)
+
+# These are runtime calcs
+a = 1
+print(a >> 32)
+print(a >> 64)
+print(a >> 128)