Skip to content

Commit 34a2cd1

Browse files
committed
Debugging scope cleanup
Signed-off-by: Michael X. Grey <mxgrey@intrinsic.ai>
1 parent 28dbcf2 commit 34a2cd1

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/chain.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,26 +744,34 @@ mod tests {
744744
.input
745745
.chain(builder)
746746
.map_block(add)
747+
.map_block(print_debug(format!("line {}", line!())))
747748
.then_scope::<_, ()>(ScopeSettings::default(), |scope, builder| {
748749
scope
749750
.input
750751
.chain(builder)
752+
.map_block(print_debug(format!("line {}", line!())))
751753
.fork_clone_zip((
752754
|chain: Chain<f64>| {
753755
chain
756+
.map_block(print_debug(format!("line {}", line!())))
754757
.map_block(|value|
755758
WaitRequest {
756759
duration: Duration::from_secs_f64(value),
757760
value,
758761
}
759762
)
763+
.map_block(print_debug(format!("line {}", line!())))
760764
.map_async(wait)
765+
.map_block(print_debug(format!("line {}", line!())))
761766
.connect(scope.terminate);
762767
},
763768
|chain: Chain<f64>| {
764769
chain
770+
.map_block(print_debug(format!("line {}", line!())))
765771
.map_block(|a| (a, a))
772+
.map_block(print_debug(format!("line {}", line!())))
766773
.map_block(add)
774+
.map_block(print_debug(format!("line {}", line!())))
767775
.connect(scope.terminate);
768776
}
769777
));
@@ -782,7 +790,7 @@ mod tests {
782790
context.run_with_conditions(
783791
&mut promise,
784792
FlushConditions::new()
785-
.with_update_count(5),
793+
.with_update_count(100),
786794
);
787795

788796
dbg!(context.get_unhandled_errors());

src/testing.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ pub fn to_uppercase(value: String) -> String {
251251
value.to_uppercase()
252252
}
253253

254-
#[derive(Clone, Copy)]
254+
#[derive(Clone, Copy, Debug)]
255255
pub struct WaitRequest<Value> {
256256
pub duration: std::time::Duration,
257257
pub value: Value
@@ -269,7 +269,7 @@ pub async fn wait<Value>(request: WaitRequest<Value>) -> Value {
269269

270270
/// Use this to add a blocking map to the chain that simply prints a debug
271271
/// message and then passes the data along.
272-
pub fn print_debug<T: std::fmt::Debug>(header: String) -> impl FnOnce(T) -> T {
272+
pub fn print_debug<T: std::fmt::Debug>(header: String) -> impl Fn(T) -> T {
273273
move |value| {
274274
println!("{header}: {value:?}");
275275
value

0 commit comments

Comments
 (0)