Diffstat (limited to 'tests/common/protocol/value.rs')
| -rw-r--r-- | tests/common/protocol/value.rs | 113 |
1 files changed, 73 insertions, 40 deletions
diff --git a/tests/common/protocol/value.rs b/tests/common/protocol/value.rs index b5b4031..6897a94 100644 --- a/tests/common/protocol/value.rs +++ b/tests/common/protocol/value.rs @@ -6,9 +6,9 @@ use effectful::{ }; use mockall::mock; use treaty::{ - any::{any_trait, OwnedStatic, TypeName}, + any::{type_name, AnyTrait, OwnedStatic}, protocol::{ - visitor::{visit_value, Value, ValueProto, VisitResult}, + visitor::{visit_value, Value, VisitResult}, AsVisitor, DynVisitor, }, Flow, @@ -17,59 +17,70 @@ use treaty::{ use crate::common::Blocking; mock! { - pub ValueVisitor<T: TypeName::MemberType<E>, E: Environment> + pub ValueVisitor<T: type_name::Static> where - for<'a, 'ctx> TypeName::T<'a, 'ctx, T, E>: Sized + for<'a, 'ctx> type_name::Lowered<'a, 'ctx, T>: Sized { - pub fn visit<'a, 'ctx>(&'a mut self, value: &TypeName::T<'a, 'ctx, T, E>) -> VisitResult<()>; + pub fn visit<'a, 'ctx>(&'a mut self, value: &type_name::Lowered<'a, 'ctx, T>) -> VisitResult<()>; } } -forward_send_sync!({} {} {T: (TypeName::MemberType<E>), E: (Environment)} MockValueVisitor<T, E> where { - for<'a, 'ctx> TypeName::T<'a, 'ctx, T, E>: Sized +forward_send_sync!({} {} {T: (type_name::Static)} MockValueVisitor<T> where { + for<'a, 'ctx> type_name::Lowered<'a, 'ctx, T>: Sized }); -any_trait! { - impl['ctx, T][E] MockValueVisitor<T, E> = [ - ValueProto<T, E> - ] where - T: TypeName::MemberType<E>, - for<'a, 'b> TypeName::T<'a, 'b, T, E>: Sized, - for<'a> Dynamic<TypeName::T<'a, 'ctx, T, E>>: DynBind<E>, - E: Environment, -} +// any_trait! { +// impl['ctx, T][E] MockValueVisitor<T, E> = [ +// ValueProto<T, E> +// ] where +// T: TypeName::MemberType<E>, +// for<'a, 'b> TypeName::T<'a, 'b, T, E>: Sized, +// for<'a> Dynamic<TypeName::T<'a, 'ctx, T, E>>: DynBind<E>, +// E: Environment, +// } -impl<'ctx, T: TypeName::MemberType<E>, E: Environment> Value<'ctx, T, E> for MockValueVisitor<T, E> +impl<'ctx, T: type_name::Static, E: Environment> Value<'ctx, T, E> for MockValueVisitor<T> where - for<'a, 'lt> TypeName::T<'a, 'lt, T, E>: Sized, - for<'a> Dynamic<TypeName::T<'a, 'ctx, T, E>>: DynBind<E>, + for<'a, 'b> type_name::Lowered<'a, 'b, T>: Sized, { - fn visit<'a>( - &'a mut self, - value: TypeName::T<'a, 'ctx, T, E>, - ) -> NativeForm<'a, VisitResult<Dynamic<TypeName::T<'a, 'ctx, T, E>>>, E> + fn visit<'this: 'value, 'value: 'e, 'e>( + &'this mut self, + value: type_name::Lowered<'value, 'ctx, T>, + ) -> NativeForm<'e, VisitResult<Dynamic<type_name::Lowered<'value, 'ctx, T>>>, E> where - 'ctx: 'a, + // type_name::Lowered<'value, 'ctx, T>: Sized, + Dynamic<type_name::Lowered<'value, 'ctx, T>>: DynBind<E>, + 'ctx: 'this + 'value, { - E::value(match self.visit(&value) { - VisitResult::Skipped(_) => VisitResult::Skipped(Dynamic(value)), - VisitResult::Control(flow) => VisitResult::Control(flow), - }) - .cast() + todo!() } + + // fn visit<'a>( + // &'a mut self, + // value: TypeName::T<'a, 'ctx, T, E>, + // ) -> NativeForm<'a, VisitResult<Dynamic<TypeName::T<'a, 'ctx, T, E>>>, E> + // where + // 'ctx: 'a, + // { + // E::value(match self.visit(&value) { + // VisitResult::Skipped(_) => VisitResult::Skipped(Dynamic(value)), + // VisitResult::Control(flow) => VisitResult::Control(flow), + // }) + // .cast() + // } } pub trait ValueVisitorExt<'ctx> { fn visit_value_and_done<'a, T>(&'a mut self, value: T) where - T: TypeName::LowerType<'a, 'ctx, Blocking>, - TypeName::HigherRanked<'a, 'ctx, T, Blocking>: TypeName::MemberType<Blocking>, + T: type_name::WithLt<'a, 'ctx>, + type_name::Raised<'a, 'ctx, T>: type_name::Static, 'ctx: 'a; fn visit_value_and_skipped<'a, T>(&'a mut self, value: T) where - T: TypeName::LowerType<'a, 'ctx, Blocking>, - TypeName::HigherRanked<'a, 'ctx, T, Blocking>: TypeName::MemberType<Blocking>, + T: type_name::WithLt<'a, 'ctx>, + type_name::Raised<'a, 'ctx, T>: type_name::Static, 'ctx: 'a; } @@ -80,8 +91,8 @@ where #[track_caller] fn visit_value_and_done<'a, T>(&'a mut self, value: T) where - T: TypeName::LowerType<'a, 'ctx, Blocking>, - TypeName::HigherRanked<'a, 'ctx, T, Blocking>: TypeName::MemberType<Blocking>, + T: type_name::WithLt<'a, 'ctx>, + type_name::Raised<'a, 'ctx, T>: type_name::Static, 'ctx: 'a, { let result = visit_value::<_, Blocking>(self.as_visitor(), value).into_value(); @@ -92,12 +103,34 @@ where #[track_caller] fn visit_value_and_skipped<'a, T>(&'a mut self, value: T) where - T: TypeName::LowerType<'a, 'ctx, Blocking>, - TypeName::HigherRanked<'a, 'ctx, T, Blocking>: TypeName::MemberType<Blocking>, + T: type_name::WithLt<'a, 'ctx>, + type_name::Raised<'a, 'ctx, T>: type_name::Static, 'ctx: 'a, { - let result = visit_value::<_, Blocking>(self.as_visitor(), value).into_value(); - - assert_eq!(result.unit_skipped(), VisitResult::Skipped(())); + todo!() } + + // #[track_caller] + // fn visit_value_and_done<'a, T>(&'a mut self, value: T) + // where + // T: TypeName::LowerType<'a, 'ctx, Blocking>, + // TypeName::HigherRanked<'a, 'ctx, T, Blocking>: TypeName::MemberType<Blocking>, + // 'ctx: 'a, + // { + // let result = visit_value::<_, Blocking>(self.as_visitor(), value).into_value(); + // + // assert_eq!(result, VisitResult::Control(Flow::Done)); + // } + // + // #[track_caller] + // fn visit_value_and_skipped<'a, T>(&'a mut self, value: T) + // where + // T: TypeName::LowerType<'a, 'ctx, Blocking>, + // TypeName::HigherRanked<'a, 'ctx, T, Blocking>: TypeName::MemberType<Blocking>, + // 'ctx: 'a, + // { + // let result = visit_value::<_, Blocking>(self.as_visitor(), value).into_value(); + // + // assert_eq!(result.unit_skipped(), VisitResult::Skipped(())); + // } } |