about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorDaniel Micay <danielmicay@gmail.com>2014-01-09 15:56:38 -0500
committerDaniel Micay <danielmicay@gmail.com>2014-01-09 21:59:07 -0500
commitfc60ace7a9ec6feed79cf52cc245f4d7c048fc8b (patch)
treee7de14e8284cc6ca97e837c6ed1d479247f8786a /src/libstd
parentc5bcb22719a8af3075fdd204003a748022022479 (diff)
downloadrust-fc60ace7a9ec6feed79cf52cc245f4d7c048fc8b.tar.gz
rust-fc60ace7a9ec6feed79cf52cc245f4d7c048fc8b.zip
port over the old tests to the new `Rc`
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/option.rs2
-rw-r--r--src/libstd/rc.rs43
2 files changed, 43 insertions, 2 deletions
diff --git a/src/libstd/option.rs b/src/libstd/option.rs
index f49244a3607..7ce9873c2da 100644
--- a/src/libstd/option.rs
+++ b/src/libstd/option.rs
@@ -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);
diff --git a/src/libstd/rc.rs b/src/libstd/rc.rs
index a5b909008bf..9947d8822ae 100644
--- a/src/libstd/rc.rs
+++ b/src/libstd/rc.rs
@@ -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() {