✓
Passing This code compiles and runs correctly.
Code
// MIRROR for `std/channel:new`, `std/channel:send`, `std/channel:recv`,
// `std/channel:close`, `std/channel:default` and `std/channel:consume` —
// all declared and used from an imported module. `app/lib` owns two
// channels: `inbox` carries a `! reading`/`! closed` join drained by a
// module-side pump, `outbox` answers plain send/recv/close. The transforms
// emit generated units (`__channel_*`) and this is the test that can see
// whether they qualify through the module's import-derived name — the
// entry file collapses file-name and module-name into one, so the 699_*
// controls cannot tell a correct qualifier from a lucky one.
import app/lib
app/lib:push(i: 7)
| ok |> app/lib:push(i: 8)
| ok |> app/lib:post(i: 3)
| ok |> app/lib:pull() |> app/lib:pull()
|> app/lib:shutdown() |> app/lib:seal() |> app/lib:go()
| full |> app/lib:seal()
| closed |> app/lib:seal()
| full |> app/lib:seal()
| closed |> app/lib:seal()
| full |> app/lib:seal()
| closed |> app/lib:seal()
Supporting Files
import std/io
import std/proto
import std/channel
import std/pump
std/proto(Reading) {
id: u64
}
std/channel:new(inbox, capacity: 4) { reading: Reading }
std/channel:new(outbox, capacity: 4) { reading: Reading }
std/channel(inbox)
! reading v |> std/io:print.ln("mod consumed {{ v.id:d }}")
! closed |> std/io:print.ln("mod saw close")
std/pump:create(main)
| drained |> std/io:print.ln("mod pump drained")
std/pump(main)
! step |> inbox-step()
! live |> inbox-live()
! wait i |> inbox-wait(i)
pub tor mk { i: u64 } -> Reading
mk -> { id: i }
pub tor push { i: u64 }
| ok
| full
| closed
push = mk(i): r |> std/channel:send(inbox, r)
| ok => ok
| full => full
| closed => closed
pub tor post { i: u64 }
| ok
| full
| closed
post = mk(i): r |> std/channel:send(outbox, r)
| ok => ok
| full => full
| closed => closed
pub tor pull {}
pull = std/channel:recv(outbox)
| some v |> std/io:print.ln("mod got {{ v.id:d }}")
| none |> std/io:print.ln("mod none")
| closed |> std/io:print.ln("mod closed")
pub tor shutdown {}
shutdown = std/channel:close(inbox)
| ok |> std/io:print.ln("mod closed it")
pub tor seal {}
seal = std/channel:close(outbox)
| ok |> std/io:print.ln("mod sealed outbox")
pub tor go {}
go = std/pump:run(main)
Actual
mod got 3
mod none
mod saw close
mod closed it
mod sealed outbox
mod consumed 7
mod consumed 8
mod pump drained
Expected output
mod got 3
mod none
mod saw close
mod closed it
mod sealed outbox
mod consumed 7
mod consumed 8
mod pump drained
Flows
flow ~push click a branch to expand · @labels scroll to their anchor
push (i: 7)
Test Configuration
MUST_RUN