Diffstat (limited to 'tests/common/protocol/tag.rs')
| -rw-r--r-- | tests/common/protocol/tag.rs | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/tests/common/protocol/tag.rs b/tests/common/protocol/tag.rs index 890157e..db11438 100644 --- a/tests/common/protocol/tag.rs +++ b/tests/common/protocol/tag.rs @@ -1,9 +1,12 @@ use mockall::mock; use treaty::{ any::any_trait, - effect::{Effect, Effective, ErasedEffective}, - protocol::visitor::{Tag, TagKind, TagProto, VisitResult}, - DynWalkerObjSafe, + effect::{blocking::Blocking, Effect, Effective, ErasedEffective}, + protocol::{ + visitor::{visit_tag, Tag, TagConst, TagKind, TagProto, VisitResult}, + AsVisitor, DynVisitor, + }, + DynWalkerObjSafe, Flow, Walker, }; mock! { @@ -29,3 +32,19 @@ impl<'ctx, K: TagKind, E: Effect> Tag<'ctx, K, E> for MockTagVisitor<K, E> { E::ready(self.visit(kind, walker)) } } + +pub trait TagVisitorExt<'ctx> { + fn visit_tag_and_done<'a, const TAG: u64, W: Walker<'ctx, Blocking>>(&'a mut self, walker: W); +} + +impl<'ctx, T> TagVisitorExt<'ctx> for T +where + T: AsVisitor<'ctx>, +{ + fn visit_tag_and_done<'a, const TAG: u64, W: Walker<'ctx, Blocking>>(&'a mut self, walker: W) { + let result = + visit_tag::<TagConst<TAG>, Blocking, _>(TagConst, self.as_visitor(), walker).value(); + + assert_eq!(result.unwrap(), VisitResult::Control(Flow::Done)); + } +} |