class Test def main is shared t = [1, 2, 3, 4] assert t[0:4]==[1, 2, 3, 4] assert t[0:3]==[1, 2, 3] assert t[0:2]==[1, 2] assert t[0:1]==[1] assert t[0:0]==[] assert t[1:4]==[2, 3, 4] assert t[2:4]==[3, 4] assert t[3:4]==[4] assert t[4:4]==[] assert t[0:-1]==[1, 2, 3] assert t[0:-2]==[1, 2] assert t[0:-3]==[1] assert t[0:-4]==[] assert t[1:-1]==[2, 3] assert t[1:3:1]==[2, 3] assert t[:4]==[1, 2, 3, 4] assert t[0:]==[1, 2, 3, 4] assert t[:-1]==[1, 2, 3] assert t[:-2]==[1, 2] assert t[:-3]==[1] assert t[:-4]==[] assert t[0:]==[1, 2, 3, 4] assert t[1:]==[2, 3, 4] assert t[2:]==[3, 4] assert t[3:]==[4] assert t[4:]==[] # a step other than 1 is not current supported assert t[1:-1:1]==[2, 3] assert t[::1]==[1, 2, 3, 4] # out of range does not complain assert t[0:5]==[1,2,3,4] assert t[5:5]==[] assert t[0:-5]==[] assert t[3:2]==[] # using slice in string substitution # this is tricky for the implementation because colon is also used to format strings like '[s:N]' assert '[CobraCore.toTechString(t[1:3])]'==r'List[2, 3]' # IList ilist as IList = t assert ilist[:-1]==[1, 2, 3]