Module
poke/capture
src/poke/capture.pookaGive a callback a small notebook for its standard output. The original group leader is restored on success and exceptions, and nested captures keep separate notebooks. Join child processes before leaving the scope. This captures standard IO, not global standard_error or logger output; replacing shared devices would interfere with tests running beside this one.
API reference
class Captured(value: a, text: String)
value: a
INFERRED
atext: String
INFERRED
String
INFERRED
fn(a, String) -> poke/capture.Captured(a)output(run: fn() -> a) -> Captured(a)
INFERRED
fn(fn() -> a) -> poke/capture.Captured(a)Capture standard output, returning the callback's value unchanged. Exceptions are re-raised after restoring the caller's device and stopping the collector.
let found = capture.output(fn() { io.println("hello") })
should.equal(found.text, "hello\n")
attempt(run: fn() -> a) -> Captured(Result(a, Failure))
INFERRED
fn(fn() -> a) -> poke/capture.Captured(Result(a, poke/failure.Failure))Keep the output and a structured failure together when a callback fails. The callback runs in the current process, so ordinary fixtures still apply.