Diffstat (limited to 'tests/common/protocol/value.rs')
-rw-r--r--tests/common/protocol/value.rs34
1 files changed, 27 insertions, 7 deletions
diff --git a/tests/common/protocol/value.rs b/tests/common/protocol/value.rs
index 690d3d1..898b21d 100644
--- a/tests/common/protocol/value.rs
+++ b/tests/common/protocol/value.rs
@@ -4,7 +4,7 @@ use treaty::{
effect::{blocking::Blocking, Effect, Effective, ErasedEffective, Ss},
protocol::{
visitor::{visit_value, Value, ValueProto, VisitResult},
- DynVisitor,
+ AsVisitor, DynVisitor,
},
Flow,
};
@@ -46,19 +46,39 @@ where
}
}
-pub trait ValueVisitorExt<'a, 'ctx: 'a> {
- fn visit_value_and_done<T>(self, value: T)
+pub trait ValueVisitorExt<'ctx> {
+ fn visit_value_and_done<'a, T>(&'a mut self, value: T)
where
- T: TypeName::LowerType<'a, 'ctx>;
+ T: TypeName::LowerType<'a, 'ctx>,
+ 'ctx: 'a;
+
+ fn visit_value_and_skipped<'a, T>(&'a mut self, value: T)
+ where
+ T: TypeName::LowerType<'a, 'ctx>,
+ 'ctx: 'a;
}
-impl<'a, 'ctx: 'a> ValueVisitorExt<'a, 'ctx> for DynVisitor<'a, 'ctx> {
- fn visit_value_and_done<T>(self, value: T)
+impl<'ctx, U> ValueVisitorExt<'ctx> for U
+where
+ U: AsVisitor<'ctx>,
+{
+ fn visit_value_and_done<'a, T>(&'a mut self, value: T)
where
T: TypeName::LowerType<'a, 'ctx>,
+ 'ctx: 'a,
{
- let result = visit_value::<_, Blocking>(self, value).value();
+ let result = visit_value::<_, Blocking>(self.as_visitor(), value).value();
assert_eq!(result, VisitResult::Control(Flow::Done));
}
+
+ fn visit_value_and_skipped<'a, T>(&'a mut self, value: T)
+ where
+ T: TypeName::LowerType<'a, 'ctx>,
+ 'ctx: 'a,
+ {
+ let result = visit_value::<_, Blocking>(self.as_visitor(), value).value();
+
+ assert_eq!(result.unit_skipped(), VisitResult::Skipped(()));
+ }
}