tests: Add test for array slice assignment.

This commit is contained in:
Paul Sokolovsky 2015-02-27 22:16:35 +02:00
parent cefcbb22b2
commit 992284be39
1 changed files with 43 additions and 0 deletions

View 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)