tests/basics: Add tests for list and bytearray growing using themselves.

This commit is contained in:
Damien George 2017-04-02 17:31:32 +10:00
parent a5500a8aad
commit bf51e2ff98
2 changed files with 10 additions and 0 deletions

View File

@ -51,6 +51,11 @@ b = bytearray(10)
b[:-1] = bytearray(500) b[:-1] = bytearray(500)
print(len(b), b[0], b[-1]) print(len(b), b[0], b[-1])
# extension with self on RHS
b = bytearray(x)
b[4:] = b
print(b)
# Assignment of bytes to array slice # Assignment of bytes to array slice
b = bytearray(2) b = bytearray(2)
b[1:1] = b"12345" b[1:1] = b"12345"

View File

@ -26,3 +26,8 @@ print(l)
l = list(x) l = list(x)
l[100:100] = [10, 20, 30, 40] l[100:100] = [10, 20, 30, 40]
print(l) print(l)
# growing by using itself on RHS
l = list(range(10))
l[4:] = l
print(l)