Diffstat (limited to 'tests/protocol_visitor_value.rs')
-rw-r--r--tests/protocol_visitor_value.rs49
1 files changed, 24 insertions, 25 deletions
diff --git a/tests/protocol_visitor_value.rs b/tests/protocol_visitor_value.rs
index 17ba3fe..82db58f 100644
--- a/tests/protocol_visitor_value.rs
+++ b/tests/protocol_visitor_value.rs
@@ -6,6 +6,7 @@ use common::protocol::{
};
use effectful::bound::Dynamic;
use effectful::SendSync;
+use effectful::blocking::BlockingSpin;
use mockall::predicate::eq;
use treaty::{
any::{AnyTrait, BorrowedStatic, OwnedStatic, TempBorrowedMutStatic},
@@ -17,8 +18,6 @@ use treaty::{
Flow,
};
-use crate::common::Blocking;
-
mod common;
/// Tests support for custom type support in the value protocol.
@@ -30,7 +29,7 @@ fn custom_value_type() {
#[derive(PartialEq, Debug, Clone, SendSync)]
struct MyValue;
- let mut mock = MockValueVisitor::<OwnedStatic<MyValue>, Blocking>::new();
+ let mut mock = MockValueVisitor::<OwnedStatic<MyValue>, BlockingSpin>::new();
// Expect the visit method to be called once with the custom type.
mock.expect_visit()
@@ -40,7 +39,7 @@ fn custom_value_type() {
// Cast to a trait object for the value protocol.
// This shows the visit method is going through the trait.
- let visitor: &mut dyn Value<OwnedStatic<MyValue>, Blocking> = &mut mock;
+ let visitor: &mut dyn Value<OwnedStatic<MyValue>, BlockingSpin> = &mut mock;
// Visit the value.
let result = visitor.visit(OwnedStatic(MyValue)).into_value();
@@ -48,9 +47,9 @@ fn custom_value_type() {
// The mock returns that it is done.
assert_eq!(result, VisitResult::Control(Flow::Done));
- let visitor: &mut dyn AnyTrait<Blocking> = &mut mock;
+ let visitor: &mut dyn AnyTrait<BlockingSpin> = &mut mock;
assert_eq!(
- visit_value::<_, Blocking>(DynVisitor(visitor), OwnedStatic(MyValue)).into_value(),
+ visit_value::<_, BlockingSpin>(DynVisitor(visitor), OwnedStatic(MyValue)).into_value(),
VisitResult::Control(Flow::Done)
);
}
@@ -70,7 +69,7 @@ fn borrowed_value() {
// We borrow the context, this is what we pass to the visitor.
let value = &context;
- let mut mock = MockValueVisitor::<BorrowedStaticHrt<String>, Blocking>::new();
+ let mut mock = MockValueVisitor::<BorrowedStaticHrt<String>, BlockingSpin>::new();
// Expect the visit method to be called once with the borrowed value.
mock.expect_visit()
@@ -79,7 +78,7 @@ fn borrowed_value() {
.return_const(VisitResult::Control(Flow::Done));
// Cast to a trait object for the value protocol.
- let visitor: &mut dyn Value<BorrowedStaticHrt<String>, Blocking> = &mut mock;
+ let visitor: &mut dyn Value<BorrowedStaticHrt<String>, BlockingSpin> = &mut mock;
// Visit the borrowed value.
assert_eq!(
@@ -87,9 +86,9 @@ fn borrowed_value() {
Flow::Done.into()
);
- let visitor: &mut dyn AnyTrait<Blocking> = &mut mock;
+ let visitor: &mut dyn AnyTrait<BlockingSpin> = &mut mock;
assert_eq!(
- visit_value::<_, Blocking>(DynVisitor(visitor), BorrowedStatic(value)).into_value(),
+ visit_value::<_, BlockingSpin>(DynVisitor(visitor), BorrowedStatic(value)).into_value(),
VisitResult::Control(Flow::Done)
);
}
@@ -115,7 +114,7 @@ fn temp_borrowed_value() {
// We borrow the context, this is what we pass to the visitor.
let value = &mut context;
- let mut mock = MockValueVisitor::<TempBorrowedMutStaticHrt<String>, Blocking>::new();
+ let mut mock = MockValueVisitor::<TempBorrowedMutStaticHrt<String>, BlockingSpin>::new();
// Expect the visit method to be called once with the borrowed value.
mock.expect_visit()
@@ -125,7 +124,7 @@ fn temp_borrowed_value() {
// Cast to a trait object for the value protocol.
// We definitly need this for this test so the lifetime is invariant.
- let visitor: &mut dyn Value<TempBorrowedMutStaticHrt<String>, Blocking> = &mut mock;
+ let visitor: &mut dyn Value<TempBorrowedMutStaticHrt<String>, BlockingSpin> = &mut mock;
// Visit the context to show we can shorten the lifetime.
// This would also force the lifetime to be to long if this wasn't the Temp form.
@@ -159,7 +158,7 @@ fn temp_borrowed_value() {
/// Tests for the control flow returns the value protocol visit can return.
#[test]
fn all_visit_results() {
- let mut mock = MockValueVisitor::<OwnedStatic<i32>, Blocking>::new();
+ let mut mock = MockValueVisitor::<OwnedStatic<i32>, BlockingSpin>::new();
mock.expect_visit()
.once()
@@ -181,7 +180,7 @@ fn all_visit_results() {
.with(eq(OwnedStatic(3)))
.return_const(VisitResult::Skipped(()));
- let visitor: &mut dyn Value<OwnedStatic<i32>, Blocking> = &mut mock;
+ let visitor: &mut dyn Value<OwnedStatic<i32>, BlockingSpin> = &mut mock;
// Visit can return a done.
assert_eq!(
@@ -214,10 +213,10 @@ fn all_visit_results() {
#[test]
fn value_proto() {
// The type id of the higher ranked type.
- let id = TypeId::of::<ValueProto<OwnedStatic<i32>, Blocking>>();
+ let id = TypeId::of::<ValueProto<OwnedStatic<i32>, BlockingSpin>>();
// The type id for the lifetime containing value protocol trait object.
- let name_id = TypeNameId::of_lower::<dyn Value<OwnedStatic<i32>, Blocking>, Blocking>();
+ let name_id = TypeNameId::of_lower::<dyn Value<OwnedStatic<i32>, BlockingSpin>, BlockingSpin>();
// They should be the same.
assert_eq!(id, name_id.into_type_id());
@@ -229,17 +228,17 @@ fn value_proto() {
#[test]
fn as_hint() {
{
- let mut mock = MockHintWalker::<ValueProto<OwnedStatic<i32>, Blocking>>::new();
+ let mut mock = MockHintWalker::<ValueProto<OwnedStatic<i32>, BlockingSpin>>::new();
mock.expect_known().once().return_const(
(|_, _hint| {
Ok(ValueKnown {
preview: Some(Dynamic(&OwnedStatic(42))),
})
- }) as KnownFactory<ValueProto<OwnedStatic<i32>, Blocking>>,
+ }) as KnownFactory<ValueProto<OwnedStatic<i32>, BlockingSpin>>,
);
- let walker: &mut dyn Hint<ValueProto<OwnedStatic<i32>, Blocking>> = &mut mock;
+ let walker: &mut dyn Hint<ValueProto<OwnedStatic<i32>, BlockingSpin>> = &mut mock;
// The value protocol has no hint data, and it has no known data.
assert_eq!(
@@ -251,17 +250,17 @@ fn as_hint() {
}
{
- let mut mock = MockHintWalker::<ValueProto<BorrowedStaticHrt<i32>, Blocking>>::new();
+ let mut mock = MockHintWalker::<ValueProto<BorrowedStaticHrt<i32>, BlockingSpin>>::new();
mock.expect_known().once().return_const(
(|_, _hint| {
Ok(ValueKnown {
preview: Some(Dynamic(&BorrowedStatic(&42))),
})
- }) as KnownFactory<ValueProto<BorrowedStaticHrt<i32>, Blocking>>,
+ }) as KnownFactory<ValueProto<BorrowedStaticHrt<i32>, BlockingSpin>>,
);
- let walker: &mut dyn Hint<ValueProto<BorrowedStaticHrt<i32>, Blocking>> = &mut mock;
+ let walker: &mut dyn Hint<ValueProto<BorrowedStaticHrt<i32>, BlockingSpin>> = &mut mock;
// The value protocol has no hint data, and it has no known data.
assert_eq!(
@@ -273,14 +272,14 @@ fn as_hint() {
}
{
- let mut mock = MockHintWalker::<ValueProto<TempBorrowedMutStaticHrt<i32>, Blocking>>::new();
+ let mut mock = MockHintWalker::<ValueProto<TempBorrowedMutStaticHrt<i32>, BlockingSpin>>::new();
mock.expect_known().once().return_const(
(|_, _hint| Ok(ValueKnown { preview: None }))
- as KnownFactory<ValueProto<TempBorrowedMutStaticHrt<i32>, Blocking>>,
+ as KnownFactory<ValueProto<TempBorrowedMutStaticHrt<i32>, BlockingSpin>>,
);
- let walker: &mut dyn Hint<ValueProto<TempBorrowedMutStaticHrt<i32>, Blocking>> = &mut mock;
+ let walker: &mut dyn Hint<ValueProto<TempBorrowedMutStaticHrt<i32>, BlockingSpin>> = &mut mock;
// The value protocol has no hint data, and it has no known data.
assert_eq!(