mirror of https://github.com/rust-lang/rust.git
port over the old tests to the new `Rc`
This commit is contained in:
parent
c5bcb22719
commit
fc60ace7a9
|
@ -127,7 +127,7 @@ mod test {
|
|||
}
|
||||
|
||||
fn mk(v: uint) -> (~IdleWatcher, Chan) {
|
||||
let rc = Rc::from_send(RefCell::new((None, 0)));
|
||||
let rc = Rc::new(RefCell::new((None, 0)));
|
||||
let cb = ~MyCallback(rc.clone(), v);
|
||||
let cb = cb as ~Callback:;
|
||||
let cb = unsafe { cast::transmute(cb) };
|
||||
|
|
|
@ -509,7 +509,7 @@ mod tests {
|
|||
}
|
||||
}
|
||||
|
||||
let i = Rc::from_send(RefCell::new(0));
|
||||
let i = Rc::new(RefCell::new(0));
|
||||
{
|
||||
let x = R(i.clone());
|
||||
let opt = Some(x);
|
||||
|
|
|
@ -172,8 +172,49 @@ impl<T> Clone for Weak<T> {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use prelude::*;
|
||||
use super::*;
|
||||
use prelude::drop;
|
||||
use cell::RefCell;
|
||||
|
||||
#[test]
|
||||
fn test_clone() {
|
||||
let x = Rc::new(RefCell::new(5));
|
||||
let y = x.clone();
|
||||
x.borrow().with_mut(|inner| {
|
||||
*inner = 20;
|
||||
});
|
||||
assert_eq!(y.borrow().with(|v| *v), 20);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deep_clone() {
|
||||
let x = Rc::new(RefCell::new(5));
|
||||
let y = x.deep_clone();
|
||||
x.borrow().with_mut(|inner| {
|
||||
*inner = 20;
|
||||
});
|
||||
assert_eq!(y.borrow().with(|v| *v), 5);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_simple() {
|
||||
let x = Rc::new(5);
|
||||
assert_eq!(*x.borrow(), 5);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_simple_clone() {
|
||||
let x = Rc::new(5);
|
||||
let y = x.clone();
|
||||
assert_eq!(*x.borrow(), 5);
|
||||
assert_eq!(*y.borrow(), 5);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_destructor() {
|
||||
let x = Rc::new(~5);
|
||||
assert_eq!(**x.borrow(), 5);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_live() {
|
||||
|
|
Loading…
Reference in New Issue