//ww:run-exit 55 // Migrated from 778_bufio_vstream_run row stream_unread. package main; import bufio; import memio; import io; export fn main() i32 = { let raw: [4]u8; raw[0]=88u8; raw[1]=89u8; raw[2]=90u8; let mst: memio.stream = memio.dynamicfrom(raw[0:3]); let vs: io.stream = &mst.vt; let rbuf: [4]u8; let wbuf: [4]u8; let b: bufio.stream = bufio.newstream(vs, rbuf[0:4], wbuf[0:4]); let bvs: io.stream = &b.vt; let out: [4]u8; let rd = io.read(bvs, out[0:3]); let n: size = 0; if (rd is size) { n = rd as size; }; if (n != 3: size || out[0] != 88u8 || out[2] != 90u8) { return 81; }; let push: [2]u8; push[0]=88u8; push[1]=89u8; bufio.unread(&b, push[0:2]); let out2: [2]u8; let rd2 = io.read(bvs, out2[0:2]); let n2: size = 0; if (rd2 is size) { n2 = rd2 as size; }; if (n2 != 2: size || out2[0] != 88u8 || out2[1] != 89u8) { return 82; }; return 55; };