tests: Rename "array" module to "uarray".

This commit is contained in:
Damien George 2019-10-22 17:33:23 +11:00
parent a2eea57b1d
commit 30e25174bb
26 changed files with 152 additions and 63 deletions

View File

@ -1,8 +1,11 @@
try:
import array
import uarray as array
except ImportError:
print("SKIP")
raise SystemExit
try:
import array
except ImportError:
print("SKIP")
raise SystemExit
a = array.array('B', [1, 2, 3])
print(a, len(a))

View File

@ -1,9 +1,12 @@
# test array + array
try:
import array
import uarray as array
except ImportError:
print("SKIP")
raise SystemExit
try:
import array
except ImportError:
print("SKIP")
raise SystemExit
a1 = array.array('I', [1])
a2 = array.array('I', [2])

View File

@ -1,10 +1,13 @@
# test construction of array.array from different objects
try:
from array import array
from uarray import array
except ImportError:
print("SKIP")
raise SystemExit
try:
from array import array
except ImportError:
print("SKIP")
raise SystemExit
# tuple, list
print(array('b', (1, 2)))

View File

@ -1,8 +1,11 @@
try:
from array import array
from uarray import array
except ImportError:
print("SKIP")
raise SystemExit
try:
from array import array
except ImportError:
print("SKIP")
raise SystemExit
# construct from something with unknown length (requires generators)
print(array('i', (i for i in range(10))))

View File

@ -1,10 +1,13 @@
# test construction of array.array from different objects
try:
from array import array
from uarray import array
except ImportError:
print("SKIP")
raise SystemExit
try:
from array import array
except ImportError:
print("SKIP")
raise SystemExit
# raw copy from bytes, bytearray
print(array('h', b'12'))

View File

@ -1,10 +1,13 @@
# test array types QqLl that require big-ints
try:
from array import array
from uarray import array
except ImportError:
print("SKIP")
raise SystemExit
try:
from array import array
except ImportError:
print("SKIP")
raise SystemExit
print(array('L', [0, 2**32-1]))
print(array('l', [-2**31, 0, 2**31-1]))

View File

@ -1,9 +1,12 @@
# test MicroPython-specific features of array.array
try:
import array
import uarray as array
except ImportError:
print("SKIP")
raise SystemExit
try:
import array
except ImportError:
print("SKIP")
raise SystemExit
# arrays of objects
a = array.array('O')

View File

@ -1,9 +1,12 @@
# test construction of bytearray from different objects
try:
from array import array
from uarray import array
except ImportError:
print("SKIP")
raise SystemExit
try:
from array import array
except ImportError:
print("SKIP")
raise SystemExit
# arrays
print(bytearray(array('b', [1, 2])))

View File

@ -1,9 +1,12 @@
# test construction of bytearray from different objects
try:
from array import array
from uarray import array
except ImportError:
print("SKIP")
raise SystemExit
try:
from array import array
except ImportError:
print("SKIP")
raise SystemExit
# arrays
print(bytearray(array('h', [1, 2])))

View File

@ -1,9 +1,12 @@
# test bytes + other
try:
import array
import uarray as array
except ImportError:
print("SKIP")
raise SystemExit
try:
import array
except ImportError:
print("SKIP")
raise SystemExit
# should be byteorder-neutral
print(b"123" + array.array('h', [0x1515]))

View File

@ -1,8 +1,11 @@
# test bytes + other
try:
import array
import uarray as array
except ImportError:
print("SKIP")
raise SystemExit
try:
import array
except ImportError:
print("SKIP")
raise SystemExit
print(b"123" + array.array('i', [1]))

View File

@ -1,8 +1,11 @@
try:
import array
import uarray as array
except ImportError:
print("SKIP")
raise SystemExit
try:
import array
except ImportError:
print("SKIP")
raise SystemExit
print(array.array('b', [1, 2]) in b'\x01\x02\x03')
# CPython gives False here

View File

@ -1,9 +1,12 @@
# test construction of bytes from different objects
try:
from array import array
from uarray import array
except ImportError:
print("SKIP")
raise SystemExit
try:
from array import array
except ImportError:
print("SKIP")
raise SystemExit
# arrays
print(bytes(array('b', [1, 2])))

View File

@ -1,10 +1,13 @@
# test construction of bytes from different objects
try:
from array import array
from uarray import array
except ImportError:
print("SKIP")
raise SystemExit
try:
from array import array
except ImportError:
print("SKIP")
raise SystemExit
# arrays
print(bytes(array('h', [1, 2])))

View File

@ -4,6 +4,14 @@ try:
except:
print("SKIP")
raise SystemExit
try:
import uarray as array
except ImportError:
try:
import array
except ImportError:
print("SKIP")
raise SystemExit
# test reading from bytes
b = b'1234'
@ -39,7 +47,6 @@ m = memoryview(bytearray(2))
print(bytearray(m))
print(list(memoryview(memoryview(b'1234')))) # read-only memoryview
import array
a = array.array('i', [1, 2, 3, 4])
m = memoryview(a)
print(list(m))

View File

@ -1,10 +1,17 @@
# test memoryview accessing maximum values for signed/unsigned elements
try:
from array import array
memoryview
except:
print("SKIP")
raise SystemExit
try:
from uarray import array
except ImportError:
try:
from array import array
except ImportError:
print("SKIP")
raise SystemExit
print(list(memoryview(b'\x7f\x80\x81\xff')))
print(list(memoryview(array('b', [0x7f, -0x80]))))

View File

@ -1,10 +1,17 @@
# test memoryview accessing maximum values for signed/unsigned elements
try:
from array import array
memoryview
except:
print("SKIP")
raise SystemExit
try:
from uarray import array
except ImportError:
try:
from array import array
except ImportError:
print("SKIP")
raise SystemExit
print(list(memoryview(array('i', [0x7f000000, -0x80000000]))))
print(list(memoryview(array('I', [0x7f000000, 0x80000000, 0x81000000, 0xffffffff]))))

View File

@ -1,9 +1,16 @@
try:
memoryview(b'a').itemsize
from array import array
except:
print("SKIP")
raise SystemExit
try:
from uarray import array
except ImportError:
try:
from array import array
except ImportError:
print("SKIP")
raise SystemExit
for code in ['b', 'h', 'i', 'l', 'q', 'f', 'd']:
print(memoryview(array(code)).itemsize)

View File

@ -1,10 +1,13 @@
# test construction of array from array with float type
try:
from array import array
from uarray import array
except ImportError:
print("SKIP")
raise SystemExit
try:
from array import array
except ImportError:
print("SKIP")
raise SystemExit
print(array('f', array('h', [1, 2])))
print(array('d', array('f', [1, 2])))

View File

@ -1,9 +1,12 @@
# test construction of bytearray from array with float type
try:
from array import array
from uarray import array
except ImportError:
print("SKIP")
raise SystemExit
try:
from array import array
except ImportError:
print("SKIP")
raise SystemExit
print(bytearray(array('f', [1, 2.3])))

View File

@ -1,9 +1,12 @@
# test construction of bytearray from array with float type
try:
from array import array
from uarray import array
except ImportError:
print("SKIP")
raise SystemExit
try:
from array import array
except ImportError:
print("SKIP")
raise SystemExit
print(bytes(array('f', [1, 2.3])))

View File

@ -1,8 +1,11 @@
try:
from array import array
from uarray import array
except ImportError:
print("SKIP")
raise SystemExit
try:
from array import array
except ImportError:
print("SKIP")
raise SystemExit
def test(a):
print(a)

View File

@ -1,4 +1,4 @@
import array
import uarray as array
@micropython.asm_thumb # test vldr, vstr
def arrayadd(r0):
vldr(s0, [r0, 0])

View File

@ -46,7 +46,7 @@ def asm_sum_bytes(r0, r1):
mov(r0, r2)
import array
import uarray as array
b = array.array('l', (100, 200, 300, 400))
n = asm_sum_words(len(b), b)

View File

@ -1,10 +1,17 @@
# test that iterating doesn't use the heap
try:
frozenset
import array
except (NameError, ImportError):
except NameError:
print("SKIP")
raise SystemExit
try:
import uarray as array
except ImportError:
try:
import array
except ImportError:
print("SKIP")
raise SystemExit
try:
from micropython import heap_lock, heap_unlock

View File

@ -1,7 +1,7 @@
# tests for things that are not implemented, or have non-compliant behaviour
try:
import array
import uarray as array
import ustruct
except ImportError:
print("SKIP")