circuitpython/tests/basics/array_micropython.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

29 lines
642 B
Python
Raw Normal View History

# test MicroPython-specific features of array.array
try:
2023-08-22 11:15:46 -04:00
import array
except ImportError:
2023-08-22 11:15:46 -04:00
print("SKIP")
raise SystemExit
# arrays of objects
a = array.array('O')
a.append(1)
print(a[0])
# arrays of pointers
a = array.array('P')
a.append(1)
print(a[0])
# comparison between mismatching binary layouts is not implemented
typecodes = ["b", "h", "i", "l", "q", "P", "O", "S", "f", "d"]
for a in typecodes:
for b in typecodes:
if a == b and a not in ["f", "d"]:
continue
try:
array.array(a) == array.array(b)
print('FAIL')
except NotImplementedError:
pass