mirror of
https://github.com/micropython/micropython.git
synced 2026-01-05 03:30:14 +01:00
objlist: Implement growing slice assignment.
This means that complete slice operations are supported for lists (but not for bytearray's and array.array's).
This commit is contained in:
28
tests/basics/list_slice_assign_grow.py
Normal file
28
tests/basics/list_slice_assign_grow.py
Normal file
@@ -0,0 +1,28 @@
|
||||
x = list(range(2))
|
||||
|
||||
l = list(x)
|
||||
l[0:0] = [10]
|
||||
print(l)
|
||||
l = list(x)
|
||||
l[:0] = [10, 20]
|
||||
print(l)
|
||||
l = list(x)
|
||||
l[0:0] = [10, 20, 30, 40]
|
||||
print(l)
|
||||
|
||||
l = list(x)
|
||||
l[1:1] = [10, 20, 30, 40]
|
||||
print(l)
|
||||
|
||||
l = list(x)
|
||||
l[2:] = [10, 20, 30, 40]
|
||||
print(l)
|
||||
|
||||
# Weird cases
|
||||
l = list(x)
|
||||
l[1:0] = [10, 20, 30, 40]
|
||||
print(l)
|
||||
|
||||
l = list(x)
|
||||
l[100:100] = [10, 20, 30, 40]
|
||||
print(l)
|
||||
Reference in New Issue
Block a user