test: add `Notify` memory leak test (failing)

ref #67
val_queue
Mingwei Samuel 2024-03-26 10:01:11 -07:00
parent 648602a4b6
commit f4c75a421a
1 changed files with 21 additions and 0 deletions

View File

@ -41,3 +41,24 @@ impl Notify {
self.waiters.lock().drain(..).for_each(Waker::wake); self.waiters.lock().drain(..).for_each(Waker::wake);
} }
} }
#[cfg(all(test, not(target_family = "wasm")))]
mod test {
use futures::FutureExt;
use super::*;
#[tokio::test]
async fn memory_leak() {
let notify = Notify::new();
for _ in 0..100 {
futures::select_biased! {
_ = notify.notified().fuse() => {}
_ = tokio::task::yield_now().fuse() => {}
}
}
assert_eq!(0, notify.waiters.lock().len());
}
}