equal
deleted
inserted
replaced
488 ) |
488 ) |
489 } |
489 } |
490 } |
490 } |
491 }; |
491 }; |
492 } |
492 } |
|
493 |
|
494 #[cfg(test)] |
|
495 #[cfg(any(feature = "python27-bin", feature = "python3-bin"))] |
|
496 mod test { |
|
497 use super::*; |
|
498 use cpython::{GILGuard, Python}; |
|
499 |
|
500 py_class!(class Owner |py| { |
|
501 data string: PySharedRefCell<String>; |
|
502 }); |
|
503 py_shared_ref!(Owner, String, string, string_shared); |
|
504 |
|
505 fn prepare_env() -> (GILGuard, Owner) { |
|
506 let gil = Python::acquire_gil(); |
|
507 let py = gil.python(); |
|
508 let owner = |
|
509 Owner::create_instance(py, PySharedRefCell::new("new".to_owned())) |
|
510 .unwrap(); |
|
511 (gil, owner) |
|
512 } |
|
513 |
|
514 #[test] |
|
515 fn test_borrow_mut_while_leaked() { |
|
516 let (gil, owner) = prepare_env(); |
|
517 let py = gil.python(); |
|
518 assert!(owner.string_shared(py).borrow_mut().is_ok()); |
|
519 let _leaked = owner.string_shared(py).leak_immutable().unwrap(); |
|
520 // TODO: will be allowed |
|
521 assert!(owner.string_shared(py).borrow_mut().is_err()); |
|
522 } |
|
523 } |