diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2017-04-21 16:40:57 +0300 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2017-04-21 16:43:21 +0300 |
commit | 9e8f3163924c1f429f16f44a4a27b0cd33064719 (patch) | |
tree | 0ae3ee37e882ed9f34dabdfc3925efa3ea8865d0 /tests | |
parent | 3e5cd35a9f6b2877f72f4af6865f14363826de4c (diff) | |
download | micropython-9e8f3163924c1f429f16f44a4a27b0cd33064719.tar.gz micropython-9e8f3163924c1f429f16f44a4a27b0cd33064719.zip |
extmod/moductypes: Fix bigint handling for 32-bit ports.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/extmod/uctypes_32bit_intbig.py | 54 | ||||
-rw-r--r-- | tests/extmod/uctypes_32bit_intbig.py.exp | 11 |
2 files changed, 65 insertions, 0 deletions
diff --git a/tests/extmod/uctypes_32bit_intbig.py b/tests/extmod/uctypes_32bit_intbig.py new file mode 100644 index 0000000000..a082dc3704 --- /dev/null +++ b/tests/extmod/uctypes_32bit_intbig.py @@ -0,0 +1,54 @@ +# This test checks previously known problem values for 32-bit ports. +# It's less useful for 64-bit ports. +try: + import uctypes +except ImportError: + import sys + print("SKIP") + sys.exit() + +buf = b"12345678abcd" +struct = uctypes.struct( + uctypes.addressof(buf), + {"f32": uctypes.UINT32 | 0, "f64": uctypes.UINT64 | 4}, + uctypes.LITTLE_ENDIAN +) + +struct.f32 = 0x7fffffff +print(buf) + +struct.f32 = 0x80000000 +print(buf) + +struct.f32 = 0xff010203 +print(buf) + +struct.f64 = 0x80000000 +print(buf) + +struct.f64 = 0x80000000 * 2 +print(buf) + +print("=") + +buf = b"12345678abcd" +struct = uctypes.struct( + uctypes.addressof(buf), + {"f32": uctypes.UINT32 | 0, "f64": uctypes.UINT64 | 4}, + uctypes.BIG_ENDIAN +) + +struct.f32 = 0x7fffffff +print(buf) + +struct.f32 = 0x80000000 +print(buf) + +struct.f32 = 0xff010203 +print(buf) + +struct.f64 = 0x80000000 +print(buf) + +struct.f64 = 0x80000000 * 2 +print(buf) diff --git a/tests/extmod/uctypes_32bit_intbig.py.exp b/tests/extmod/uctypes_32bit_intbig.py.exp new file mode 100644 index 0000000000..d1fc1fe350 --- /dev/null +++ b/tests/extmod/uctypes_32bit_intbig.py.exp @@ -0,0 +1,11 @@ +b'\xff\xff\xff\x7f5678abcd' +b'\x00\x00\x00\x805678abcd' +b'\x03\x02\x01\xff5678abcd' +b'\x03\x02\x01\xff\x00\x00\x00\x80\x00\x00\x00\x00' +b'\x03\x02\x01\xff\x00\x00\x00\x00\x01\x00\x00\x00' += +b'\x7f\xff\xff\xff5678abcd' +b'\x80\x00\x00\x005678abcd' +b'\xff\x01\x02\x035678abcd' +b'\xff\x01\x02\x03\x00\x00\x00\x00\x80\x00\x00\x00' +b'\xff\x01\x02\x03\x00\x00\x00\x01\x00\x00\x00\x00' |