tests/extmod: Use bytearray instead of bytes for uctypes test.

Because the test modifies the (now) bytearray object, and if it's a bytes
object it's not guaranteed that it can be modified, or that this constant
object isn't used elsewhere.

Signed-off-by: Damien George <damien@micropython.org>
pull/8677/head
Damien George 2022-05-17 19:45:06 +10:00
rodzic 8588525868
commit 80938839c1
2 zmienionych plików z 12 dodań i 12 usunięć

Wyświetl plik

@ -6,7 +6,7 @@ except ImportError:
print("SKIP")
raise SystemExit
buf = b"12345678abcd"
buf = bytearray(b"12345678abcd")
struct = uctypes.struct(
uctypes.addressof(buf),
{"f32": uctypes.UINT32 | 0, "f64": uctypes.UINT64 | 4},
@ -30,7 +30,7 @@ print(buf)
print("=")
buf = b"12345678abcd"
buf = bytearray(b"12345678abcd")
struct = uctypes.struct(
uctypes.addressof(buf),
{"f32": uctypes.UINT32 | 0, "f64": uctypes.UINT64 | 4},

Wyświetl plik

@ -1,11 +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'
bytearray(b'\xff\xff\xff\x7f5678abcd')
bytearray(b'\x00\x00\x00\x805678abcd')
bytearray(b'\x03\x02\x01\xff5678abcd')
bytearray(b'\x03\x02\x01\xff\x00\x00\x00\x80\x00\x00\x00\x00')
bytearray(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'
bytearray(b'\x7f\xff\xff\xff5678abcd')
bytearray(b'\x80\x00\x00\x005678abcd')
bytearray(b'\xff\x01\x02\x035678abcd')
bytearray(b'\xff\x01\x02\x03\x00\x00\x00\x00\x80\x00\x00\x00')
bytearray(b'\xff\x01\x02\x03\x00\x00\x00\x01\x00\x00\x00\x00')