Skip to content
Playground(another site)

bynk.expect.impure_predicate

Error An expect predicate contains an effectful call (a sub-expression of type Effect[_]); a predicate must be pure.

An expect predicate is a pure claim: the same predicate surface as invariant and ensures. A capability or service call inside it, even one held in a list or returned by a lambda, would run when the claim is checked, and its call would be recorded as if the unit under test had made it. Run the call before the claim with let x <- …, then state the claim about x. A fault claim (expect <call> faults) is the one form that runs its call.

Example

tests/pay.test.bynk
expect [Logger.log("x")].length() == 1 // ✗ runs Logger.log
let r <- authorise.call(100)
expect r is Ok(_) // ✓ the call runs first

In the Book

See also

  • The grammar rule it governs: expect_expr.
  • Every code in its category, Expectations, on the diagnostic index.
  • bynk explain bynk.expect.impure_predicate shows the same from the installed toolchain, without a network.