Diffstat (limited to 'tests/protocol_visitor_request_hint.rs')
| -rw-r--r-- | tests/protocol_visitor_request_hint.rs | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/tests/protocol_visitor_request_hint.rs b/tests/protocol_visitor_request_hint.rs index dee681d..098e24d 100644 --- a/tests/protocol_visitor_request_hint.rs +++ b/tests/protocol_visitor_request_hint.rs @@ -1,10 +1,7 @@ use std::any::TypeId; use common::{ - protocol::{ - hint::MockHintWalker, - request_hint::{MockRequestHintVisitor, RequestHintFactory}, - }, + protocol::{hint::MockHintWalker, request_hint::MockRequestHintVisitor}, walker::MockWalker, }; use mockall::predicate::eq; @@ -28,25 +25,23 @@ fn hints_can_be_requested() { let mut mock = MockRequestHintVisitor::<Blocking>::new(); // We will request a hint from the visitor. - mock.expect_request_hint().once().return_const( - (|_, mut walker| { - // Lookup the value protocol on the walker. - let obj = walker - .upcast_mut::<HintProto<ValueProto<OwnedStatic<i32>, Blocking>>>() - .unwrap(); - - // Get the known for the value protocol. - assert_eq!( - obj.known(&()).value(), - Ok(ValueKnown { - preview: Some(&OwnedStatic(42)) - }) - ); - - // We are done. - VisitResult::Control(Flow::Done) - }) as RequestHintFactory, - ); + mock.expect_request_hint().once().returning(|mut walker| { + // Lookup the value protocol on the walker. + let obj = walker + .upcast_mut::<HintProto<ValueProto<OwnedStatic<i32>, Blocking>>>() + .unwrap(); + + // Get the known for the value protocol. + assert_eq!( + obj.known(&()).value(), + Ok(ValueKnown { + preview: Some(&OwnedStatic(42)) + }) + ); + + // We are done. + VisitResult::Control(Flow::Done) + }); // This mock becomes the visitor. let visitor: &mut dyn RequestHint<Blocking> = &mut mock; |