提交 104e285e 编写于 作者: A Alex Crichton

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.
上级 f62c121e
......@@ -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 @@ fn any_move() {
#[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());
}
......
......@@ -175,9 +175,8 @@ fn default() -> bool { false }
#[cfg(test)]
mod tests {
use prelude::*;
use realstd::prelude::*;
use super::to_bit;
use str::StrSlice;
#[test]
fn test_to_bit() {
......
......@@ -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() {
......
......@@ -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");
......
......@@ -29,10 +29,6 @@
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 @@ fn default() -> char { '\x00' }
#[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 @@ fn string(c: char) -> ~str {
#[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());
}
......
......@@ -128,6 +128,8 @@ fn clone(&self) -> extern "Rust" fn($($A),*) -> ReturnType { *self }
#[cfg(test)]
mod test {
use prelude::*;
#[test]
fn test_owned_clone() {
let a = box 5i;
......
......@@ -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
......
......@@ -34,8 +34,6 @@
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 @@ fn drop(&mut self) {
#[cfg(test)]
mod test {
use super::{try_finally, Finally};
use realstd::task::failing;
#[test]
fn test_success() {
let mut i = 0;
......
......@@ -46,7 +46,7 @@
// 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);
......
......@@ -1090,7 +1090,7 @@ fn idx(&mut self, index: uint) -> Option<A> {
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 @@ fn test_lt() {
#[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() {
......
......@@ -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 @@
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 @@
/* 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 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
}
......@@ -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() {
......
......@@ -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 @@ fn ge(&self, other: &f32) -> bool { (*self) >= (*other) }
#[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) }
......
......@@ -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 @@ fn ge(&self, other: &f64) -> bool { (*self) >= (*other) }
#[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) }
......
......@@ -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)
......
......@@ -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)
......
......@@ -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)
......
......@@ -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)
......
......@@ -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)
......
......@@ -28,15 +28,19 @@
// 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 @@ fn max_value() -> $T { MAX }
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() {
......
......@@ -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);
}
......@@ -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)
......
......@@ -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)
......
......@@ -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)
......
......@@ -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)
......
......@@ -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)
......
......@@ -19,15 +19,19 @@
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() {
......
......@@ -236,6 +236,7 @@ pub fn as_mut_slice<'r>(&'r mut self) -> &'r mut [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 @@ pub fn expect(self, msg: &str) -> 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 @@ fn test_get_str() {
#[test]
fn test_get_resource() {
use rc::Rc;
use realstd::rc::Rc;
use cell::RefCell;
struct R {
......
// 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};
......@@ -480,12 +480,12 @@ fn lt(&self, other: &*mut T) -> bool { *self < *other }
#[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]
......
......@@ -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()) }
......
......@@ -17,14 +17,16 @@
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 @@ fn from_iter<T: Iterator<char>>(mut iterator: T) -> ~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 @@ fn from_iter<T: Iterator<A>>(mut iterator: T) -> ~[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 @@ fn add(&self, rhs: &V) -> ~[T] {
}
}
#[cfg(not(test))]
impl<T:Clone, V: Vector<T>> Add<V, ~[T]> for ~[T] {
#[inline]
fn add(&self, rhs: &V) -> ~[T] {
......
......@@ -246,7 +246,7 @@ mod tests {
use super::*;
use clone::Clone;
use cmp::*;
use str::StrSlice;
use realstd::str::StrAllocating;
#[test]
fn test_clone() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册