2015-01-23 04:58:22 +00:00
|
|
|
var s = "abçd"
|
2015-09-15 14:46:09 +00:00
|
|
|
System.print(s.iterate(null)) // expect: 0
|
|
|
|
|
System.print(s.iterate(0)) // expect: 1
|
|
|
|
|
System.print(s.iterate(1)) // expect: 2
|
2015-01-23 04:58:22 +00:00
|
|
|
// Skip 3 because that's the middle of the ç sequence.
|
2015-09-15 14:46:09 +00:00
|
|
|
System.print(s.iterate(2)) // expect: 4
|
2015-01-23 04:58:22 +00:00
|
|
|
// Iterating from the middle of a UTF-8 sequence goes to the next one.
|
2015-09-15 14:46:09 +00:00
|
|
|
System.print(s.iterate(3)) // expect: 4
|
|
|
|
|
System.print(s.iterate(4)) // expect: false
|
2015-01-23 04:58:22 +00:00
|
|
|
|
|
|
|
|
// Out of bounds.
|
2015-09-15 14:46:09 +00:00
|
|
|
System.print(s.iterate(123)) // expect: false
|
|
|
|
|
System.print(s.iterate(-1)) // expect: false
|
2015-01-23 04:58:22 +00:00
|
|
|
|
|
|
|
|
// Nothing to iterate in an empty string.
|
2015-09-15 14:46:09 +00:00
|
|
|
System.print("".iterate(null)) // expect: false
|
feat: add 8-bit string test cases across concatenation, contains, count, ends_with, equality, index_of, iterate, iterator_value, join, starts_with, subscript, and to_string
2015-02-04 12:58:16 +00:00
|
|
|
|
2015-02-05 04:26:29 +00:00
|
|
|
// 8-bit clean.
|
2015-09-15 14:46:09 +00:00
|
|
|
System.print("a\0b\0c".iterate(null)) // expect: 0
|
|
|
|
|
System.print("a\0b\0c".iterate(0)) // expect: 1
|
|
|
|
|
System.print("a\0b\0c".iterate(1)) // expect: 2
|
|
|
|
|
System.print("a\0b\0c".iterate(2)) // expect: 3
|
|
|
|
|
System.print("a\0b\0c".iterate(3)) // expect: 4
|
|
|
|
|
System.print("a\0b\0c".iterate(4)) // expect: false
|
2015-09-11 14:56:01 +00:00
|
|
|
|
|
|
|
|
// Iterates over invalid UTF-8 one byte at a time.
|
2015-09-15 14:46:09 +00:00
|
|
|
System.print("\xef\xf7".iterate(null)) // expect: 0
|
|
|
|
|
System.print("\xef\xf7".iterate(0)) // expect: 1
|
|
|
|
|
System.print("\xef\xf7".iterate(1)) // expect: false
|