tests: Rename "array" module to "uarray".
This commit is contained in:
parent
a2eea57b1d
commit
30e25174bb
@ -1,8 +1,11 @@
|
|||||||
try:
|
try:
|
||||||
import array
|
import uarray as array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
try:
|
||||||
raise SystemExit
|
import array
|
||||||
|
except ImportError:
|
||||||
|
print("SKIP")
|
||||||
|
raise SystemExit
|
||||||
|
|
||||||
a = array.array('B', [1, 2, 3])
|
a = array.array('B', [1, 2, 3])
|
||||||
print(a, len(a))
|
print(a, len(a))
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
# test array + array
|
# test array + array
|
||||||
try:
|
try:
|
||||||
import array
|
import uarray as array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
try:
|
||||||
raise SystemExit
|
import array
|
||||||
|
except ImportError:
|
||||||
|
print("SKIP")
|
||||||
|
raise SystemExit
|
||||||
|
|
||||||
a1 = array.array('I', [1])
|
a1 = array.array('I', [1])
|
||||||
a2 = array.array('I', [2])
|
a2 = array.array('I', [2])
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
# test construction of array.array from different objects
|
# test construction of array.array from different objects
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from array import array
|
from uarray import array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
try:
|
||||||
raise SystemExit
|
from array import array
|
||||||
|
except ImportError:
|
||||||
|
print("SKIP")
|
||||||
|
raise SystemExit
|
||||||
|
|
||||||
# tuple, list
|
# tuple, list
|
||||||
print(array('b', (1, 2)))
|
print(array('b', (1, 2)))
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
try:
|
try:
|
||||||
from array import array
|
from uarray import array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
try:
|
||||||
raise SystemExit
|
from array import array
|
||||||
|
except ImportError:
|
||||||
|
print("SKIP")
|
||||||
|
raise SystemExit
|
||||||
|
|
||||||
# construct from something with unknown length (requires generators)
|
# construct from something with unknown length (requires generators)
|
||||||
print(array('i', (i for i in range(10))))
|
print(array('i', (i for i in range(10))))
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
# test construction of array.array from different objects
|
# test construction of array.array from different objects
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from array import array
|
from uarray import array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
try:
|
||||||
raise SystemExit
|
from array import array
|
||||||
|
except ImportError:
|
||||||
|
print("SKIP")
|
||||||
|
raise SystemExit
|
||||||
|
|
||||||
# raw copy from bytes, bytearray
|
# raw copy from bytes, bytearray
|
||||||
print(array('h', b'12'))
|
print(array('h', b'12'))
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
# test array types QqLl that require big-ints
|
# test array types QqLl that require big-ints
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from array import array
|
from uarray import array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
try:
|
||||||
raise SystemExit
|
from array import array
|
||||||
|
except ImportError:
|
||||||
|
print("SKIP")
|
||||||
|
raise SystemExit
|
||||||
|
|
||||||
print(array('L', [0, 2**32-1]))
|
print(array('L', [0, 2**32-1]))
|
||||||
print(array('l', [-2**31, 0, 2**31-1]))
|
print(array('l', [-2**31, 0, 2**31-1]))
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
# test MicroPython-specific features of array.array
|
# test MicroPython-specific features of array.array
|
||||||
try:
|
try:
|
||||||
import array
|
import uarray as array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
try:
|
||||||
raise SystemExit
|
import array
|
||||||
|
except ImportError:
|
||||||
|
print("SKIP")
|
||||||
|
raise SystemExit
|
||||||
|
|
||||||
# arrays of objects
|
# arrays of objects
|
||||||
a = array.array('O')
|
a = array.array('O')
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
# test construction of bytearray from different objects
|
# test construction of bytearray from different objects
|
||||||
try:
|
try:
|
||||||
from array import array
|
from uarray import array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
try:
|
||||||
raise SystemExit
|
from array import array
|
||||||
|
except ImportError:
|
||||||
|
print("SKIP")
|
||||||
|
raise SystemExit
|
||||||
|
|
||||||
# arrays
|
# arrays
|
||||||
print(bytearray(array('b', [1, 2])))
|
print(bytearray(array('b', [1, 2])))
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
# test construction of bytearray from different objects
|
# test construction of bytearray from different objects
|
||||||
try:
|
try:
|
||||||
from array import array
|
from uarray import array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
try:
|
||||||
raise SystemExit
|
from array import array
|
||||||
|
except ImportError:
|
||||||
|
print("SKIP")
|
||||||
|
raise SystemExit
|
||||||
|
|
||||||
# arrays
|
# arrays
|
||||||
print(bytearray(array('h', [1, 2])))
|
print(bytearray(array('h', [1, 2])))
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
# test bytes + other
|
# test bytes + other
|
||||||
try:
|
try:
|
||||||
import array
|
import uarray as array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
try:
|
||||||
raise SystemExit
|
import array
|
||||||
|
except ImportError:
|
||||||
|
print("SKIP")
|
||||||
|
raise SystemExit
|
||||||
|
|
||||||
# should be byteorder-neutral
|
# should be byteorder-neutral
|
||||||
print(b"123" + array.array('h', [0x1515]))
|
print(b"123" + array.array('h', [0x1515]))
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
# test bytes + other
|
# test bytes + other
|
||||||
try:
|
try:
|
||||||
import array
|
import uarray as array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
try:
|
||||||
raise SystemExit
|
import array
|
||||||
|
except ImportError:
|
||||||
|
print("SKIP")
|
||||||
|
raise SystemExit
|
||||||
|
|
||||||
print(b"123" + array.array('i', [1]))
|
print(b"123" + array.array('i', [1]))
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
try:
|
try:
|
||||||
import array
|
import uarray as array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
try:
|
||||||
raise SystemExit
|
import array
|
||||||
|
except ImportError:
|
||||||
|
print("SKIP")
|
||||||
|
raise SystemExit
|
||||||
|
|
||||||
print(array.array('b', [1, 2]) in b'\x01\x02\x03')
|
print(array.array('b', [1, 2]) in b'\x01\x02\x03')
|
||||||
# CPython gives False here
|
# CPython gives False here
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
# test construction of bytes from different objects
|
# test construction of bytes from different objects
|
||||||
try:
|
try:
|
||||||
from array import array
|
from uarray import array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
try:
|
||||||
raise SystemExit
|
from array import array
|
||||||
|
except ImportError:
|
||||||
|
print("SKIP")
|
||||||
|
raise SystemExit
|
||||||
|
|
||||||
# arrays
|
# arrays
|
||||||
print(bytes(array('b', [1, 2])))
|
print(bytes(array('b', [1, 2])))
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
# test construction of bytes from different objects
|
# test construction of bytes from different objects
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from array import array
|
from uarray import array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
try:
|
||||||
raise SystemExit
|
from array import array
|
||||||
|
except ImportError:
|
||||||
|
print("SKIP")
|
||||||
|
raise SystemExit
|
||||||
|
|
||||||
# arrays
|
# arrays
|
||||||
print(bytes(array('h', [1, 2])))
|
print(bytes(array('h', [1, 2])))
|
||||||
|
@ -4,6 +4,14 @@ try:
|
|||||||
except:
|
except:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
try:
|
||||||
|
import uarray as array
|
||||||
|
except ImportError:
|
||||||
|
try:
|
||||||
|
import array
|
||||||
|
except ImportError:
|
||||||
|
print("SKIP")
|
||||||
|
raise SystemExit
|
||||||
|
|
||||||
# test reading from bytes
|
# test reading from bytes
|
||||||
b = b'1234'
|
b = b'1234'
|
||||||
@ -39,7 +47,6 @@ m = memoryview(bytearray(2))
|
|||||||
print(bytearray(m))
|
print(bytearray(m))
|
||||||
print(list(memoryview(memoryview(b'1234')))) # read-only memoryview
|
print(list(memoryview(memoryview(b'1234')))) # read-only memoryview
|
||||||
|
|
||||||
import array
|
|
||||||
a = array.array('i', [1, 2, 3, 4])
|
a = array.array('i', [1, 2, 3, 4])
|
||||||
m = memoryview(a)
|
m = memoryview(a)
|
||||||
print(list(m))
|
print(list(m))
|
||||||
|
@ -1,10 +1,17 @@
|
|||||||
# test memoryview accessing maximum values for signed/unsigned elements
|
# test memoryview accessing maximum values for signed/unsigned elements
|
||||||
try:
|
try:
|
||||||
from array import array
|
|
||||||
memoryview
|
memoryview
|
||||||
except:
|
except:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
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(b'\x7f\x80\x81\xff')))
|
||||||
print(list(memoryview(array('b', [0x7f, -0x80]))))
|
print(list(memoryview(array('b', [0x7f, -0x80]))))
|
||||||
|
@ -1,10 +1,17 @@
|
|||||||
# test memoryview accessing maximum values for signed/unsigned elements
|
# test memoryview accessing maximum values for signed/unsigned elements
|
||||||
try:
|
try:
|
||||||
from array import array
|
|
||||||
memoryview
|
memoryview
|
||||||
except:
|
except:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
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]))))
|
||||||
print(list(memoryview(array('I', [0x7f000000, 0x80000000, 0x81000000, 0xffffffff]))))
|
print(list(memoryview(array('I', [0x7f000000, 0x80000000, 0x81000000, 0xffffffff]))))
|
||||||
|
@ -1,9 +1,16 @@
|
|||||||
try:
|
try:
|
||||||
memoryview(b'a').itemsize
|
memoryview(b'a').itemsize
|
||||||
from array import array
|
|
||||||
except:
|
except:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
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']:
|
for code in ['b', 'h', 'i', 'l', 'q', 'f', 'd']:
|
||||||
print(memoryview(array(code)).itemsize)
|
print(memoryview(array(code)).itemsize)
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
# test construction of array from array with float type
|
# test construction of array from array with float type
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from array import array
|
from uarray import array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
try:
|
||||||
raise SystemExit
|
from array import array
|
||||||
|
except ImportError:
|
||||||
|
print("SKIP")
|
||||||
|
raise SystemExit
|
||||||
|
|
||||||
print(array('f', array('h', [1, 2])))
|
print(array('f', array('h', [1, 2])))
|
||||||
print(array('d', array('f', [1, 2])))
|
print(array('d', array('f', [1, 2])))
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
# test construction of bytearray from array with float type
|
# test construction of bytearray from array with float type
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from array import array
|
from uarray import array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
try:
|
||||||
raise SystemExit
|
from array import array
|
||||||
|
except ImportError:
|
||||||
|
print("SKIP")
|
||||||
|
raise SystemExit
|
||||||
|
|
||||||
print(bytearray(array('f', [1, 2.3])))
|
print(bytearray(array('f', [1, 2.3])))
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
# test construction of bytearray from array with float type
|
# test construction of bytearray from array with float type
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from array import array
|
from uarray import array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
try:
|
||||||
raise SystemExit
|
from array import array
|
||||||
|
except ImportError:
|
||||||
|
print("SKIP")
|
||||||
|
raise SystemExit
|
||||||
|
|
||||||
print(bytes(array('f', [1, 2.3])))
|
print(bytes(array('f', [1, 2.3])))
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
try:
|
try:
|
||||||
from array import array
|
from uarray import array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
try:
|
||||||
raise SystemExit
|
from array import array
|
||||||
|
except ImportError:
|
||||||
|
print("SKIP")
|
||||||
|
raise SystemExit
|
||||||
|
|
||||||
def test(a):
|
def test(a):
|
||||||
print(a)
|
print(a)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import array
|
import uarray as array
|
||||||
@micropython.asm_thumb # test vldr, vstr
|
@micropython.asm_thumb # test vldr, vstr
|
||||||
def arrayadd(r0):
|
def arrayadd(r0):
|
||||||
vldr(s0, [r0, 0])
|
vldr(s0, [r0, 0])
|
||||||
|
@ -46,7 +46,7 @@ def asm_sum_bytes(r0, r1):
|
|||||||
|
|
||||||
mov(r0, r2)
|
mov(r0, r2)
|
||||||
|
|
||||||
import array
|
import uarray as array
|
||||||
|
|
||||||
b = array.array('l', (100, 200, 300, 400))
|
b = array.array('l', (100, 200, 300, 400))
|
||||||
n = asm_sum_words(len(b), b)
|
n = asm_sum_words(len(b), b)
|
||||||
|
@ -1,10 +1,17 @@
|
|||||||
# test that iterating doesn't use the heap
|
# test that iterating doesn't use the heap
|
||||||
try:
|
try:
|
||||||
frozenset
|
frozenset
|
||||||
import array
|
except NameError:
|
||||||
except (NameError, ImportError):
|
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
try:
|
||||||
|
import uarray as array
|
||||||
|
except ImportError:
|
||||||
|
try:
|
||||||
|
import array
|
||||||
|
except ImportError:
|
||||||
|
print("SKIP")
|
||||||
|
raise SystemExit
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from micropython import heap_lock, heap_unlock
|
from micropython import heap_lock, heap_unlock
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# tests for things that are not implemented, or have non-compliant behaviour
|
# tests for things that are not implemented, or have non-compliant behaviour
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import array
|
import uarray as array
|
||||||
import ustruct
|
import ustruct
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
|
Loading…
Reference in New Issue
Block a user