mirror of
https://github.com/micropython/micropython.git
synced 2026-01-05 03:30:14 +01:00
py/objlist: Make list += accept all arguments and add test.
This commit is contained in:
33
tests/basics/list_extend.py
Normal file
33
tests/basics/list_extend.py
Normal file
@@ -0,0 +1,33 @@
|
||||
# test list.__iadd__ and list.extend (they are equivalent)
|
||||
|
||||
l = [1, 2]
|
||||
l.extend([])
|
||||
print(l)
|
||||
|
||||
l.extend([3])
|
||||
print(l)
|
||||
|
||||
l.extend([4, 5])
|
||||
print(l)
|
||||
|
||||
l.extend(range(6, 10))
|
||||
print(l)
|
||||
|
||||
l.extend("abc")
|
||||
print(l)
|
||||
|
||||
l = [1, 2]
|
||||
l += []
|
||||
print(l)
|
||||
|
||||
l += [3]
|
||||
print(l)
|
||||
|
||||
l += [4, 5]
|
||||
print(l)
|
||||
|
||||
l += range(6, 10)
|
||||
print(l)
|
||||
|
||||
l += "abc"
|
||||
print(l)
|
||||
Reference in New Issue
Block a user