about summary refs log tree commit diff
path: root/src/test/auxiliary
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2013-12-31 15:46:27 -0800
committerPatrick Walton <pcwalton@mimiga.net>2014-01-03 14:02:01 -0800
commitc3694d732ef9ed641671fbf116d183e78dc4e90a (patch)
tree9491998229d82615ae8d547ff4061e433947b373 /src/test/auxiliary
parentdf13c64c3b221f0408fa7e149884e25ff5b02343 (diff)
downloadrust-c3694d732ef9ed641671fbf116d183e78dc4e90a.tar.gz
rust-c3694d732ef9ed641671fbf116d183e78dc4e90a.zip
test: De-`@mut` the test suite
Diffstat (limited to 'src/test/auxiliary')
-rw-r--r--src/test/auxiliary/cci_nested_lib.rs20
-rw-r--r--src/test/auxiliary/issue-2631-a.rs5
2 files changed, 18 insertions, 7 deletions
diff --git a/src/test/auxiliary/cci_nested_lib.rs b/src/test/auxiliary/cci_nested_lib.rs
index 72ce66c20bd..90b01f8888b 100644
--- a/src/test/auxiliary/cci_nested_lib.rs
+++ b/src/test/auxiliary/cci_nested_lib.rs
@@ -10,6 +10,8 @@
 
 #[feature(managed_boxes)];
 
+use std::cell::RefCell;
+
 pub struct Entry<A,B> {
     key: A,
     value: B
@@ -17,11 +19,12 @@ pub struct Entry<A,B> {
 
 pub struct alist<A,B> {
     eq_fn: extern "Rust" fn(A,A) -> bool,
-    data: @mut ~[Entry<A,B>]
+    data: @RefCell<~[Entry<A,B>]>,
 }
 
 pub fn alist_add<A:'static,B:'static>(lst: &alist<A,B>, k: A, v: B) {
-    lst.data.push(Entry{key:k, value:v});
+    let mut data = lst.data.borrow_mut();
+    data.get().push(Entry{key:k, value:v});
 }
 
 pub fn alist_get<A:Clone + 'static,
@@ -30,7 +33,8 @@ pub fn alist_get<A:Clone + 'static,
                  k: A)
                  -> B {
     let eq_fn = lst.eq_fn;
-    for entry in lst.data.iter() {
+    let data = lst.data.borrow();
+    for entry in data.get().iter() {
         if eq_fn(entry.key.clone(), k.clone()) {
             return entry.value.clone();
         }
@@ -41,12 +45,18 @@ pub fn alist_get<A:Clone + 'static,
 #[inline]
 pub fn new_int_alist<B:'static>() -> alist<int, B> {
     fn eq_int(a: int, b: int) -> bool { a == b }
-    return alist {eq_fn: eq_int, data: @mut ~[]};
+    return alist {
+        eq_fn: eq_int,
+        data: @RefCell::new(~[]),
+    };
 }
 
 #[inline]
 pub fn new_int_alist_2<B:'static>() -> alist<int, B> {
     #[inline]
     fn eq_int(a: int, b: int) -> bool { a == b }
-    return alist {eq_fn: eq_int, data: @mut ~[]};
+    return alist {
+        eq_fn: eq_int,
+        data: @RefCell::new(~[]),
+    };
 }
diff --git a/src/test/auxiliary/issue-2631-a.rs b/src/test/auxiliary/issue-2631-a.rs
index f5d2fb9ffd2..15dde899ce3 100644
--- a/src/test/auxiliary/issue-2631-a.rs
+++ b/src/test/auxiliary/issue-2631-a.rs
@@ -14,11 +14,12 @@
 
 extern mod extra;
 
+use std::cell::RefCell;
 use std::hashmap::HashMap;
 
-pub type header_map = HashMap<~str, @mut ~[@~str]>;
+pub type header_map = HashMap<~str, @RefCell<~[@~str]>>;
 
 // the unused ty param is necessary so this gets monomorphized
 pub fn request<T>(req: &header_map) {
-  let _x = (*((**req.get(&~"METHOD")).clone())[0u]).clone();
+  let _x = (*((**req.get(&~"METHOD")).clone()).get()[0u]).clone();
 }