Diffstat (limited to 'tests/common/protocol/value.rs')
| -rw-r--r-- | tests/common/protocol/value.rs | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/tests/common/protocol/value.rs b/tests/common/protocol/value.rs index b0f2273..690d3d1 100644 --- a/tests/common/protocol/value.rs +++ b/tests/common/protocol/value.rs @@ -1,8 +1,11 @@ use mockall::mock; use treaty::{ - any::{any_trait, TypeName}, - effect::{Effect, Effective, ErasedEffective}, - protocol::visitor::{Value, ValueProto, VisitResult}, + any::{any_trait, OwnedStatic, TypeName}, + effect::{blocking::Blocking, Effect, Effective, ErasedEffective, Ss}, + protocol::{ + visitor::{visit_value, Value, ValueProto, VisitResult}, + DynVisitor, + }, Flow, }; @@ -19,7 +22,7 @@ any_trait! { impl['ctx, T, E] MockValueVisitor<T, E> = [ ValueProto<T, E> ] where - T: TypeName::MemberType, + T: TypeName::MemberType + Ss, for<'a, 'b> TypeName::T<'a, 'b, T>: Sized, E: Effect, } @@ -42,3 +45,20 @@ where }) } } + +pub trait ValueVisitorExt<'a, 'ctx: 'a> { + fn visit_value_and_done<T>(self, value: T) + where + T: TypeName::LowerType<'a, 'ctx>; +} + +impl<'a, 'ctx: 'a> ValueVisitorExt<'a, 'ctx> for DynVisitor<'a, 'ctx> { + fn visit_value_and_done<T>(self, value: T) + where + T: TypeName::LowerType<'a, 'ctx>, + { + let result = visit_value::<_, Blocking>(self, value).value(); + + assert_eq!(result, VisitResult::Control(Flow::Done)); + } +} |