about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-05-01 18:06:59 -0700
committerAlex Crichton <alex@alexcrichton.com>2014-05-07 08:16:42 -0700
commit104e285eb8f848867c2666765e2aa8221e8a97d1 (patch)
treed261196dbf9c8006ce647799fcc743a3a350910c /src/libcore
parentf62c121eb0de35ac03a7860e6039202f2522e527 (diff)
downloadrust-104e285eb8f848867c2666765e2aa8221e8a97d1.tar.gz
rust-104e285eb8f848867c2666765e2aa8221e8a97d1.zip
core: Get coretest working
This mostly involved frobbing imports between realstd, realcore, and the core
being test. Some of the imports are a little counterintuitive, but it mainly
focuses around libcore's types not implementing Show while libstd's types
implement Show.
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/any.rs14
-rw-r--r--src/libcore/bool.rs3
-rw-r--r--src/libcore/cast.rs2
-rw-r--r--src/libcore/cell.rs14
-rw-r--r--src/libcore/char.rs14
-rw-r--r--src/libcore/clone.rs2
-rw-r--r--src/libcore/failure.rs1
-rw-r--r--src/libcore/finally.rs5
-rw-r--r--src/libcore/intrinsics.rs2
-rw-r--r--src/libcore/iter.rs8
-rw-r--r--src/libcore/lib.rs31
-rw-r--r--src/libcore/mem.rs2
-rw-r--r--src/libcore/num/f32.rs7
-rw-r--r--src/libcore/num/f64.rs7
-rw-r--r--src/libcore/num/i16.rs8
-rw-r--r--src/libcore/num/i32.rs8
-rw-r--r--src/libcore/num/i64.rs8
-rw-r--r--src/libcore/num/i8.rs8
-rw-r--r--src/libcore/num/int.rs8
-rw-r--r--src/libcore/num/int_macros.rs9
-rw-r--r--src/libcore/num/mod.rs16
-rw-r--r--src/libcore/num/u16.rs8
-rw-r--r--src/libcore/num/u32.rs8
-rw-r--r--src/libcore/num/u64.rs8
-rw-r--r--src/libcore/num/u8.rs8
-rw-r--r--src/libcore/num/uint.rs8
-rw-r--r--src/libcore/num/uint_macros.rs7
-rw-r--r--src/libcore/option.rs19
-rw-r--r--src/libcore/prelude.rs47
-rw-r--r--src/libcore/ptr.rs6
-rw-r--r--src/libcore/result.rs8
-rw-r--r--src/libcore/should_not_exist.rs9
-rw-r--r--src/libcore/tuple.rs2
33 files changed, 238 insertions, 77 deletions
diff --git a/src/libcore/any.rs b/src/libcore/any.rs
index f22453eb740..0c07bf91bd2 100644
--- a/src/libcore/any.rs
+++ b/src/libcore/any.rs
@@ -150,6 +150,7 @@ mod tests {
     use super::*;
     use owned::Box;
     use str::StrSlice;
+    use realstd::str::StrAllocating;
 
     #[deriving(Eq, Show)]
     struct Test;
@@ -274,13 +275,20 @@ mod tests {
 
     #[test]
     fn test_show() {
+<<<<<<< HEAD
         let a = box 8u as Box<Any>;
         let b = box Test as Box<Any>;
         assert_eq!(format!("{}", a), "Box<Any>".to_owned());
         assert_eq!(format!("{}", b), "Box<Any>".to_owned());
-
-        let a = &8u as &Any;
-        let b = &Test as &Any;
+=======
+        let a = ~8u as ~::realcore::any::Any;
+        let b = ~Test as ~::realcore::any::Any;
+        assert_eq!(format!("{}", a), "~Any".to_owned());
+        assert_eq!(format!("{}", b), "~Any".to_owned());
+>>>>>>> core: Get coretest working
+
+        let a = &8u as &::realcore::any::Any;
+        let b = &Test as &::realcore::any::Any;
         assert_eq!(format!("{}", a), "&Any".to_owned());
         assert_eq!(format!("{}", b), "&Any".to_owned());
     }
diff --git a/src/libcore/bool.rs b/src/libcore/bool.rs
index 0ccb7f93837..0f632f4d4d0 100644
--- a/src/libcore/bool.rs
+++ b/src/libcore/bool.rs
@@ -175,9 +175,8 @@ impl Default for bool {
 
 #[cfg(test)]
 mod tests {
-    use prelude::*;
+    use realstd::prelude::*;
     use super::to_bit;
-    use str::StrSlice;
 
     #[test]
     fn test_to_bit() {
diff --git a/src/libcore/cast.rs b/src/libcore/cast.rs
index 7a8f517bbf9..8cea197fbfa 100644
--- a/src/libcore/cast.rs
+++ b/src/libcore/cast.rs
@@ -108,7 +108,7 @@ pub unsafe fn copy_lifetime_vec<'a,S,T>(_ptr: &'a [S], ptr: &T) -> &'a T {
 mod tests {
     use cast::{bump_box_refcount, transmute};
     use raw;
-    use str::StrSlice;
+    use realstd::str::StrAllocating;
 
     #[test]
     fn test_transmute_copy() {
diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs
index 8c520a4788a..8951c7d806a 100644
--- a/src/libcore/cell.rs
+++ b/src/libcore/cell.rs
@@ -221,22 +221,22 @@ mod test {
     #[test]
     fn smoketest_cell() {
         let x = Cell::new(10);
-        assert_eq!(x, Cell::new(10));
-        assert_eq!(x.get(), 10);
+        assert!(x == Cell::new(10));
+        assert!(x.get() == 10);
         x.set(20);
-        assert_eq!(x, Cell::new(20));
-        assert_eq!(x.get(), 20);
+        assert!(x == Cell::new(20));
+        assert!(x.get() == 20);
 
         let y = Cell::new((30, 40));
-        assert_eq!(y, Cell::new((30, 40)));
-        assert_eq!(y.get(), (30, 40));
+        assert!(y == Cell::new((30, 40)));
+        assert!(y.get() == (30, 40));
     }
 
     #[test]
     fn cell_has_sensible_show() {
         use str::StrSlice;
 
-        let x = Cell::new("foo bar");
+        let x = ::realcore::cell::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 298a3b38ee5..1e31486c63f 100644
--- a/src/libcore/char.rs
+++ b/src/libcore/char.rs
@@ -29,10 +29,6 @@ use option::{None, Option, Some};
 use iter::{Iterator, range_step};
 use unicode::{derived_property, property, general_category, decompose, conversions};
 
-#[cfg(test)] use str::Str;
-#[cfg(test)] use strbuf::StrBuf;
-#[cfg(test)] use slice::ImmutableVector;
-
 #[cfg(not(test))] use cmp::{Eq, Ord, TotalEq, TotalOrd, Ordering};
 #[cfg(not(test))] use default::Default;
 
@@ -682,6 +678,14 @@ impl Default for char {
 
 #[cfg(test)]
 mod test {
+    use super::{escape_unicode, escape_default};
+
+    use realcore::char::Char;
+    use slice::ImmutableVector;
+    use realstd::option::{Some, None};
+    use realstd::strbuf::StrBuf;
+    use realstd::str::StrAllocating;
+
     #[test]
     fn test_is_lowercase() {
         assert!('a'.is_lowercase());
@@ -822,7 +826,7 @@ mod test {
 
     #[test]
     fn test_to_str() {
-        use to_str::ToStr;
+        use realstd::to_str::ToStr;
         let s = 't'.to_str();
         assert_eq!(s, "t".to_owned());
     }
diff --git a/src/libcore/clone.rs b/src/libcore/clone.rs
index 0e39e3c36b7..659d797bc67 100644
--- a/src/libcore/clone.rs
+++ b/src/libcore/clone.rs
@@ -128,6 +128,8 @@ extern_fn_clone!(A, B, C, D, E, F, G, H)
 
 #[cfg(test)]
 mod test {
+    use prelude::*;
+
     #[test]
     fn test_owned_clone() {
         let a = box 5i;
diff --git a/src/libcore/failure.rs b/src/libcore/failure.rs
index efa24fa96f8..2296e663033 100644
--- a/src/libcore/failure.rs
+++ b/src/libcore/failure.rs
@@ -12,6 +12,7 @@
 
 #![allow(dead_code)]
 
+#[cfg(not(test))]
 use str::raw::c_str_to_static_slice;
 
 // FIXME: Once std::fmt is in libcore, all of these functions should delegate
diff --git a/src/libcore/finally.rs b/src/libcore/finally.rs
index ff167f20fff..a4d261f539a 100644
--- a/src/libcore/finally.rs
+++ b/src/libcore/finally.rs
@@ -34,8 +34,6 @@ use std::unstable::finally::Finally;
 
 use ops::Drop;
 
-#[cfg(test)] use task::failing;
-
 /// A trait for executing a destructor unconditionally after a block of code,
 /// regardless of whether the blocked fails.
 pub trait Finally<T> {
@@ -119,6 +117,9 @@ impl<'a,A> Drop for Finallyalizer<'a,A> {
 
 #[cfg(test)]
 mod test {
+    use super::{try_finally, Finally};
+    use realstd::task::failing;
+
     #[test]
     fn test_success() {
         let mut i = 0;
diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs
index 770433c4521..d7a277d3b6b 100644
--- a/src/libcore/intrinsics.rs
+++ b/src/libcore/intrinsics.rs
@@ -46,7 +46,7 @@ A quick refresher on memory ordering:
 
 // This is needed to prevent duplicate lang item definitions.
 #[cfg(test)]
-pub use realstd::intrinsics::{TyDesc, Opaque, TyVisitor, TypeId};
+pub use realcore::intrinsics::{TyDesc, Opaque, TyVisitor, TypeId};
 
 pub type GlueFn = extern "Rust" fn(*i8);
 
diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs
index 6d40db1be4d..5ee642cd810 100644
--- a/src/libcore/iter.rs
+++ b/src/libcore/iter.rs
@@ -1090,7 +1090,7 @@ impl<A, T: Clone + RandomAccessIterator<A>> RandomAccessIterator<A> for Cycle<T>
 pub struct Chain<T, U> {
     a: T,
     b: U,
-    flag: bool
+    flag: bool,
 }
 
 impl<A, T: Iterator<A>, U: Iterator<A>> Iterator<A> for Chain<T, U> {
@@ -2329,13 +2329,13 @@ pub mod order {
 
 #[cfg(test)]
 mod tests {
-    use super::*;
-    use prelude::*;
+    use realstd::prelude::*;
+    use realstd::iter::*;
+    use realstd::num;
 
     use cmp;
     use owned::Box;
     use uint;
-    use num;
 
     #[test]
     fn test_counter_from_iter() {
diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs
index 550dcc1fed8..5aef169cd57 100644
--- a/src/libcore/lib.rs
+++ b/src/libcore/lib.rs
@@ -18,9 +18,21 @@
        html_root_url = "http://static.rust-lang.org/doc/master")]
 
 #![no_std]
-#![feature(globs, macro_rules, managed_boxes)]
+#![feature(globs, macro_rules, managed_boxes, phase)]
 #![deny(missing_doc)]
 
+#[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)] pub use kinds = realcore::kinds;
+#[cfg(test)] pub use cmp = realcore::cmp;
+#[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;
@@ -44,6 +56,10 @@ mod macros;
 
 pub mod num;
 
+/* The libcore prelude, not as all-encompassing as the libstd prelude */
+
+pub mod prelude;
+
 /* Core modules for ownership management */
 
 pub mod cast;
@@ -53,10 +69,10 @@ pub mod ptr;
 
 /* Core language traits */
 
-pub mod cmp;
-pub mod kinds;
-pub mod ops;
-pub mod ty;
+#[cfg(not(test))] pub mod kinds;
+#[cfg(not(test))] pub mod ops;
+#[cfg(not(test))] pub mod ty;
+#[cfg(not(test))] pub mod cmp;
 pub mod clone;
 pub mod default;
 pub mod container;
@@ -88,4 +104,9 @@ mod should_not_exist;
 mod std {
     pub use clone;
     pub use cmp;
+
+    #[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::os;     // needed for tests
 }
diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs
index 860304232d4..0bac90064d6 100644
--- a/src/libcore/mem.rs
+++ b/src/libcore/mem.rs
@@ -293,7 +293,7 @@ pub fn drop<T>(_x: T) { }
 mod tests {
     use mem::*;
     use option::{Some,None};
-    use str::StrSlice;
+    use realstd::str::StrAllocating;
 
     #[test]
     fn size_of_basic() {
diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs
index ac45f52e710..c4cdc5a0a40 100644
--- a/src/libcore/num/f32.rs
+++ b/src/libcore/num/f32.rs
@@ -10,11 +10,12 @@
 
 //! Operations and constants for 32-bits floats (`f32` type)
 
-use cmp::{Eq, Ord};
 use default::Default;
 use intrinsics;
 use num::{Zero, One, Bounded, Signed, Num, Primitive};
-use ops::{Add, Sub, Mul, Div, Rem, Neg};
+
+#[cfg(not(test))] use cmp::{Eq, Ord};
+#[cfg(not(test))] use ops::{Add, Sub, Mul, Div, Rem, Neg};
 
 pub static RADIX: uint = 2u;
 
@@ -100,6 +101,7 @@ pub mod consts {
     pub static LN_10: f32 = 2.30258509299404568401799145468436421_f32;
 }
 
+#[cfg(not(test))]
 impl Ord for f32 {
     #[inline]
     fn lt(&self, other: &f32) -> bool { (*self) < (*other) }
@@ -110,6 +112,7 @@ impl Ord for f32 {
     #[inline]
     fn gt(&self, other: &f32) -> bool { (*self) > (*other) }
 }
+#[cfg(not(test))]
 impl Eq for f32 {
     #[inline]
     fn eq(&self, other: &f32) -> bool { (*self) == (*other) }
diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs
index f83ab510b7f..b15b4566cdd 100644
--- a/src/libcore/num/f64.rs
+++ b/src/libcore/num/f64.rs
@@ -10,11 +10,12 @@
 
 //! Operations and constants for 64-bits floats (`f64` type)
 
-use cmp::{Eq, Ord};
 use default::Default;
 use intrinsics;
 use num::{Zero, One, Bounded, Signed, Num, Primitive};
-use ops::{Add, Sub, Mul, Div, Rem, Neg};
+
+#[cfg(not(test))] use cmp::{Eq, Ord};
+#[cfg(not(test))] use ops::{Add, Sub, Mul, Div, Rem, Neg};
 
 // FIXME(#5527): These constants should be deprecated once associated
 // constants are implemented in favour of referencing the respective
@@ -106,6 +107,7 @@ pub mod consts {
     pub static LN_10: f64 = 2.30258509299404568401799145468436421_f64;
 }
 
+#[cfg(not(test))]
 impl Ord for f64 {
     #[inline]
     fn lt(&self, other: &f64) -> bool { (*self) < (*other) }
@@ -116,6 +118,7 @@ impl Ord for f64 {
     #[inline]
     fn gt(&self, other: &f64) -> bool { (*self) > (*other) }
 }
+#[cfg(not(test))]
 impl Eq for f64 {
     #[inline]
     fn eq(&self, other: &f64) -> bool { (*self) == (*other) }
diff --git a/src/libcore/num/i16.rs b/src/libcore/num/i16.rs
index 63ad3bf7d90..361f75b9e88 100644
--- a/src/libcore/num/i16.rs
+++ b/src/libcore/num/i16.rs
@@ -10,14 +10,18 @@
 
 //! Operations and constants for signed 16-bits integers (`i16` type)
 
-use cmp::{Eq, Ord, TotalEq, TotalOrd, Less, Greater, Equal, Ordering};
 use default::Default;
 use intrinsics;
 use num::{Bitwise, Bounded, Zero, One, Signed, Num, Primitive, Int};
 use num::{CheckedDiv, CheckedAdd, CheckedSub, CheckedMul};
+use option::{Option, Some, None};
+
+#[cfg(not(test))]
+use cmp::{Eq, Ord, TotalEq, TotalOrd, Less, Greater, Equal, Ordering};
+#[cfg(not(test))]
 use ops::{Add, Sub, Mul, Div, Rem, Neg, BitOr, BitAnd, BitXor};
+#[cfg(not(test))]
 use ops::{Shl, Shr, Not};
-use option::{Option, Some, None};
 
 int_module!(i16, 16)
 
diff --git a/src/libcore/num/i32.rs b/src/libcore/num/i32.rs
index 25f11be459e..9071f150292 100644
--- a/src/libcore/num/i32.rs
+++ b/src/libcore/num/i32.rs
@@ -10,14 +10,18 @@
 
 //! Operations and constants for signed 32-bits integers (`i32` type)
 
-use cmp::{Eq, Ord, TotalEq, TotalOrd, Less, Greater, Equal, Ordering};
 use default::Default;
 use intrinsics;
 use num::{Bitwise, Bounded, Zero, One, Signed, Num, Primitive, Int};
 use num::{CheckedDiv, CheckedAdd, CheckedSub, CheckedMul};
+use option::{Option, Some, None};
+
+#[cfg(not(test))]
+use cmp::{Eq, Ord, TotalEq, TotalOrd, Less, Greater, Equal, Ordering};
+#[cfg(not(test))]
 use ops::{Add, Sub, Mul, Div, Rem, Neg, BitOr, BitAnd, BitXor};
+#[cfg(not(test))]
 use ops::{Shl, Shr, Not};
-use option::{Option, Some, None};
 
 int_module!(i32, 32)
 
diff --git a/src/libcore/num/i64.rs b/src/libcore/num/i64.rs
index 24585009a1b..ba7b715f13d 100644
--- a/src/libcore/num/i64.rs
+++ b/src/libcore/num/i64.rs
@@ -10,14 +10,18 @@
 
 //! Operations and constants for signed 64-bits integers (`i64` type)
 
-use cmp::{Eq, Ord, TotalEq, TotalOrd, Less, Greater, Equal, Ordering};
 use default::Default;
 use intrinsics;
 use num::{Bitwise, Bounded, Zero, One, Signed, Num, Primitive, Int};
 use num::{CheckedDiv, CheckedAdd, CheckedSub, CheckedMul};
+use option::{Option, Some, None};
+
+#[cfg(not(test))]
+use cmp::{Eq, Ord, TotalEq, TotalOrd, Less, Greater, Equal, Ordering};
+#[cfg(not(test))]
 use ops::{Add, Sub, Mul, Div, Rem, Neg, BitOr, BitAnd, BitXor};
+#[cfg(not(test))]
 use ops::{Shl, Shr, Not};
-use option::{Option, Some, None};
 
 int_module!(i64, 64)
 
diff --git a/src/libcore/num/i8.rs b/src/libcore/num/i8.rs
index 0d8b9541f7b..6ec05eb50ee 100644
--- a/src/libcore/num/i8.rs
+++ b/src/libcore/num/i8.rs
@@ -10,14 +10,18 @@
 
 //! Operations and constants for signed 8-bits integers (`i8` type)
 
-use cmp::{Eq, Ord, TotalEq, TotalOrd, Less, Greater, Equal, Ordering};
 use default::Default;
 use intrinsics;
 use num::{Bitwise, Bounded, Zero, One, Signed, Num, Primitive, Int};
 use num::{CheckedDiv, CheckedAdd, CheckedSub, CheckedMul};
+use option::{Option, Some, None};
+
+#[cfg(not(test))]
+use cmp::{Eq, Ord, TotalEq, TotalOrd, Less, Greater, Equal, Ordering};
+#[cfg(not(test))]
 use ops::{Add, Sub, Mul, Div, Rem, Neg, BitOr, BitAnd, BitXor};
+#[cfg(not(test))]
 use ops::{Shl, Shr, Not};
-use option::{Option, Some, None};
 
 int_module!(i8, 8)
 
diff --git a/src/libcore/num/int.rs b/src/libcore/num/int.rs
index dacfe987d90..8273fa2b39f 100644
--- a/src/libcore/num/int.rs
+++ b/src/libcore/num/int.rs
@@ -10,14 +10,18 @@
 
 //! Operations and constants for architecture-sized signed integers (`int` type)
 
-use cmp::{Eq, Ord, TotalEq, TotalOrd, Less, Greater, Equal, Ordering};
 use default::Default;
 use intrinsics;
 use num::{Bitwise, Bounded, Zero, One, Signed, Num, Primitive, Int};
 use num::{CheckedDiv, CheckedAdd, CheckedSub, CheckedMul};
+use option::{Option, Some, None};
+
+#[cfg(not(test))]
+use cmp::{Eq, Ord, TotalEq, TotalOrd, Less, Greater, Equal, Ordering};
+#[cfg(not(test))]
 use ops::{Add, Sub, Mul, Div, Rem, Neg, BitOr, BitAnd, BitXor};
+#[cfg(not(test))]
 use ops::{Shl, Shr, Not};
-use option::{Option, Some, None};
 
 #[cfg(target_word_size = "32")] int_module!(int, 32)
 #[cfg(target_word_size = "64")] int_module!(int, 64)
diff --git a/src/libcore/num/int_macros.rs b/src/libcore/num/int_macros.rs
index 771d801dcb7..7d21764eb70 100644
--- a/src/libcore/num/int_macros.rs
+++ b/src/libcore/num/int_macros.rs
@@ -28,15 +28,19 @@ pub static MIN: $T = (-1 as $T) << (BITS - 1);
 // calling the `Bounded::max_value` function.
 pub static MAX: $T = !MIN;
 
+#[cfg(not(test))]
 impl Ord for $T {
     #[inline]
     fn lt(&self, other: &$T) -> bool { *self < *other }
 }
+#[cfg(not(test))]
 impl TotalEq for $T {}
+#[cfg(not(test))]
 impl Eq for $T {
     #[inline]
     fn eq(&self, other: &$T) -> bool { *self == *other }
 }
+#[cfg(not(test))]
 impl TotalOrd for $T {
     #[inline]
     fn cmp(&self, other: &$T) -> Ordering {
@@ -221,7 +225,7 @@ impl Bounded for $T {
 impl CheckedDiv for $T {
     #[inline]
     fn checked_div(&self, v: &$T) -> Option<$T> {
-        if *v == 0 {
+        if *v == 0 || (*self == MIN && *v == -1) {
             None
         } else {
             Some(self / *v)
@@ -244,12 +248,9 @@ mod tests {
     use super::*;
 
     use int;
-    use i32;
     use num;
     use num::Bitwise;
     use num::CheckedDiv;
-    use num::ToStrRadix;
-    use str::StrSlice;
 
     #[test]
     fn test_overflows() {
diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs
index c91b0f5918d..22411fef3b2 100644
--- a/src/libcore/num/mod.rs
+++ b/src/libcore/num/mod.rs
@@ -858,3 +858,19 @@ pub trait CheckedDiv: Div<Self, Self> {
     /// `None` is returned.
     fn checked_div(&self, v: &Self) -> Option<Self>;
 }
+
+/// Helper function for testing numeric operations
+#[cfg(test)]
+pub fn test_num<T:Num + NumCast + ::std::fmt::Show>(ten: T, two: T) {
+    assert_eq!(ten.add(&two),  cast(12).unwrap());
+    assert_eq!(ten.sub(&two),  cast(8).unwrap());
+    assert_eq!(ten.mul(&two),  cast(20).unwrap());
+    assert_eq!(ten.div(&two),  cast(5).unwrap());
+    assert_eq!(ten.rem(&two),  cast(0).unwrap());
+
+    assert_eq!(ten.add(&two),  ten + two);
+    assert_eq!(ten.sub(&two),  ten - two);
+    assert_eq!(ten.mul(&two),  ten * two);
+    assert_eq!(ten.div(&two),  ten / two);
+    assert_eq!(ten.rem(&two),  ten % two);
+}
diff --git a/src/libcore/num/u16.rs b/src/libcore/num/u16.rs
index 92afe4955a8..96db898e3b0 100644
--- a/src/libcore/num/u16.rs
+++ b/src/libcore/num/u16.rs
@@ -10,14 +10,18 @@
 
 //! Operations and constants for unsigned 16-bits integers (`u16` type)
 
-use cmp::{Eq, Ord, TotalEq, TotalOrd, Less, Greater, Equal, Ordering};
 use default::Default;
 use intrinsics;
 use num::{Bitwise, Bounded, Zero, One, Unsigned, Num, Int, Primitive};
 use num::{CheckedAdd, CheckedSub, CheckedMul, CheckedDiv};
+use option::{Some, None, Option};
+
+#[cfg(not(test))]
+use cmp::{Eq, Ord, TotalEq, TotalOrd, Less, Greater, Equal, Ordering};
+#[cfg(not(test))]
 use ops::{Add, Sub, Mul, Div, Rem, Neg, BitAnd, BitOr, BitXor};
+#[cfg(not(test))]
 use ops::{Shl, Shr, Not};
-use option::{Some, None, Option};
 
 uint_module!(u16, i16, 16)
 
diff --git a/src/libcore/num/u32.rs b/src/libcore/num/u32.rs
index 2cac95e5c3b..2748b001bb8 100644
--- a/src/libcore/num/u32.rs
+++ b/src/libcore/num/u32.rs
@@ -10,14 +10,18 @@
 
 //! Operations and constants for unsigned 32-bits integers (`u32` type)
 
-use cmp::{Eq, Ord, TotalEq, TotalOrd, Less, Greater, Equal, Ordering};
 use default::Default;
 use intrinsics;
 use num::{Bitwise, Bounded, Zero, One, Unsigned, Num, Int, Primitive};
 use num::{CheckedAdd, CheckedSub, CheckedMul, CheckedDiv};
+use option::{Some, None, Option};
+
+#[cfg(not(test))]
+use cmp::{Eq, Ord, TotalEq, TotalOrd, Less, Greater, Equal, Ordering};
+#[cfg(not(test))]
 use ops::{Add, Sub, Mul, Div, Rem, Neg, BitAnd, BitOr, BitXor};
+#[cfg(not(test))]
 use ops::{Shl, Shr, Not};
-use option::{Some, None, Option};
 
 uint_module!(u32, i32, 32)
 
diff --git a/src/libcore/num/u64.rs b/src/libcore/num/u64.rs
index 7b6498b5a69..c047df09532 100644
--- a/src/libcore/num/u64.rs
+++ b/src/libcore/num/u64.rs
@@ -10,14 +10,18 @@
 
 //! Operations and constants for unsigned 64-bits integer (`u64` type)
 
-use cmp::{Eq, Ord, TotalEq, TotalOrd, Less, Greater, Equal, Ordering};
 use default::Default;
 use intrinsics;
 use num::{Bitwise, Bounded, Zero, One, Unsigned, Num, Int, Primitive};
 use num::{CheckedAdd, CheckedSub, CheckedMul, CheckedDiv};
+use option::{Some, None, Option};
+
+#[cfg(not(test))]
+use cmp::{Eq, Ord, TotalEq, TotalOrd, Less, Greater, Equal, Ordering};
+#[cfg(not(test))]
 use ops::{Add, Sub, Mul, Div, Rem, Neg, BitAnd, BitOr, BitXor};
+#[cfg(not(test))]
 use ops::{Shl, Shr, Not};
-use option::{Some, None, Option};
 
 uint_module!(u64, i64, 64)
 
diff --git a/src/libcore/num/u8.rs b/src/libcore/num/u8.rs
index 6916c0c9f32..a6df17956a1 100644
--- a/src/libcore/num/u8.rs
+++ b/src/libcore/num/u8.rs
@@ -10,14 +10,18 @@
 
 //! Operations and constants for unsigned 8-bits integers (`u8` type)
 
-use cmp::{Eq, Ord, TotalEq, TotalOrd, Less, Greater, Equal, Ordering};
 use default::Default;
 use intrinsics;
 use num::{Bitwise, Bounded, Zero, One, Unsigned, Num, Int, Primitive};
 use num::{CheckedAdd, CheckedSub, CheckedMul, CheckedDiv};
+use option::{Some, None, Option};
+
+#[cfg(not(test))]
+use cmp::{Eq, Ord, TotalEq, TotalOrd, Less, Greater, Equal, Ordering};
+#[cfg(not(test))]
 use ops::{Add, Sub, Mul, Div, Rem, Neg, BitAnd, BitOr, BitXor};
+#[cfg(not(test))]
 use ops::{Shl, Shr, Not};
-use option::{Some, None, Option};
 
 uint_module!(u8, i8, 8)
 
diff --git a/src/libcore/num/uint.rs b/src/libcore/num/uint.rs
index 40e4b8327dd..f988650cc01 100644
--- a/src/libcore/num/uint.rs
+++ b/src/libcore/num/uint.rs
@@ -10,14 +10,18 @@
 
 //! Operations and constants for architecture-sized unsigned integers (`uint` type)
 
-use cmp::{Eq, Ord, TotalEq, TotalOrd, Less, Greater, Equal, Ordering};
 use default::Default;
 use intrinsics;
 use num::{Bitwise, Bounded, Zero, One, Unsigned, Num, Int, Primitive};
 use num::{CheckedAdd, CheckedSub, CheckedMul, CheckedDiv};
+use option::{Some, None, Option};
+
+#[cfg(not(test))]
+use cmp::{Eq, Ord, TotalEq, TotalOrd, Less, Greater, Equal, Ordering};
+#[cfg(not(test))]
 use ops::{Add, Sub, Mul, Div, Rem, Neg, BitAnd, BitOr, BitXor};
+#[cfg(not(test))]
 use ops::{Shl, Shr, Not};
-use option::{Some, None, Option};
 
 uint_module!(uint, int, ::int::BITS)
 
diff --git a/src/libcore/num/uint_macros.rs b/src/libcore/num/uint_macros.rs
index 12aaf41b196..a53388bd0e3 100644
--- a/src/libcore/num/uint_macros.rs
+++ b/src/libcore/num/uint_macros.rs
@@ -19,15 +19,19 @@ pub static BYTES : uint = ($bits / 8);
 pub static MIN: $T = 0 as $T;
 pub static MAX: $T = 0 as $T - 1 as $T;
 
+#[cfg(not(test))]
 impl Ord for $T {
     #[inline]
     fn lt(&self, other: &$T) -> bool { *self < *other }
 }
+#[cfg(not(test))]
 impl TotalEq for $T {}
+#[cfg(not(test))]
 impl Eq for $T {
     #[inline]
     fn eq(&self, other: &$T) -> bool { *self == *other }
 }
+#[cfg(not(test))]
 impl TotalOrd for $T {
     #[inline]
     fn cmp(&self, other: &$T) -> Ordering {
@@ -184,9 +188,6 @@ mod tests {
     use num;
     use num::CheckedDiv;
     use num::Bitwise;
-    use num::ToStrRadix;
-    use str::StrSlice;
-    use u16;
 
     #[test]
     fn test_overflows() {
diff --git a/src/libcore/option.rs b/src/libcore/option.rs
index 84da65f90be..143e8bf2622 100644
--- a/src/libcore/option.rs
+++ b/src/libcore/option.rs
@@ -236,6 +236,7 @@ impl<T> Option<T> {
     ///
     /// Fails if the value is a `None` with a custom failure message provided by `msg`.
     #[inline]
+    #[cfg(not(test))]
     pub fn expect(self, msg: &str) -> T {
         match self {
             Some(val) => val,
@@ -243,6 +244,16 @@ impl<T> Option<T> {
         }
     }
 
+    // FIXME: once std::fmt is in libcore, this extra variant should not be
+    //        necessary.
+    #[cfg(test)]
+    pub fn expect(self, msg: &str) -> T {
+        match self {
+            Some(val) => val,
+            None => fail!("{}", msg),
+        }
+    }
+
     /// Moves a value out of an option type and returns it, consuming the `Option`.
     ///
     /// # Failure
@@ -605,10 +616,10 @@ pub fn collect<T, Iter: Iterator<Option<T>>, V: FromIterator<T>>(iter: Iter) ->
 
 #[cfg(test)]
 mod tests {
-    use super::*;
-    use prelude::*;
+    use realstd::option::collect;
+    use realstd::prelude::*;
+    use realstd::iter::range;
 
-    use iter::range;
     use str::StrSlice;
     use kinds::marker;
     use slice::ImmutableVector;
@@ -637,7 +648,7 @@ mod tests {
 
     #[test]
     fn test_get_resource() {
-        use rc::Rc;
+        use realstd::rc::Rc;
         use cell::RefCell;
 
         struct R {
diff --git a/src/libcore/prelude.rs b/src/libcore/prelude.rs
new file mode 100644
index 00000000000..efd6732f653
--- /dev/null
+++ b/src/libcore/prelude.rs
@@ -0,0 +1,47 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+//! The core prelude
+//!
+//! For more information, see std::prelude.
+
+// Reexported core operators
+pub use kinds::{Copy, Send, Sized, Share};
+pub use ops::{Add, Sub, Mul, Div, Rem, Neg, Not};
+pub use ops::{BitAnd, BitOr, BitXor};
+pub use ops::{Drop, Deref, DerefMut};
+pub use ops::{Shl, Shr, Index};
+pub use option::{Option, Some, None};
+pub use result::{Result, Ok, Err};
+
+// Reexported functions
+pub use iter::range;
+pub use mem::drop;
+
+// Reexported types and traits
+
+pub use char::Char;
+pub use clone::Clone;
+pub use cmp::{Eq, Ord, TotalEq, TotalOrd, Ordering, Less, Equal, Greater, Equiv};
+pub use container::{Container, Mutable, Map, MutableMap, Set, MutableSet};
+pub use iter::{FromIterator, Extendable};
+pub use iter::{Iterator, DoubleEndedIterator, RandomAccessIterator, CloneableIterator};
+pub use iter::{OrdIterator, MutableDoubleEndedIterator, ExactSize};
+pub use num::{Num, NumCast, CheckedAdd, CheckedSub, CheckedMul};
+pub use num::{Signed, Unsigned};
+pub use num::{Primitive, Int, ToPrimitive, FromPrimitive};
+pub use ptr::RawPtr;
+pub use str::{Str, StrSlice};
+pub use tuple::{Tuple1, Tuple2, Tuple3, Tuple4};
+pub use tuple::{Tuple5, Tuple6, Tuple7, Tuple8};
+pub use tuple::{Tuple9, Tuple10, Tuple11, Tuple12};
+pub use slice::{ImmutableEqVector, ImmutableTotalOrdVector};
+pub use slice::{MutableVector};
+pub use slice::{Vector, ImmutableVector};
diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs
index 9ac9e62b50d..e3a3f78dcb9 100644
--- a/src/libcore/ptr.rs
+++ b/src/libcore/ptr.rs
@@ -480,12 +480,12 @@ impl<T> Ord for *mut T {
 #[cfg(test)]
 pub mod ptr_tests {
     use super::*;
-    use prelude::*;
+    use realstd::prelude::*;
 
-    use c_str::ToCStr;
+    use realstd::c_str::ToCStr;
     use cast;
     use libc;
-    use str;
+    use realstd::str;
     use slice::{ImmutableVector, MutableVector};
 
     #[test]
diff --git a/src/libcore/result.rs b/src/libcore/result.rs
index 13f59d0875d..337b2ac89dd 100644
--- a/src/libcore/result.rs
+++ b/src/libcore/result.rs
@@ -592,11 +592,9 @@ pub fn fold_<T,E,Iter:Iterator<Result<T,E>>>(iterator: Iter) -> Result<(),E> {
 
 #[cfg(test)]
 mod tests {
-    use super::*;
-    use prelude::*;
-    use str::StrSlice;
-
-    use iter::range;
+    use realstd::result::{collect, fold, fold_};
+    use realstd::prelude::*;
+    use realstd::iter::range;
 
     pub fn op1() -> Result<int, ~str> { Ok(666) }
     pub fn op2() -> Result<int, ~str> { Err("sadface".to_owned()) }
diff --git a/src/libcore/should_not_exist.rs b/src/libcore/should_not_exist.rs
index 83e4c0d339f..587723563eb 100644
--- a/src/libcore/should_not_exist.rs
+++ b/src/libcore/should_not_exist.rs
@@ -17,14 +17,16 @@ use intrinsics;
 use iter::{Iterator, FromIterator};
 use mem;
 use num::{CheckedMul, CheckedAdd};
-use ops::Add;
 use option::{Some, None};
 use ptr::RawPtr;
 use ptr;
 use raw::Vec;
-use slice::{ImmutableVector, Vector};
+use slice::ImmutableVector;
 use str::StrSlice;
 
+#[cfg(not(test))] use ops::Add;
+#[cfg(not(test))] use slice::Vector;
+
 #[allow(ctypes)]
 extern {
     fn malloc(size: uint) -> *u8;
@@ -118,6 +120,7 @@ impl FromIterator<char> for ~str {
     }
 }
 
+#[cfg(not(test))]
 impl<'a> Add<&'a str,~str> for &'a str {
     #[inline]
     fn add(&self, rhs: & &'a str) -> ~str {
@@ -181,6 +184,7 @@ impl<A> FromIterator<A> for ~[A] {
     }
 }
 
+#[cfg(not(test))]
 impl<'a,T:Clone, V: Vector<T>> Add<V, ~[T]> for &'a [T] {
     #[inline]
     fn add(&self, rhs: &V) -> ~[T] {
@@ -189,6 +193,7 @@ impl<'a,T:Clone, V: Vector<T>> Add<V, ~[T]> for &'a [T] {
     }
 }
 
+#[cfg(not(test))]
 impl<T:Clone, V: Vector<T>> Add<V, ~[T]> for ~[T] {
     #[inline]
     fn add(&self, rhs: &V) -> ~[T] {
diff --git a/src/libcore/tuple.rs b/src/libcore/tuple.rs
index 84f850ff907..b73d85489a3 100644
--- a/src/libcore/tuple.rs
+++ b/src/libcore/tuple.rs
@@ -246,7 +246,7 @@ mod tests {
     use super::*;
     use clone::Clone;
     use cmp::*;
-    use str::StrSlice;
+    use realstd::str::StrAllocating;
 
     #[test]
     fn test_clone() {