Allow empty ranges at the end of a sequence.
This commit is contained in:
@@ -33,3 +33,7 @@ System.print(list[3...-6]) // expect: [d, c, b, a]
|
||||
// An empty range at zero is allowed on an empty list.
|
||||
System.print([][0...0]) // expect: []
|
||||
System.print([][0..-1]) // expect: []
|
||||
|
||||
// An empty range at the end is allowed on a list.
|
||||
System.print([1, 2, 3][3...3]) // expect: []
|
||||
System.print([1, 2, 3][3..-1]) // expect: []
|
||||
|
||||
@@ -33,6 +33,10 @@ System.print(string[3...-6]) // expect: dcba
|
||||
System.print(""[0...0] == "") // expect: true
|
||||
System.print(""[0..-1] == "") // expect: true
|
||||
|
||||
// An empty range at the end is allowed on a string.
|
||||
System.print("abc"[3...3] == "") // expect: true
|
||||
System.print("abc"[3..-1] == "") // expect: true
|
||||
|
||||
// Indexes by byte, not code point.
|
||||
//
|
||||
// Bytes: 11111
|
||||
|
||||
Reference in New Issue
Block a user