✓
Passing This code compiles and runs correctly.
Code
// std/channel — close does not drop the backlog: a closed channel still
// answers `| some` until the ring is drained, then `| closed`.
import std/io
import std/proto
import std/channel
std/proto(Reading) {
id: u64
ts: f64
}
pub tor mk-reading { i: u64, t: f64 } -> Reading
mk-reading -> { id: i, ts: t }
std/channel:new(inbox, capacity: 4) { reading: Reading }
mk-reading(i: 11, t: 1.0): r1 |> std/channel:send(inbox, r1)
| ok |> mk-reading(i: 22, t: 2.0): r2 |> std/channel:send(inbox, r2)
| ok |> std/channel:close(inbox)
| ok |> std/channel:recv(inbox)
| some a |> std/io:print.ln("drain {{ a.id:d }}") |> std/channel:recv(inbox)
| some b |> std/io:print.ln("drain {{ b.id:d }}") |> std/channel:recv(inbox)
| some c |> std/io:print.ln("unexpected {{ c.id:d }}")
| none |> std/io:print.ln("none after drain")
| closed |> std/io:print.ln("closed after drain")
| none |> std/io:print.ln("none too early")
| closed |> std/io:print.ln("closed too early")
| none |> std/io:print.ln("none first")
| closed |> std/io:print.ln("closed first")
| full |> std/io:print.ln("send2 full")
| closed |> std/io:print.ln("send2 closed")
| full |> std/io:print.ln("send1 full")
| closed |> std/io:print.ln("send1 closed")
Actual
drain 11
drain 22
closed after drain
Expected output
drain 11
drain 22
closed after drain
Flows
flow ~std/proto click a branch to expand · @labels scroll to their anchor
std/proto (Reading, source: id: u64
ts: f64)
flow ~new click a branch to expand · @labels scroll to their anchor
new (expr: inbox, capacity: 4, source: reading: Reading)
flow ~mk-reading click a branch to expand · @labels scroll to their anchor
mk-reading (i: 11, t: 1.0)
Test Configuration
MUST_RUN