about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/any.rs35
-rw-r--r--src/libcore/cell.rs2
-rw-r--r--src/libcore/char.rs4
-rw-r--r--src/libcore/clone.rs2
-rw-r--r--src/libcore/fmt/float.rs12
-rw-r--r--src/libcore/fmt/mod.rs73
-rw-r--r--src/libcore/fmt/num.rs4
-rw-r--r--src/libcore/iter.rs110
-rw-r--r--src/libcore/lib.rs13
-rw-r--r--src/libcore/macros.rs21
-rw-r--r--src/libcore/option.rs25
-rw-r--r--src/libcore/ptr.rs8
-rw-r--r--src/libcore/result.rs40
-rw-r--r--src/libcore/should_not_exist.rs2
14 files changed, 219 insertions, 132 deletions
diff --git a/src/libcore/any.rs b/src/libcore/any.rs
index 70cd46dcfa2..61c1193e515 100644
--- a/src/libcore/any.rs
+++ b/src/libcore/any.rs
@@ -166,12 +166,12 @@ mod tests {
 
         match a.as_ref::<uint>() {
             Some(&5) => {}
-            x => fail!("Unexpected value {:?}", x)
+            x => fail!("Unexpected value {}", x)
         }
 
         match a.as_ref::<Test>() {
             None => {}
-            x => fail!("Unexpected value {:?}", x)
+            x => fail!("Unexpected value {}", x)
         }
     }
 
@@ -189,7 +189,7 @@ mod tests {
                 assert_eq!(*x, 5u);
                 *x = 612;
             }
-            x => fail!("Unexpected value {:?}", x)
+            x => fail!("Unexpected value {}", x)
         }
 
         match b_r.as_mut::<uint>() {
@@ -197,27 +197,27 @@ mod tests {
                 assert_eq!(*x, 7u);
                 *x = 413;
             }
-            x => fail!("Unexpected value {:?}", x)
+            x => fail!("Unexpected value {}", x)
         }
 
         match a_r.as_mut::<Test>() {
             None => (),
-            x => fail!("Unexpected value {:?}", x)
+            x => fail!("Unexpected value {}", x)
         }
 
         match b_r.as_mut::<Test>() {
             None => (),
-            x => fail!("Unexpected value {:?}", x)
+            x => fail!("Unexpected value {}", x)
         }
 
         match a_r.as_mut::<uint>() {
             Some(&612) => {}
-            x => fail!("Unexpected value {:?}", x)
+            x => fail!("Unexpected value {}", x)
         }
 
         match b_r.as_mut::<uint>() {
             Some(&413) => {}
-            x => fail!("Unexpected value {:?}", x)
+            x => fail!("Unexpected value {}", x)
         }
     }
 
@@ -229,11 +229,11 @@ mod tests {
         let b = box Test as Box<Any>;
 
         match a.move::<uint>() {
-            Ok(a) => { assert_eq!(a, box 8u); }
+            Ok(a) => { assert!(a == box 8u); }
             Err(..) => fail!()
         }
         match b.move::<Test>() {
-            Ok(a) => { assert_eq!(a, box Test); }
+            Ok(a) => { assert!(a == box Test); }
             Err(..) => fail!()
         }
 
@@ -246,13 +246,14 @@ mod tests {
 
     #[test]
     fn test_show() {
-        let a = box 8u as Box<::realcore::any::Any>;
-        let b = box Test as Box<::realcore::any::Any>;
-        assert_eq!(format!("{}", a), "Box<Any>".to_owned());
-        assert_eq!(format!("{}", b), "Box<Any>".to_owned());
-
-        let a = &8u as &::realcore::any::Any;
-        let b = &Test as &::realcore::any::Any;
+        use realstd::to_str::ToStr;
+        let a = box 8u as Box<::realstd::any::Any>;
+        let b = box Test as Box<::realstd::any::Any>;
+        assert_eq!(a.to_str(), "Box<Any>".to_owned());
+        assert_eq!(b.to_str(), "Box<Any>".to_owned());
+
+        let a = &8u as &Any;
+        let b = &Test as &Any;
         assert_eq!(format!("{}", a), "&Any".to_owned());
         assert_eq!(format!("{}", b), "&Any".to_owned());
     }
diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs
index 8b3494f3127..d42ad49485f 100644
--- a/src/libcore/cell.rs
+++ b/src/libcore/cell.rs
@@ -255,7 +255,7 @@ mod test {
     fn cell_has_sensible_show() {
         use str::StrSlice;
 
-        let x = ::realcore::cell::Cell::new("foo bar");
+        let x = Cell::new("foo bar");
         assert!(format!("{}", x).contains(x.get()));
 
         x.set("baz qux");
diff --git a/src/libcore/char.rs b/src/libcore/char.rs
index 934483dbed4..6e9d4c9bafb 100644
--- a/src/libcore/char.rs
+++ b/src/libcore/char.rs
@@ -633,9 +633,9 @@ impl Default for char {
 mod test {
     use super::{escape_unicode, escape_default};
 
-    use realcore::char::Char;
+    use char::Char;
     use slice::ImmutableVector;
-    use realstd::option::{Some, None};
+    use option::{Some, None};
     use realstd::strbuf::StrBuf;
     use realstd::str::StrAllocating;
 
diff --git a/src/libcore/clone.rs b/src/libcore/clone.rs
index cd66beabc12..c7befe2f4b1 100644
--- a/src/libcore/clone.rs
+++ b/src/libcore/clone.rs
@@ -131,7 +131,7 @@ mod test {
     fn test_owned_clone() {
         let a = box 5i;
         let b: Box<int> = realclone(&a);
-        assert_eq!(a, b);
+        assert!(a == b);
     }
 
     #[test]
diff --git a/src/libcore/fmt/float.rs b/src/libcore/fmt/float.rs
index e389775ce4c..e5fb148aded 100644
--- a/src/libcore/fmt/float.rs
+++ b/src/libcore/fmt/float.rs
@@ -352,8 +352,16 @@ pub fn float_to_str_bytes_common<T: Primitive + Float, U>(
 
             let mut filler = Filler { buf: buf, end: &mut end };
             match sign {
-                SignNeg => { let _ = write!(&mut filler, "{:-}", exp); }
-                SignNone | SignAll => { let _ = write!(&mut filler, "{}", exp); }
+                SignNeg => {
+                    let _ = format_args!(|args| {
+                        fmt::write(&mut filler, args)
+                    }, "{:-}", exp);
+                }
+                SignNone | SignAll => {
+                    let _ = format_args!(|args| {
+                        fmt::write(&mut filler, args)
+                    }, "{}", exp);
+                }
             }
         }
     }
diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs
index 95c6e15bd72..979928c10ad 100644
--- a/src/libcore/fmt/mod.rs
+++ b/src/libcore/fmt/mod.rs
@@ -13,16 +13,15 @@
 #![allow(unused_variable)]
 
 use any;
-use cast;
 use cell::Cell;
 use char::Char;
 use container::Container;
 use iter::{Iterator, range};
 use kinds::Copy;
+use mem;
 use option::{Option, Some, None};
-use owned::Box;
-use result;
 use result::{Ok, Err};
+use result;
 use slice::{Vector, ImmutableVector};
 use slice;
 use str::StrSlice;
@@ -34,8 +33,7 @@ pub use self::num::RadixFmt;
 
 macro_rules! write(
     ($dst:expr, $($arg:tt)*) => ({
-        let dst: &mut ::fmt::FormatWriter = $dst;
-        format_args!(|args| { ::std::fmt::write(dst, args) }, $($arg)*)
+        format_args!(|args| { $dst.write_fmt(args) }, $($arg)*)
     })
 )
 
@@ -104,7 +102,7 @@ impl<'a> Arguments<'a> {
     #[doc(hidden)] #[inline]
     pub unsafe fn new<'a>(fmt: &'static [rt::Piece<'static>],
                           args: &'a [Argument<'a>]) -> Arguments<'a> {
-        Arguments{ fmt: cast::transmute(fmt), args: args }
+        Arguments{ fmt: mem::transmute(fmt), args: args }
     }
 }
 
@@ -329,7 +327,7 @@ impl<'a> Formatter<'a> {
             rt::Plural(offset, ref selectors, ref default) => {
                 // This is validated at compile-time to be a pointer to a
                 // '&uint' value.
-                let value: &uint = unsafe { cast::transmute(arg.value) };
+                let value: &uint = unsafe { mem::transmute(arg.value) };
                 let value = *value;
 
                 // First, attempt to match against explicit values without the
@@ -372,7 +370,7 @@ impl<'a> Formatter<'a> {
             rt::Select(ref selectors, ref default) => {
                 // This is validated at compile-time to be a pointer to a
                 // string slice,
-                let value: & &str = unsafe { cast::transmute(arg.value) };
+                let value: & &str = unsafe { mem::transmute(arg.value) };
                 let value = *value;
 
                 for s in selectors.iter() {
@@ -565,10 +563,33 @@ pub fn argument<'a, T>(f: extern "Rust" fn(&T, &mut Formatter) -> Result,
                        t: &'a T) -> Argument<'a> {
     unsafe {
         Argument {
-            formatter: cast::transmute(f),
-            value: cast::transmute(t)
+            formatter: mem::transmute(f),
+            value: mem::transmute(t)
+        }
+    }
+}
+
+#[cfg(test)]
+pub fn format(args: &Arguments) -> ~str {
+    use str;
+    use realstd::str::StrAllocating;
+    use realstd::io::MemWriter;
+
+    fn mywrite<T: ::realstd::io::Writer>(t: &mut T, b: &[u8]) {
+        use realstd::io::Writer;
+        let _ = t.write(b);
+    }
+
+    impl FormatWriter for MemWriter {
+        fn write(&mut self, bytes: &[u8]) -> Result {
+            mywrite(self, bytes);
+            Ok(())
         }
     }
+
+    let mut i = MemWriter::new();
+    let _ = write(&mut i, args);
+    str::from_utf8(i.get_ref()).unwrap().to_owned()
 }
 
 /// When the compiler determines that the type of an argument *must* be a string
@@ -590,12 +611,12 @@ pub fn argumentuint<'a>(s: &'a uint) -> Argument<'a> {
 impl<T: Show> Show for @T {
     fn fmt(&self, f: &mut Formatter) -> Result { secret_show(&**self, f) }
 }
-impl<T: Show> Show for Box<T> {
-    fn fmt(&self, f: &mut Formatter) -> Result { secret_show(&**self, f) }
-}
 impl<'a, T: Show> Show for &'a T {
     fn fmt(&self, f: &mut Formatter) -> Result { secret_show(*self, f) }
 }
+impl<'a, T: Show> Show for &'a mut T {
+    fn fmt(&self, f: &mut Formatter) -> Result { secret_show(&**self, f) }
+}
 
 impl Bool for bool {
     fn fmt(&self, f: &mut Formatter) -> Result {
@@ -613,7 +634,7 @@ impl Char for char {
     fn fmt(&self, f: &mut Formatter) -> Result {
         let mut utf8 = [0u8, ..4];
         let amt = self.encode_utf8(utf8);
-        let s: &str = unsafe { cast::transmute(utf8.slice_to(amt)) };
+        let s: &str = unsafe { mem::transmute(utf8.slice_to(amt)) };
         secret_string(&s, f)
     }
 }
@@ -738,20 +759,20 @@ macro_rules! tuple (
         impl<$($name:Show),*> Show for ($($name,)*) {
             #[allow(uppercase_variables, dead_assignment)]
             fn fmt(&self, f: &mut Formatter) -> Result {
-                try!(write!(f.buf, "("));
+                try!(write!(f, "("));
                 let ($(ref $name,)*) = *self;
                 let mut n = 0;
                 $(
                     if n > 0 {
-                        try!(write!(f.buf, ", "));
+                        try!(write!(f, ", "));
                     }
-                    try!(write!(f.buf, "{}", *$name));
+                    try!(write!(f, "{}", *$name));
                     n += 1;
                 )*
                 if n == 1 {
-                    try!(write!(f.buf, ","));
+                    try!(write!(f, ","));
                 }
-                write!(f.buf, ")")
+                write!(f, ")")
             }
         }
         peel!($($name,)*)
@@ -760,10 +781,6 @@ macro_rules! tuple (
 
 tuple! { T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, }
 
-impl Show for Box<any::Any> {
-    fn fmt(&self, f: &mut Formatter) -> Result { f.pad("Box<Any>") }
-}
-
 impl<'a> Show for &'a any::Any {
     fn fmt(&self, f: &mut Formatter) -> Result { f.pad("&Any") }
 }
@@ -771,19 +788,19 @@ impl<'a> Show for &'a any::Any {
 impl<'a, T: Show> Show for &'a [T] {
     fn fmt(&self, f: &mut Formatter) -> Result {
         if f.flags & (1 << (rt::FlagAlternate as uint)) == 0 {
-            try!(write!(f.buf, "["));
+            try!(write!(f, "["));
         }
         let mut is_first = true;
         for x in self.iter() {
             if is_first {
                 is_first = false;
             } else {
-                try!(write!(f.buf, ", "));
+                try!(write!(f, ", "));
             }
-            try!(write!(f.buf, "{}", *x))
+            try!(write!(f, "{}", *x))
         }
         if f.flags & (1 << (rt::FlagAlternate as uint)) == 0 {
-            try!(write!(f.buf, "]"));
+            try!(write!(f, "]"));
         }
         Ok(())
     }
@@ -809,7 +826,7 @@ impl Show for () {
 
 impl<T: Copy + Show> Show for Cell<T> {
     fn fmt(&self, f: &mut Formatter) -> Result {
-        write!(f.buf, r"Cell \{ value: {} \}", self.get())
+        write!(f, r"Cell \{ value: {} \}", self.get())
     }
 }
 
diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs
index 12adcee2f0f..d9a32713781 100644
--- a/src/libcore/fmt/num.rs
+++ b/src/libcore/fmt/num.rs
@@ -172,7 +172,7 @@ macro_rules! integer {
         int_base!(Octal    for $Int as $Uint  -> Octal)
         int_base!(LowerHex for $Int as $Uint  -> LowerHex)
         int_base!(UpperHex for $Int as $Uint  -> UpperHex)
-        radix_fmt!($Int as $Uint, fmt_int)
+        radix_fmt!($Int as $Int, fmt_int)
 
         int_base!(Show     for $Uint as $Uint -> Decimal)
         int_base!(Unsigned for $Uint as $Uint -> Decimal)
@@ -194,7 +194,7 @@ mod tests {
     use fmt::radix;
     use super::{Binary, Octal, Decimal, LowerHex, UpperHex};
     use super::{GenericRadix, Radix};
-    use str::StrAllocating;
+    use realstd::str::StrAllocating;
 
     #[test]
     fn test_radix_base() {
diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs
index 18553d2c48b..d40701860f4 100644
--- a/src/libcore/iter.rs
+++ b/src/libcore/iter.rs
@@ -2329,19 +2329,48 @@ pub mod order {
 
 #[cfg(test)]
 mod tests {
-    use realstd::prelude::*;
-    use realstd::iter::*;
-    use realstd::num;
+    use prelude::*;
+    use iter::*;
+    use num;
+    use realstd::vec::Vec;
+    use realstd::slice::Vector;
 
     use cmp;
     use realstd::owned::Box;
     use uint;
 
+    impl<T> FromIterator<T> for Vec<T> {
+        fn from_iter<I: Iterator<T>>(mut iterator: I) -> Vec<T> {
+            let mut v = Vec::new();
+            for e in iterator {
+                v.push(e);
+            }
+            return v;
+        }
+    }
+
+    impl<'a, T> Iterator<&'a T> for ::realcore::slice::Items<'a, T> {
+        fn next(&mut self) -> Option<&'a T> {
+            use RealSome = realcore::option::Some;
+            use RealNone = realcore::option::None;
+            fn mynext<T, I: ::realcore::iter::Iterator<T>>(i: &mut I)
+                -> ::realcore::option::Option<T>
+            {
+                use realcore::iter::Iterator;
+                i.next()
+            }
+            match mynext(self) {
+                RealSome(t) => Some(t),
+                RealNone => None,
+            }
+        }
+    }
+
     #[test]
     fn test_counter_from_iter() {
         let it = count(0, 5).take(10);
         let xs: Vec<int> = FromIterator::from_iter(it);
-        assert_eq!(xs, vec![0, 5, 10, 15, 20, 25, 30, 35, 40, 45]);
+        assert!(xs == vec![0, 5, 10, 15, 20, 25, 30, 35, 40, 45]);
     }
 
     #[test]
@@ -2371,7 +2400,7 @@ mod tests {
     fn test_filter_map() {
         let mut it = count(0u, 1u).take(10)
             .filter_map(|x| if x % 2 == 0 { Some(x*x) } else { None });
-        assert_eq!(it.collect::<Vec<uint>>(), vec![0*0, 2*2, 4*4, 6*6, 8*8]);
+        assert!(it.collect::<Vec<uint>>() == vec![0*0, 2*2, 4*4, 6*6, 8*8]);
     }
 
     #[test]
@@ -2630,7 +2659,7 @@ mod tests {
     fn test_collect() {
         let a = vec![1, 2, 3, 4, 5];
         let b: Vec<int> = a.iter().map(|&x| x).collect();
-        assert_eq!(a, b);
+        assert!(a == b);
     }
 
     #[test]
@@ -2702,7 +2731,8 @@ mod tests {
         let mut it = xs.iter();
         it.next();
         it.next();
-        assert_eq!(it.rev().map(|&x| x).collect::<Vec<int>>(), vec![16, 14, 12, 10, 8, 6]);
+        assert!(it.rev().map(|&x| x).collect::<Vec<int>>() ==
+                vec![16, 14, 12, 10, 8, 6]);
     }
 
     #[test]
@@ -2940,12 +2970,12 @@ mod tests {
 
     #[test]
     fn test_double_ended_range() {
-        assert_eq!(range(11i, 14).rev().collect::<Vec<int>>(), vec![13i, 12, 11]);
+        assert!(range(11i, 14).rev().collect::<Vec<int>>() == vec![13i, 12, 11]);
         for _ in range(10i, 0).rev() {
             fail!("unreachable");
         }
 
-        assert_eq!(range(11u, 14).rev().collect::<Vec<uint>>(), vec![13u, 12, 11]);
+        assert!(range(11u, 14).rev().collect::<Vec<uint>>() == vec![13u, 12, 11]);
         for _ in range(10u, 0).rev() {
             fail!("unreachable");
         }
@@ -2997,14 +3027,14 @@ mod tests {
             }
         }
 
-        assert_eq!(range(0i, 5).collect::<Vec<int>>(), vec![0i, 1, 2, 3, 4]);
-        assert_eq!(range(-10i, -1).collect::<Vec<int>>(),
+        assert!(range(0i, 5).collect::<Vec<int>>() == vec![0i, 1, 2, 3, 4]);
+        assert!(range(-10i, -1).collect::<Vec<int>>() ==
                    vec![-10, -9, -8, -7, -6, -5, -4, -3, -2]);
-        assert_eq!(range(0i, 5).rev().collect::<Vec<int>>(), vec![4, 3, 2, 1, 0]);
-        assert_eq!(range(200, -5).collect::<Vec<int>>(), vec![]);
-        assert_eq!(range(200, -5).rev().collect::<Vec<int>>(), vec![]);
-        assert_eq!(range(200, 200).collect::<Vec<int>>(), vec![]);
-        assert_eq!(range(200, 200).rev().collect::<Vec<int>>(), vec![]);
+        assert!(range(0i, 5).rev().collect::<Vec<int>>() == vec![4, 3, 2, 1, 0]);
+        assert_eq!(range(200, -5).len(), 0);
+        assert_eq!(range(200, -5).rev().len(), 0);
+        assert_eq!(range(200, 200).len(), 0);
+        assert_eq!(range(200, 200).rev().len(), 0);
 
         assert_eq!(range(0i, 100).size_hint(), (100, Some(100)));
         // this test is only meaningful when sizeof uint < sizeof u64
@@ -3015,32 +3045,44 @@ mod tests {
 
     #[test]
     fn test_range_inclusive() {
-        assert_eq!(range_inclusive(0i, 5).collect::<Vec<int>>(), vec![0i, 1, 2, 3, 4, 5]);
-        assert_eq!(range_inclusive(0i, 5).rev().collect::<Vec<int>>(), vec![5i, 4, 3, 2, 1, 0]);
-        assert_eq!(range_inclusive(200, -5).collect::<Vec<int>>(), vec![]);
-        assert_eq!(range_inclusive(200, -5).rev().collect::<Vec<int>>(), vec![]);
-        assert_eq!(range_inclusive(200, 200).collect::<Vec<int>>(), vec![200]);
-        assert_eq!(range_inclusive(200, 200).rev().collect::<Vec<int>>(), vec![200]);
+        assert!(range_inclusive(0i, 5).collect::<Vec<int>>() ==
+                vec![0i, 1, 2, 3, 4, 5]);
+        assert!(range_inclusive(0i, 5).rev().collect::<Vec<int>>() ==
+                vec![5i, 4, 3, 2, 1, 0]);
+        assert_eq!(range_inclusive(200, -5).len(), 0);
+        assert_eq!(range_inclusive(200, -5).rev().len(), 0);
+        assert!(range_inclusive(200, 200).collect::<Vec<int>>() == vec![200]);
+        assert!(range_inclusive(200, 200).rev().collect::<Vec<int>>() == vec![200]);
     }
 
     #[test]
     fn test_range_step() {
-        assert_eq!(range_step(0i, 20, 5).collect::<Vec<int>>(), vec![0, 5, 10, 15]);
-        assert_eq!(range_step(20i, 0, -5).collect::<Vec<int>>(), vec![20, 15, 10, 5]);
-        assert_eq!(range_step(20i, 0, -6).collect::<Vec<int>>(), vec![20, 14, 8, 2]);
-        assert_eq!(range_step(200u8, 255, 50).collect::<Vec<u8>>(), vec![200u8, 250]);
-        assert_eq!(range_step(200, -5, 1).collect::<Vec<int>>(), vec![]);
-        assert_eq!(range_step(200, 200, 1).collect::<Vec<int>>(), vec![]);
+        assert!(range_step(0i, 20, 5).collect::<Vec<int>>() ==
+                vec![0, 5, 10, 15]);
+        assert!(range_step(20i, 0, -5).collect::<Vec<int>>() ==
+                vec![20, 15, 10, 5]);
+        assert!(range_step(20i, 0, -6).collect::<Vec<int>>() ==
+                vec![20, 14, 8, 2]);
+        assert!(range_step(200u8, 255, 50).collect::<Vec<u8>>() ==
+                vec![200u8, 250]);
+        assert!(range_step(200, -5, 1).collect::<Vec<int>>() == vec![]);
+        assert!(range_step(200, 200, 1).collect::<Vec<int>>() == vec![]);
     }
 
     #[test]
     fn test_range_step_inclusive() {
-        assert_eq!(range_step_inclusive(0i, 20, 5).collect::<Vec<int>>(), vec![0, 5, 10, 15, 20]);
-        assert_eq!(range_step_inclusive(20i, 0, -5).collect::<Vec<int>>(), vec![20, 15, 10, 5, 0]);
-        assert_eq!(range_step_inclusive(20i, 0, -6).collect::<Vec<int>>(), vec![20, 14, 8, 2]);
-        assert_eq!(range_step_inclusive(200u8, 255, 50).collect::<Vec<u8>>(), vec![200u8, 250]);
-        assert_eq!(range_step_inclusive(200, -5, 1).collect::<Vec<int>>(), vec![]);
-        assert_eq!(range_step_inclusive(200, 200, 1).collect::<Vec<int>>(), vec![200]);
+        assert!(range_step_inclusive(0i, 20, 5).collect::<Vec<int>>() ==
+                vec![0, 5, 10, 15, 20]);
+        assert!(range_step_inclusive(20i, 0, -5).collect::<Vec<int>>() ==
+                vec![20, 15, 10, 5, 0]);
+        assert!(range_step_inclusive(20i, 0, -6).collect::<Vec<int>>() ==
+                vec![20, 14, 8, 2]);
+        assert!(range_step_inclusive(200u8, 255, 50).collect::<Vec<u8>>() ==
+                vec![200u8, 250]);
+        assert!(range_step_inclusive(200, -5, 1).collect::<Vec<int>>() ==
+                vec![]);
+        assert!(range_step_inclusive(200, 200, 1).collect::<Vec<int>>() ==
+                vec![200]);
     }
 
     #[test]
diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs
index a126766b0de..05b314b6998 100644
--- a/src/libcore/lib.rs
+++ b/src/libcore/lib.rs
@@ -11,7 +11,7 @@
 //! The Rust core library
 //!
 //! This library is meant to represent the core functionality of rust that is
-//! maximally portable to other platforms. To that exent, this library has no
+//! maximally portable to other platforms. To that extent, this library has no
 //! knowledge of things like allocation, threads, I/O, etc. This library is
 //! built on the assumption of a few existing symbols:
 //!
@@ -48,15 +48,14 @@
 #[cfg(test)] extern crate realcore = "core";
 #[cfg(test)] extern crate libc;
 #[cfg(test)] extern crate native;
-#[phase(syntax, link)] #[cfg(test)] extern crate realstd = "std";
-#[phase(syntax, link)] #[cfg(test)] extern crate log;
+#[cfg(test)] extern crate rand;
+#[cfg(test)] extern crate realstd = "std";
 
 #[cfg(test)] pub use cmp = realcore::cmp;
 #[cfg(test)] pub use kinds = realcore::kinds;
 #[cfg(test)] pub use ops = realcore::ops;
 #[cfg(test)] pub use ty = realcore::ty;
 
-#[cfg(not(test))]
 mod macros;
 
 #[path = "num/float_macros.rs"] mod float_macros;
@@ -131,13 +130,13 @@ mod core {
 mod std {
     pub use clone;
     pub use cmp;
-    pub use fmt;
     pub use kinds;
     pub use option;
+    pub use fmt;
 
-    #[cfg(test)] pub use realstd::fmt;    // needed for fail!()
     #[cfg(test)] pub use realstd::rt;     // needed for fail!()
-    #[cfg(test)] pub use realstd::option; // needed for assert!()
+    // #[cfg(test)] pub use realstd::option; // needed for fail!()
+    // #[cfg(test)] pub use realstd::fmt;    // needed for fail!()
     #[cfg(test)] pub use realstd::os;     // needed for tests
     #[cfg(test)] pub use realstd::slice;  // needed for tests
     #[cfg(test)] pub use realstd::vec;    // needed for vec![]
diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs
index a04d93260c5..6474c5e37a4 100644
--- a/src/libcore/macros.rs
+++ b/src/libcore/macros.rs
@@ -54,6 +54,17 @@ macro_rules! assert(
     );
 )
 
+/// Runtime assertion for equality, for details see std::macros
+macro_rules! assert_eq(
+    ($cond1:expr, $cond2:expr) => ({
+        let c1 = $cond1;
+        let c2 = $cond2;
+        if c1 != c2 || c2 != c1 {
+            fail!("expressions not equal, left: {}, right: {}", c1, c2);
+        }
+    })
+)
+
 /// Runtime assertion, disableable at compile time
 #[macro_export]
 macro_rules! debug_assert(
@@ -65,3 +76,13 @@ macro_rules! debug_assert(
 macro_rules! try(
     ($e:expr) => (match $e { Ok(e) => e, Err(e) => return Err(e) })
 )
+
+#[cfg(test)]
+macro_rules! vec( ($($e:expr),*) => ({
+    let mut _v = ::std::vec::Vec::new();
+    $(_v.push($e);)*
+    _v
+}) )
+
+#[cfg(test)]
+macro_rules! format( ($($arg:tt)*) => (format_args!(::fmt::format, $($arg)*)) )
diff --git a/src/libcore/option.rs b/src/libcore/option.rs
index 614d8eeff27..00f21ee4c9c 100644
--- a/src/libcore/option.rs
+++ b/src/libcore/option.rs
@@ -595,9 +595,11 @@ pub fn collect<T, Iter: Iterator<Option<T>>, V: FromIterator<T>>(iter: Iter) ->
 
 #[cfg(test)]
 mod tests {
-    use realstd::option::collect;
-    use realstd::prelude::*;
-    use realstd::iter::range;
+    use realstd::vec::Vec;
+    use realstd::str::StrAllocating;
+    use option::collect;
+    use prelude::*;
+    use iter::range;
 
     use str::StrSlice;
     use kinds::marker;
@@ -638,7 +640,7 @@ mod tests {
         impl ::ops::Drop for R {
            fn drop(&mut self) {
                 let ii = &*self.i;
-                let i = ii.borrow().clone();
+                let i = *ii.borrow();
                 *ii.borrow_mut() = i + 1;
             }
         }
@@ -649,9 +651,14 @@ mod tests {
             }
         }
 
+        fn realclone<T: ::realstd::clone::Clone>(t: &T) -> T {
+            use realstd::clone::Clone;
+            t.clone()
+        }
+
         let i = Rc::new(RefCell::new(0));
         {
-            let x = R(i.clone());
+            let x = R(realclone(&i));
             let opt = Some(x);
             let _y = opt.unwrap();
         }
@@ -849,21 +856,21 @@ mod tests {
     fn test_collect() {
         let v: Option<Vec<int>> = collect(range(0, 0)
                                           .map(|_| Some(0)));
-        assert_eq!(v, Some(vec![]));
+        assert!(v == Some(vec![]));
 
         let v: Option<Vec<int>> = collect(range(0, 3)
                                           .map(|x| Some(x)));
-        assert_eq!(v, Some(vec![0, 1, 2]));
+        assert!(v == Some(vec![0, 1, 2]));
 
         let v: Option<Vec<int>> = collect(range(0, 3)
                                           .map(|x| if x > 1 { None } else { Some(x) }));
-        assert_eq!(v, None);
+        assert!(v == None);
 
         // test that it does not take more elements than it needs
         let mut functions = [|| Some(()), || None, || fail!()];
 
         let v: Option<Vec<()>> = collect(functions.mut_iter().map(|f| (*f)()));
 
-        assert_eq!(v, None);
+        assert!(v == None);
     }
 }
diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs
index 438e18d999b..acdf0bf0658 100644
--- a/src/libcore/ptr.rs
+++ b/src/libcore/ptr.rs
@@ -480,7 +480,7 @@ impl<T> Ord for *mut T {
 #[cfg(test)]
 pub mod ptr_tests {
     use super::*;
-    use realstd::prelude::*;
+    use prelude::*;
 
     use realstd::c_str::ToCStr;
     use mem;
@@ -660,9 +660,6 @@ pub mod ptr_tests {
                     let expected = expected_arr[ctr].with_ref(|buf| {
                             str::raw::from_c_str(buf)
                         });
-                    debug!(
-                        "test_ptr_array_each_with_len e: {}, a: {}",
-                        expected, actual);
                     assert_eq!(actual, expected);
                     ctr += 1;
                     iteration_count += 1;
@@ -696,9 +693,6 @@ pub mod ptr_tests {
                     let expected = expected_arr[ctr].with_ref(|buf| {
                         str::raw::from_c_str(buf)
                     });
-                    debug!(
-                        "test_ptr_array_each e: {}, a: {}",
-                        expected, actual);
                     assert_eq!(actual, expected);
                     ctr += 1;
                     iteration_count += 1;
diff --git a/src/libcore/result.rs b/src/libcore/result.rs
index 80d201c899d..3237269e4a6 100644
--- a/src/libcore/result.rs
+++ b/src/libcore/result.rs
@@ -268,7 +268,7 @@
 
 use clone::Clone;
 use cmp::Eq;
-use fmt::Show;
+use std::fmt::Show;
 use iter::{Iterator, FromIterator};
 use option::{None, Option, Some};
 
@@ -621,9 +621,12 @@ pub fn fold_<T,E,Iter:Iterator<Result<T,E>>>(iterator: Iter) -> Result<(),E> {
 
 #[cfg(test)]
 mod tests {
-    use realstd::result::{collect, fold, fold_};
-    use realstd::prelude::*;
-    use realstd::iter::range;
+    use realstd::vec::Vec;
+    use realstd::str::StrAllocating;
+
+    use result::{collect, fold, fold_};
+    use prelude::*;
+    use iter::range;
 
     pub fn op1() -> Result<int, ~str> { Ok(666) }
     pub fn op2() -> Result<int, ~str> { Err("sadface".to_owned()) }
@@ -670,33 +673,37 @@ mod tests {
 
     #[test]
     pub fn test_impl_map() {
-        assert_eq!(Ok::<~str, ~str>("a".to_owned()).map(|x| x + "b"), Ok("ab".to_owned()));
-        assert_eq!(Err::<~str, ~str>("a".to_owned()).map(|x| x + "b"), Err("a".to_owned()));
+        assert_eq!(Ok::<~str, ~str>("a".to_owned()).map(|x| x + "b"),
+                   Ok("ab".to_owned()));
+        assert_eq!(Err::<~str, ~str>("a".to_owned()).map(|x| x + "b"),
+                   Err("a".to_owned()));
     }
 
     #[test]
     pub fn test_impl_map_err() {
-        assert_eq!(Ok::<~str, ~str>("a".to_owned()).map_err(|x| x + "b"), Ok("a".to_owned()));
-        assert_eq!(Err::<~str, ~str>("a".to_owned()).map_err(|x| x + "b"), Err("ab".to_owned()));
+        assert_eq!(Ok::<~str, ~str>("a".to_owned()).map_err(|x| x + "b"),
+                   Ok("a".to_owned()));
+        assert_eq!(Err::<~str, ~str>("a".to_owned()).map_err(|x| x + "b"),
+                   Err("ab".to_owned()));
     }
 
     #[test]
     fn test_collect() {
         let v: Result<Vec<int>, ()> = collect(range(0, 0).map(|_| Ok::<int, ()>(0)));
-        assert_eq!(v, Ok(vec![]));
+        assert!(v == Ok(vec![]));
 
         let v: Result<Vec<int>, ()> = collect(range(0, 3).map(|x| Ok::<int, ()>(x)));
-        assert_eq!(v, Ok(vec![0, 1, 2]));
+        assert!(v == Ok(vec![0, 1, 2]));
 
         let v: Result<Vec<int>, int> = collect(range(0, 3)
                                                .map(|x| if x > 1 { Err(x) } else { Ok(x) }));
-        assert_eq!(v, Err(2));
+        assert!(v == Err(2));
 
         // test that it does not take more elements than it needs
         let mut functions = [|| Ok(()), || Err(1), || fail!()];
 
         let v: Result<Vec<()>, int> = collect(functions.mut_iter().map(|f| (*f)()));
-        assert_eq!(v, Err(1));
+        assert!(v == Err(1));
     }
 
     #[test]
@@ -721,15 +728,6 @@ mod tests {
     }
 
     #[test]
-    pub fn test_to_str() {
-        let ok: Result<int, ~str> = Ok(100);
-        let err: Result<int, ~str> = Err("Err".to_owned());
-
-        assert_eq!(ok.to_str(), "Ok(100)".to_owned());
-        assert_eq!(err.to_str(), "Err(Err)".to_owned());
-    }
-
-    #[test]
     pub fn test_fmt_default() {
         let ok: Result<int, ~str> = Ok(100);
         let err: Result<int, ~str> = Err("Err".to_owned());
diff --git a/src/libcore/should_not_exist.rs b/src/libcore/should_not_exist.rs
index 9272f24da9d..b55952e7059 100644
--- a/src/libcore/should_not_exist.rs
+++ b/src/libcore/should_not_exist.rs
@@ -20,7 +20,7 @@
 //      1. Implement DST
 //      2. Make `Box<T>` not a language feature
 //      3. Move `Box<T>` to a separate crate, liballoc.
-//      4. Implement relevant trais in liballoc, not libcore
+//      4. Implement relevant traits in liballoc, not libcore
 //
 // Currently, no progress has been made on this list.