summaryrefslogtreecommitdiffstatshomepage
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/basics/bytearray_slice_assign.py43
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)