expect
fn · Source line 41
pub fn expect[T](v: T ! {none}, msg: str) -> Tv's value, or a trap carrying msg when v is absent — the assertion form of absence handling, for a miss the caller has already ruled out by construction.
Rows: consumes none. Traps assert ([conf.trap.map]) on the miss, after printing one FAILED: {msg} line, exactly as testing.fail does. It never returns normally on a miss: a trap ends the process (D30, no unwinding), which is why this is the wrong tool for data-driven absence and the right one for an invariant.
Example (prose — a row value has no literal, F-0038; runnable in tests/x/option_expect/expect_trap.lu): option_expect.expect(find(5), "5 is positive") is 5; option_expect.expect(find(0), "0 is positive") prints FAILED: 0 is positive and traps assert.