tests: Add test for array slice assignment.
This commit is contained in:
parent
cefcbb22b2
commit
992284be39
43
tests/basics/bytearray_slice_assign.py
Normal file
43
tests/basics/bytearray_slice_assign.py
Normal file
@ -0,0 +1,43 @@
|
||||
try:
|
||||
bytearray()[:] = bytearray()
|
||||
except TypeError:
|
||||
print("SKIP")
|
||||
import sys
|
||||
sys.exit()
|
||||
|
||||
# test slices; only 2 argument version supported by Micro Python at the moment
|
||||
x = bytearray(range(10))
|
||||
|
||||
# Assignment
|
||||
l = bytearray(x)
|
||||
l[1:3] = bytearray([10, 20])
|
||||
print(l)
|
||||
l = bytearray(x)
|
||||
l[1:3] = bytearray([10])
|
||||
print(l)
|
||||
l = bytearray(x)
|
||||
l[1:3] = bytearray()
|
||||
print(l)
|
||||
l = bytearray(x)
|
||||
#del l[1:3]
|
||||
print(l)
|
||||
|
||||
l = bytearray(x)
|
||||
l[:3] = bytearray([10, 20])
|
||||
print(l)
|
||||
l = bytearray(x)
|
||||
l[:3] = bytearray()
|
||||
print(l)
|
||||
l = bytearray(x)
|
||||
#del l[:3]
|
||||
print(l)
|
||||
|
||||
l = bytearray(x)
|
||||
l[:-3] = bytearray([10, 20])
|
||||
print(l)
|
||||
l = bytearray(x)
|
||||
l[:-3] = bytearray()
|
||||
print(l)
|
||||
l = bytearray(x)
|
||||
#del l[:-3]
|
||||
print(l)
|
Loading…
x
Reference in New Issue
Block a user