2016-12-27 23:29:21 -05:00
|
|
|
# test MicroPython-specific features of array.array
|
2017-02-14 16:57:56 -05:00
|
|
|
try:
|
2019-10-22 02:33:23 -04:00
|
|
|
import uarray as array
|
2017-02-14 16:57:56 -05:00
|
|
|
except ImportError:
|
2019-10-22 02:33:23 -04:00
|
|
|
try:
|
|
|
|
import array
|
|
|
|
except ImportError:
|
|
|
|
print("SKIP")
|
|
|
|
raise SystemExit
|
2016-12-27 23:29:21 -05:00
|
|
|
|
|
|
|
# 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])
|
2021-05-12 11:02:06 -04:00
|
|
|
|
|
|
|
# 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
|