test: prove package initialization semantics
This commit is contained in:
@@ -73,7 +73,7 @@ fn checkpartialflush(zero: bool) void = {
|
||||
sink.zero = zero;
|
||||
let rb: [1]u8;
|
||||
let wb: [4]u8;
|
||||
let b: bufio.stream = bufio.init(&sink.vt, rb[0:1], wb[0:4]);
|
||||
let b: bufio.stream = bufio.newstream(&sink.vt, rb[0:1], wb[0:4]);
|
||||
let src: [4]u8;
|
||||
let _: i32 = sputstr("ABCD", src[0:4], 0);
|
||||
let wr: (size | io.error) = io.write(&b.vt, src[0:4]);
|
||||
@@ -109,7 +109,7 @@ fn checkpartialflush(zero: bool) void = {
|
||||
|
||||
let rb: [8]u8;
|
||||
let wb: [8]u8;
|
||||
let b: bufio.stream = bufio.init(m, rb[0:8], wb[0:8]);
|
||||
let b: bufio.stream = bufio.newstream(m, rb[0:8], wb[0:8]);
|
||||
|
||||
// Write under the buffer limit — nothing reaches src.
|
||||
let buf: [5]u8;
|
||||
@@ -139,7 +139,7 @@ fn checkpartialflush(zero: bool) void = {
|
||||
|
||||
let rb: [4]u8;
|
||||
let wb: [4]u8;
|
||||
let b: bufio.stream = bufio.init(m, rb[0:4], wb[0:4]);
|
||||
let b: bufio.stream = bufio.newstream(m, rb[0:4], wb[0:4]);
|
||||
|
||||
// 10B payload through a 4B wbuf: bwrite must flush twice mid-write.
|
||||
let buf: [10]u8;
|
||||
@@ -170,7 +170,7 @@ fn checkpartialflush(zero: bool) void = {
|
||||
|
||||
let rb: [4]u8;
|
||||
let wb: [16]u8;
|
||||
let b: bufio.stream = bufio.init(m, rb[0:4], wb[0:16]);
|
||||
let b: bufio.stream = bufio.newstream(m, rb[0:4], wb[0:16]);
|
||||
|
||||
let p: io.stream = &b.vt;
|
||||
|
||||
@@ -204,7 +204,7 @@ fn checkpartialflush(zero: bool) void = {
|
||||
|
||||
let rb: [4]u8;
|
||||
let wb: [16]u8;
|
||||
let b: bufio.stream = bufio.init(m, rb[0:4], wb[0:16]);
|
||||
let b: bufio.stream = bufio.newstream(m, rb[0:4], wb[0:16]);
|
||||
let nilbs: [1]u8;
|
||||
bufio.setflush(&b, nilbs[0:0]);
|
||||
|
||||
@@ -245,7 +245,7 @@ fn checkpartialflush(zero: bool) void = {
|
||||
|
||||
let rb: [4]u8;
|
||||
let wb: [4]u8;
|
||||
let b: bufio.stream = bufio.init(m, rb[0:4], wb[0:4]);
|
||||
let b: bufio.stream = bufio.newstream(m, rb[0:4], wb[0:4]);
|
||||
|
||||
assert(!(!bufio.isbuffered(&b.vt)));
|
||||
assert(!(bufio.isbuffered(m)));
|
||||
@@ -264,7 +264,7 @@ fn checkpartialflush(zero: bool) void = {
|
||||
|
||||
let rb: [8]u8;
|
||||
let wb: [4]u8;
|
||||
let b: bufio.stream = bufio.init(m, rb[0:8], wb[0:4]);
|
||||
let b: bufio.stream = bufio.newstream(m, rb[0:8], wb[0:4]);
|
||||
|
||||
let p: io.stream = &b.vt;
|
||||
|
||||
@@ -303,7 +303,7 @@ fn checkpartialflush(zero: bool) void = {
|
||||
|
||||
let rb: [8]u8;
|
||||
let wb: [4]u8;
|
||||
let b: bufio.stream = bufio.init(m, rb[0:8], wb[0:4]);
|
||||
let b: bufio.stream = bufio.newstream(m, rb[0:8], wb[0:4]);
|
||||
|
||||
let p: io.stream = &b.vt;
|
||||
|
||||
@@ -339,7 +339,7 @@ fn checkpartialflush(zero: bool) void = {
|
||||
|
||||
let rb: [8]u8;
|
||||
let wb: [4]u8;
|
||||
let b: bufio.stream = bufio.init(m, rb[0:8], wb[0:4]);
|
||||
let b: bufio.stream = bufio.newstream(m, rb[0:8], wb[0:4]);
|
||||
|
||||
let p: io.stream = &b.vt;
|
||||
|
||||
@@ -385,7 +385,7 @@ fn checkpartialflush(zero: bool) void = {
|
||||
let rb: [4]u8;
|
||||
let _: i32 = sputstr("ABCD", rb[0:4], 0);
|
||||
let wb: [1]u8;
|
||||
let b: bufio.stream = bufio.init(&mem.vt, rb[0:4], wb[0:1]);
|
||||
let b: bufio.stream = bufio.newstream(&mem.vt, rb[0:4], wb[0:1]);
|
||||
bufio.unread(&b, rb[0:3]);
|
||||
let out: [3]u8;
|
||||
let r: (size | io.eof | io.error) = io.read(&b.vt, out[0:3]);
|
||||
@@ -406,7 +406,7 @@ fn checkpartialflush(zero: bool) void = {
|
||||
|
||||
let rb: [16]u8;
|
||||
let wb: [4]u8;
|
||||
let b: bufio.stream = bufio.init(m, rb[0:16], wb[0:4]);
|
||||
let b: bufio.stream = bufio.newstream(m, rb[0:16], wb[0:4]);
|
||||
|
||||
let push: [3]u8;
|
||||
push[0] = 88u8; push[1] = 89u8; push[2] = 90u8; // "XYZ"
|
||||
@@ -437,7 +437,7 @@ fn checkpartialflush(zero: bool) void = {
|
||||
|
||||
let rb: [4]u8;
|
||||
let wb: [4]u8;
|
||||
let b: bufio.stream = bufio.init(m, rb[0:4], wb[0:4]);
|
||||
let b: bufio.stream = bufio.newstream(m, rb[0:4], wb[0:4]);
|
||||
|
||||
let r: (void | io.error) = bufio.flush(&b);
|
||||
match (r) {
|
||||
@@ -454,7 +454,7 @@ fn checkpartialflush(zero: bool) void = {
|
||||
|
||||
let rb: [4]u8;
|
||||
let wb: [4]u8;
|
||||
let b: bufio.stream = bufio.init(m, rb[0:4], wb[0:4]);
|
||||
let b: bufio.stream = bufio.newstream(m, rb[0:4], wb[0:4]);
|
||||
let nilbs: [1]u8;
|
||||
bufio.setflush(&b, nilbs[0:0]); // suppress the default '\n' detector
|
||||
|
||||
@@ -490,7 +490,7 @@ fn checkpartialflush(zero: bool) void = {
|
||||
|
||||
let rb: [4]u8;
|
||||
let wb: [4]u8;
|
||||
let b: bufio.stream = bufio.init(src, rb[0:4], wb[0:4]);
|
||||
let b: bufio.stream = bufio.newstream(src, rb[0:4], wb[0:4]);
|
||||
let nilbs: [1]u8;
|
||||
bufio.setflush(&b, nilbs[0:0]); // suppress the default '\n' detector
|
||||
|
||||
@@ -524,7 +524,7 @@ fn checkpartialflush(zero: bool) void = {
|
||||
|
||||
let rb: [4]u8;
|
||||
let wb: [16]u8;
|
||||
let b: bufio.stream = bufio.init(m, rb[0:4], wb[0:16]);
|
||||
let b: bufio.stream = bufio.newstream(m, rb[0:4], wb[0:16]);
|
||||
let bs: [1]u8;
|
||||
bs[0] = 32u8; // ' '
|
||||
bufio.setflush(&b, bs[0:1]);
|
||||
|
||||
Reference in New Issue
Block a user