Skip to content

Commit

Permalink
Add a (failing) test
Browse files Browse the repository at this point in the history
  • Loading branch information
jwodder committed Jan 11, 2025
1 parent 2a355bc commit 648d479
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions crates/tokio-nursery/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ impl<T> Future for FragileHandle<T> {
mod tests {
use super::*;
use futures_util::{FutureExt, StreamExt};
use std::sync::Arc;
use std::time::Duration;
use tokio::time::timeout;

Expand Down Expand Up @@ -209,4 +210,21 @@ mod tests {
let r = timeout(Duration::from_millis(100), nursery_stream.next()).await;
assert_eq!(r, Ok(None));
}

#[tokio::test]
async fn drop_tasks_on_drop_stream() {
let (nursery, nursery_stream) = Nursery::new();
let token = Arc::new(());
nursery.spawn({
let token = token.clone();
async move {
std::future::pending::<()>().await;
*token;
}
});
drop(nursery);
assert_eq!(Arc::strong_count(&token), 2);
drop(nursery_stream);
assert_eq!(Arc::strong_count(&token), 1);
}
}

0 comments on commit 648d479

Please sign in to comment.