1
0
forked from Mirror/wren
Files
wren/test/core/string/iterator_value.wren
Bob Nystrom 58e4d26648 "IO" -> "System".
Get rid of the separate opt-in IO class and replace it with a core
System class.

- Remove wren_io.c, wren_io.h, and io.wren.
- Remove the flags that disable it.
- Remove the overloads for print() with different arity. (It was an
  experiment, but I don't think it's that useful.)
- Remove IO.read(). That will reappear using libuv in the CLI at some
  point.
- Remove IO.time. Doesn't seem to have been used.
- Update all of the tests, docs, etc.

I'm sorry for all the breakage this causes, but I think "System" is a
better name for this class (it makes it natural to add things like
"System.gc()") and frees up "IO" for referring to the CLI's IO module.
2015-09-15 07:46:09 -07:00

20 lines
841 B
Plaintext

var s = "abçd"
System.print(s.iteratorValue(0)) // expect: a
System.print(s.iteratorValue(1)) // expect: b
System.print(s.iteratorValue(2)) // expect: ç
// Iterator value in middle of UTF sequence is the unencoded byte.
System.print(s.iteratorValue(3) == "\xa7") // expect: true
System.print(s.iteratorValue(4)) // expect: d
// 8-bit clean.
var t = "a\0b\0c"
System.print(t.iteratorValue(0) == "a") // expect: true
System.print(t.iteratorValue(1) == "\0") // expect: true
System.print(t.iteratorValue(2) == "b") // expect: true
System.print(t.iteratorValue(3) == "\0") // expect: true
System.print(t.iteratorValue(4) == "c") // expect: true
// Returns single byte strings for invalid UTF-8 sequences.
System.print("\xef\xf7".iteratorValue(0) == "\xef") // expect: true
System.print("\xef\xf7".iteratorValue(1) == "\xf7") // expect: true