Fix conversion if (int x = foo()). Initial stream api. Extended enumset.

This commit is contained in:
Christoffer Lerno
2023-02-22 17:06:06 +01:00
parent 8f5676b488
commit b175b9318a
11 changed files with 541 additions and 35 deletions

View File

@@ -0,0 +1,25 @@
module std::io @test;
fn void! bytestream()
{
ByteReader r;
r.init("abc");
Stream s = r.as_stream();
assert(s.len()? == 3);
char[5] buffer;
assert('a' == s.read_byte()?);
s.pushback_byte()?;
usz len = s.read(&buffer)?;
assert(buffer[:len] == "abc");
ByteWriter w;
w.init();
Stream ws = w.as_stream();
ws.write("helloworld")?;
assert(w.as_str() == "helloworld");
s.seek(0, SET)?;
ws.read_from(&s)?;
s.seek(1, SET)?;
s.write_to(&ws)?;
assert(w.as_str() == "helloworldabcbc");
}