MCPcopy Create free account
hub / github.com/AI45Lab/Code / test_read_or_recover_poisoned

Function test_read_or_recover_poisoned

core/src/error.rs:224–234  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

222
223 #[test]
224 fn test_read_or_recover_poisoned() {
225 let lock = std::sync::RwLock::new(42);
226 // Poison the lock by panicking while holding a write guard
227 let _ = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
228 let _guard = lock.write().unwrap();
229 panic!("intentional poison");
230 }));
231 // Should recover without panicking
232 let guard = read_or_recover(&lock);
233 assert_eq!(*guard, 42);
234 }
235
236 #[test]
237 fn test_write_or_recover_poisoned() {

Callers

nothing calls this directly

Calls 2

read_or_recoverFunction · 0.85
writeMethod · 0.80

Tested by

no test coverage detected