Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kwannoel committed Oct 7, 2024
1 parent cf934bf commit 9978cf0
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions madsim-tokio/src/sim/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,33 @@ mod tests {
}

// FIXME(kwannoel): See https://github.com/madsim-rs/madsim/issues/228
// #[test]
#[allow(dead_code)]
fn runtime_drop_and_spawn_struct_fail_with_try_current_task() {
#[derive(Debug)]
struct A {}
impl Drop for A {
fn drop(&mut self) {
if let Some(handle) = Handle::try_current().ok() {
handle.spawn(std::future::pending::<()>());
}
}
}

let a = A {};
let runtime = madsim::runtime::Runtime::new();
runtime.block_on(async move {
let rt = Runtime::new().unwrap();
let join_handle = rt.spawn(async move { drop(a) });
drop(rt);

let err = join_handle.await.unwrap_err();
assert!(err.is_cancelled());
})
}

// FIXME(kwannoel): See https://github.com/madsim-rs/madsim/issues/228
// #[test]
#[allow(dead_code)]
fn runtime_drop_and_spawn_struct_fail() {
#[derive(Debug)]
Expand Down

0 comments on commit 9978cf0

Please sign in to comment.