use ump::{channel, Error}; #[test] fn sync_weak_should_not_count() { let (server, client) = channel::(); let _weak_client = client.weak(); // nuke the only (strong) client drop(client); let Err(Error::ClientsDisappeared) = server.wait() else { panic!("Unexpected error"); }; } #[test] fn async_weak_should_not_count() { let tokrt = tokio::runtime::Runtime::new().unwrap(); let (server, client) = channel::(); let _weak_client = client.weak(); // nuke the only client drop(client); tokrt.block_on(async { let Err(Error::ClientsDisappeared) = server.async_wait().await else { panic!("Unexpected error"); }; }); } #[test] fn upgraded_should_count() { let (server, client) = channel::(); let weak_client = client.weak(); let Some(_client2) = weak_client.upgrade() else { panic!("Unable to upgrade weak_client"); }; // nuke original client drop(client); let Ok(None) = server.try_pop() else { panic!("Unexpected error"); }; } // vim: set ft=rust et sw=2 ts=2 sts=2 cinoptions=2 tw=79 :