From 757ac81a69cc2143a6b170367b18c75ac60249e4 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sun, 12 Jan 2014 17:06:25 +0200 Subject: Add proper checks for fits-in-small-int. Make it reusable. We likely should make mp_obj_new_int() inline, and rely on its encapsulated check rather than inline checks everywhere explicitly. Also, parser for big small int values is still broken. --- tests/basics/tests/int-small.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tests/basics/tests/int-small.py (limited to 'tests/basics') diff --git a/tests/basics/tests/int-small.py b/tests/basics/tests/int-small.py new file mode 100644 index 000000000..be338c4a4 --- /dev/null +++ b/tests/basics/tests/int-small.py @@ -0,0 +1,26 @@ +# This test small int range for 32-bit machine + +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 -- cgit v1.2.3