Diffstat (limited to 'tests/protocol_visitor_value.rs')
-rw-r--r--tests/protocol_visitor_value.rs31
1 files changed, 14 insertions, 17 deletions
diff --git a/tests/protocol_visitor_value.rs b/tests/protocol_visitor_value.rs
index 374ed99..584e87f 100644
--- a/tests/protocol_visitor_value.rs
+++ b/tests/protocol_visitor_value.rs
@@ -10,7 +10,7 @@ use treaty::{
AnyTrait, BorrowedStatic, BorrowedStaticHrt, OwnedStatic, TempBorrowedMutStatic,
TempBorrowedMutStaticHrt, TypeNameId,
},
- effect::Blocking,
+ effect::{Blocking, ReadyValue},
protocol::{
visitor::{visit_value, Value, ValueKnown, ValueProto, VisitResult},
walker::hint::Hint,
@@ -43,14 +43,14 @@ fn custom_value_type() {
let visitor: &mut dyn Value<OwnedStatic<MyValue>, Blocking> = &mut mock;
// Visit the value.
- let result = visitor.visit(OwnedStatic(MyValue)).into_inner();
+ let result = visitor.visit(OwnedStatic(MyValue)).value();
// The mock returns that it is done.
assert_eq!(result, VisitResult::Control(Flow::Done));
let visitor: &mut (dyn AnyTrait + Send + Sync) = &mut mock;
assert_eq!(
- visit_value::<_, Blocking>(DynVisitor(visitor), OwnedStatic(MyValue)).into_inner(),
+ visit_value::<_, Blocking>(DynVisitor(visitor), OwnedStatic(MyValue)).value(),
VisitResult::Control(Flow::Done)
);
}
@@ -82,11 +82,11 @@ fn borrowed_value() {
let visitor: &mut dyn Value<BorrowedStaticHrt<String>, Blocking> = &mut mock;
// Visit the borrowed value.
- visitor.visit(BorrowedStatic(value));
+ assert_eq!(visitor.visit(BorrowedStatic(value)).value(), Flow::Done.into());
let visitor: &mut (dyn AnyTrait + Send + Sync) = &mut mock;
assert_eq!(
- visit_value::<_, Blocking>(DynVisitor(visitor), BorrowedStatic(value)).into_inner(),
+ visit_value::<_, Blocking>(DynVisitor(visitor), BorrowedStatic(value)).value(),
VisitResult::Control(Flow::Done)
);
}
@@ -126,7 +126,7 @@ fn temp_borrowed_value() {
// 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.
- visitor.visit(TempBorrowedMutStatic(value));
+ assert_eq!(visitor.visit(TempBorrowedMutStatic(value)).value(), Flow::Done.into());
// Temporary scope (smaller than the context we set above).
{
@@ -134,7 +134,7 @@ fn temp_borrowed_value() {
let mut value = String::from("test");
// Visit the temp value.
- visitor.visit(TempBorrowedMutStatic(&mut value));
+ assert_eq!(visitor.visit(TempBorrowedMutStatic(&mut value)).value(), Flow::Done.into());
}
// Force the visitor to outlive the temporary scope.
@@ -174,19 +174,19 @@ fn all_visit_results() {
// Visit can return a done.
assert_eq!(
- visitor.visit(OwnedStatic(0)).into_inner(),
+ visitor.visit(OwnedStatic(0)).value(),
VisitResult::Control(Flow::Done)
);
// Visit can return an error signal.
assert_eq!(
- visitor.visit(OwnedStatic(1)).into_inner(),
+ visitor.visit(OwnedStatic(1)).value(),
VisitResult::Control(Flow::Err)
);
// Visit can return a continue.
assert_eq!(
- visitor.visit(OwnedStatic(2)).into_inner(),
+ visitor.visit(OwnedStatic(2)).value(),
VisitResult::Control(Flow::Continue)
);
@@ -194,7 +194,7 @@ fn all_visit_results() {
// This is for runtime visit support checking.
// The value should be given back, but that's not forced.
assert_eq!(
- visitor.visit(OwnedStatic(3)).into_inner(),
+ visitor.visit(OwnedStatic(3)).value(),
VisitResult::Skipped(OwnedStatic(3))
);
}
@@ -232,7 +232,7 @@ fn as_hint() {
// The value protocol has no hint data, and it has no known data.
assert_eq!(
- walker.known(&()).into_inner(),
+ walker.known(&()).value(),
Ok(ValueKnown {
preview: Some(&OwnedStatic(42))
})
@@ -254,7 +254,7 @@ fn as_hint() {
// The value protocol has no hint data, and it has no known data.
assert_eq!(
- walker.known(&()).into_inner(),
+ walker.known(&()).value(),
Ok(ValueKnown {
preview: Some(&BorrowedStatic(&42))
})
@@ -272,9 +272,6 @@ fn as_hint() {
let walker: &mut dyn Hint<ValueProto<TempBorrowedMutStaticHrt<i32>, Blocking>> = &mut mock;
// The value protocol has no hint data, and it has no known data.
- assert_eq!(
- walker.known(&()).into_inner(),
- Ok(ValueKnown { preview: None })
- );
+ assert_eq!(walker.known(&()).value(), Ok(ValueKnown { preview: None }));
}
}