pub fn classify_assertion(
stmt: &AIRNode,
) -> Option<(TestAssertion, &AIRNode, Option<&AIRNode>)>Expand description
If stmt is an expect(actual).<assertion>(expected?) chain, classify it.
Returns (assertion, actual_expr, expected_expr_opt) where actual_expr is
the argument to expect(...) and expected_expr_opt is the explicit
argument to the assertion method (present for TestAssertion::Equal,
absent for the nullary predicates). Returns None for any statement that is
not an expect(...)-rooted assertion chain — the emitter falls back to its
normal statement lowering for those.
A Bock method call recv.m(args) is lowered (by bock-air::lower) to
Call { callee: FieldAccess(recv, m), args: [self=recv, ...args] } — the
receiver is prepended as the implicit self argument. So an assertion
expect(actual).to_equal(expected) is:
Call {
callee: FieldAccess(object: Call{expect, [actual]}, field: to_equal),
args: [ self = Call{expect, [actual]}, expected ],
}The explicit expected is therefore args[1] (args[0] is the self copy).