mirror of
https://github.com/micropython/micropython.git
synced 2026-01-07 04:30:24 +01:00
Merge pull request #59 from pfalcon/slice
Implement basic slice object and string slicing
This commit is contained in:
27
tests/basics/tests/slice-bstr1.py
Normal file
27
tests/basics/tests/slice-bstr1.py
Normal file
@@ -0,0 +1,27 @@
|
||||
b"123"[0:1]
|
||||
|
||||
b"123"[0:2]
|
||||
|
||||
b"123"[:1]
|
||||
|
||||
b"123"[1:]
|
||||
|
||||
# Idiom for copying sequence
|
||||
b"123"[:]
|
||||
|
||||
b"123"[:-1]
|
||||
|
||||
# Weird cases
|
||||
b"123"[0:0]
|
||||
b"123"[1:0]
|
||||
b"123"[1:1]
|
||||
b"123"[-1:-1]
|
||||
b"123"[-3:]
|
||||
b"123"[-3:3]
|
||||
b"123"[0:]
|
||||
b"123"[:0]
|
||||
b"123"[:-3]
|
||||
b"123"[:-4]
|
||||
# No IndexError!
|
||||
b""[1:1]
|
||||
b""[-1:-1]
|
||||
Reference in New Issue
Block a user