diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2015-02-27 22:16:35 +0200 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2015-02-27 22:17:24 +0200 |
commit | 992284be39857f61c9b408ed4a6dad4ca5bfe7f9 (patch) | |
tree | 4982df3822d3fde8a5a26f70b39dc4d251b7c02a /tests/basics | |
parent | cefcbb22b2befac1baa9953c477fcee4031635d3 (diff) | |
download | micropython-992284be39857f61c9b408ed4a6dad4ca5bfe7f9.tar.gz micropython-992284be39857f61c9b408ed4a6dad4ca5bfe7f9.zip |
tests: Add test for array slice assignment.
Diffstat (limited to 'tests/basics')
-rw-r--r-- | tests/basics/bytearray_slice_assign.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/basics/bytearray_slice_assign.py b/tests/basics/bytearray_slice_assign.py new file mode 100644 index 0000000000..0b476ae0ac --- /dev/null +++ b/tests/basics/bytearray_slice_assign.py @@ -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) |