1
0
forked from Mirror/wren
Files
wren/test/core/string_byte_sequence/iterate.wren
Bob Nystrom 72c38a59ce More stuff for working with strings and bytes!
- "\x" escape sequence to put byte values in strings: "\x34"
- String.byteAt(index) gets value of byte in string.
- String.bytes returns a raw sequence of bytes for a string.
- String.codePointAt(index) gets the code point at an offset as a raw number.
2015-03-27 20:44:07 -07:00

22 lines
651 B
Plaintext

// Bytes:
// 012345678
// Chars: sø mé ஃ
var bytes = "søméஃ".bytes
IO.print(bytes.iterate(null)) // expect: 0
IO.print("".bytes.iterate(null)) // expect: false
IO.print(bytes.iterate(0)) // expect: 1
IO.print(bytes.iterate(1)) // expect: 2
IO.print(bytes.iterate(2)) // expect: 3
IO.print(bytes.iterate(3)) // expect: 4
IO.print(bytes.iterate(4)) // expect: 5
IO.print(bytes.iterate(5)) // expect: 6
IO.print(bytes.iterate(6)) // expect: 7
IO.print(bytes.iterate(7)) // expect: 8
IO.print(bytes.iterate(8)) // expect: false
// Out of bounds.
IO.print(bytes.iterate(123)) // expect: false
IO.print(bytes.iterate(-1)) // expect: false