class Test def main is shared s = 'aoeu' assert s[0:4]=='aoeu' assert s[0:3]=='aoe' assert s[0:2]=='ao' assert s[0:1]=='a' assert s[0:0]=='' assert s[1:4]=='oeu' assert s[2:4]=='eu' assert s[3:4]=='u' assert s[4:4]=='' assert s[0:-1]=='aoe' assert s[0:-2]=='ao' assert s[0:-3]=='a' assert s[0:-4]=='' assert s[1:-1]=='oe' assert s[1:3:1]=='oe' assert s[:4]=='aoeu' assert s[0:]=='aoeu' assert s[:-1]=='aoe' assert s[:-2]=='ao' assert s[:-3]=='a' assert s[:-4]=='' assert s[0:]=='aoeu' assert s[1:]=='oeu' assert s[2:]=='eu' assert s[3:]=='u' assert s[4:]=='' # a step other than 1 is not current supported assert s[1:-1:1]=='oe' assert s[::1]=='aoeu' # out of range does not complain (convenient and like Python) assert s[0:5]=='aoeu' assert s[5:5]=='' assert s[0:-5]=='' # using slice in string substitution # this is tricky for the implementation because colon is also used to format strings like '[s:N]' assert '[s[1:3]]'=='oe'